BSD 4_4_Lite2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 2 Dec 1994 00:05:43 +0000 (16:05 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 2 Dec 1994 00:05:43 +0000 (16:05 -0800)
Work on file usr/src/contrib/nvi.1.43/PORT/isc.3/local/mmap.c

Synthesized-from: CSRG/cd3/4.4BSD-Lite2

usr/src/contrib/nvi.1.43/PORT/isc.3/local/mmap.c [new file with mode: 0644]

diff --git a/usr/src/contrib/nvi.1.43/PORT/isc.3/local/mmap.c b/usr/src/contrib/nvi.1.43/PORT/isc.3/local/mmap.c
new file mode 100644 (file)
index 0000000..e001026
--- /dev/null
@@ -0,0 +1,42 @@
+#include <sys/types.h>
+
+#include <stdlib.h>
+
+#include "compat.h"
+
+/*
+ * This function emulates mmap() by reading `len' bytes from the file
+ * descriptor `fd' and returning a pointer to that memory.  The "mapped"
+ * region can later be deallocated with munmap().
+ *
+ * Note: ONLY reading is supported and only reading of the exact size
+ * of the file will work.
+ */
+char *
+mmap_hack(addr, len, prot, flags, fd, off)
+       char *addr;
+       size_t len;
+       int prot;
+       int flags;
+       int fd;
+       off_t off;
+{
+       char *ptr;
+
+       if ((ptr = (char *)malloc(len)) == 0)
+               return (-1);
+       if (read(fd, ptr, len) < 0) {
+               free(ptr);
+               return (-1);
+       }
+       return (ptr);
+}
+
+int
+munmap_hack(addr, len)
+       char *addr;
+       size_t len;
+{
+       free(addr);
+       return (0);
+}