From aeacf3ddc29fb3d83e01ac0042ca290b55e99734 Mon Sep 17 00:00:00 2001 From: CSRG Date: Mon, 21 Nov 1994 01:06:38 -0800 Subject: [PATCH 1/1] 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 --- .../nvi.1.43/PORT/aux.3.1/local/mmap.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 usr/src/contrib/nvi.1.43/PORT/aux.3.1/local/mmap.c 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); +} -- 2.20.1