From: CSRG Date: Mon, 21 Nov 1994 09:06:38 +0000 (-0800) Subject: BSD 4_4_Lite2 development X-Git-Tag: BSD-4_4_Lite2~193 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/aeacf3ddc29fb3d83e01ac0042ca290b55e99734?hp=05ad8709ae06de4dca3ae813cd316c001a2d1c0b BSD 4_4_Lite2 development Work on file usr/src/contrib/nvi.1.43/PORT/aux.3.1/local/mmap.c Synthesized-from: CSRG/cd3/4.4BSD-Lite2 --- diff --git a/usr/src/contrib/nvi.1.43/PORT/aux.3.1/local/mmap.c b/usr/src/contrib/nvi.1.43/PORT/aux.3.1/local/mmap.c new file mode 100644 index 0000000000..e001026f4e --- /dev/null +++ b/usr/src/contrib/nvi.1.43/PORT/aux.3.1/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); +}