From: CSRG Date: Fri, 2 Dec 1994 00:05:43 +0000 (-0800) Subject: BSD 4_4_Lite2 development X-Git-Tag: BSD-4_4_Lite2~185 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/31b138d3c1e521e88d0b043baa24db96cb9497a7 BSD 4_4_Lite2 development Work on file usr/src/contrib/nvi.1.43/PORT/isc.3/local/mmap.c Synthesized-from: CSRG/cd3/4.4BSD-Lite2 --- 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 index 0000000000..e001026f4e --- /dev/null +++ b/usr/src/contrib/nvi.1.43/PORT/isc.3/local/mmap.c @@ -0,0 +1,42 @@ +#include + +#include + +#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); +}