1 /* Iain Sandoe, Oct 2015. */
3 #include "cctools_map_fd.h"
6 /* The interface is originally defined in libc.h */
8 /* The actual code for the map_fd syscall is in kern_mman.c in xnu.
9 - replace it with a call to mmap. */
12 map_fd(int fd
, vm_offset_t offset
, vm_offset_t
*addr
,
13 boolean_t find_space
, vm_size_t numbytes
)
15 void *ret_addr
= (void *)0; /* default, let the system pick the adddress. */
16 int prot
= PROT_READ
| PROT_WRITE
;
17 int flags
= MAP_FILE
| MAP_PRIVATE
;
20 /* Use the address specified.
21 At present, this is not used by cctools - and presumably the code will
22 be updated on some future drop to remove it. */
23 ret_addr
= (void *) *addr
;
27 ret_addr
= mmap(ret_addr
, numbytes
, prot
, flags
, fd
, offset
);
29 /* mmp either returns MAP_FAILED, or the result. */
30 if (ret_addr
== MAP_FAILED
)
33 *addr
= (vm_offset_t
)ret_addr
;