git » libfiu » commit d896135

preload/posix: Add more functions (mmap(), readdir() and their friends)

author Alberto Bertogli
2009-06-19 00:30:43 UTC
committer Alberto Bertogli
2009-06-19 00:30:43 UTC
parent ea0a2be66a8f242510eaf784352459a53649b72f

preload/posix: Add more functions (mmap(), readdir() and their friends)

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

preload/posix/function_list +17 -1
preload/posix/modules/posix.io.mod +24 -0
preload/posix/modules/posix.mm.mod +68 -0

diff --git a/preload/posix/function_list b/preload/posix/function_list
index e1084aa..394a705 100644
--- a/preload/posix/function_list
+++ b/preload/posix/function_list
@@ -36,6 +36,22 @@ send			posix/io/net/send
 sendto			posix/io/net/sendto
 sendmsg			posix/io/net/sendmsg
 shutdown		posix/io/net/shutdown
-sync_file_range		linux/io/sync_file_range (Linux-only)
 
+opendir			posix/io/dir/opendir
+fdopendir		posix/io/dir/fdopendir
+readdir			posix/io/dir/readdir
+readdir_r		posix/io/dir/readdir_r
+closedir		posix/io/dir/closedir
+
+mmap			posix/mm/mmap
+munmap			posix/mm/munmap
+msync			posix/mm/msync
+mprotect		posix/mm/mprotect
+madvise			posix/mm/madvise
+mlock			posix/mm/mlock
+munlock			posix/mm/munlock
+mlockall		posix/mm/mlockall
+munlockall		posix/mm/munlockall
+
+sync_file_range		linux/io/sync_file_range (Linux-only)
 
diff --git a/preload/posix/modules/posix.io.mod b/preload/posix/modules/posix.io.mod
index 17bcb8c..c8b40d9 100644
--- a/preload/posix/modules/posix.io.mod
+++ b/preload/posix/modules/posix.io.mod
@@ -58,6 +58,30 @@ ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
 	valid errnos: EBADFD EFAULT EFBIG EINTR EINVAL EIO ENOSPC
 
 
+fiu name base: posix/io/dir/
+
+include: <dirent.h>
+
+DIR *opendir(const char *name);
+	on error: NULL
+	valid errnos: EACCES EBADF EMFILE ENFILE ENOENT ENOMEM ENOTDIR
+
+DIR *fdopendir(int fd);
+	on error: NULL
+	valid errnos: EACCES EBADF EMFILE ENFILE ENOENT ENOMEM ENOTDIR
+
+struct dirent *readdir(DIR *dirp);
+	on error: NULL
+	valid errnos: EBADF
+
+int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
+	on error: 1
+
+int closedir(DIR *dirp);
+	on error: -1
+	valid errnos: EBADF
+
+
 fiu name base: posix/io/net/
 
 int socket(int domain, int type, int protocol);
diff --git a/preload/posix/modules/posix.mm.mod b/preload/posix/modules/posix.mm.mod
new file mode 100644
index 0000000..443f816
--- /dev/null
+++ b/preload/posix/modules/posix.mm.mod
@@ -0,0 +1,68 @@
+
+include: <unistd.h>
+include: <errno.h>
+include: <sys/mman.h>
+
+fiu name base: posix/mm/
+
+
+v: #ifdef _POSIX_MAPPED_FILES
+
+void *mmap(void *addr, size_t length, int prot, int flags, int fd, \
+		off_t offset);
+	on error: MAP_FAILED
+	valid errnos: EACCES EAGAIN EBADF EINVAL ENFILE ENODEV ENOMEM EPERM \
+		ETXTBSY
+
+int munmap(void *addr, size_t length);
+	on error: 0
+	valid errnos: EACCES EAGAIN EBADF EINVAL ENFILE ENODEV ENOMEM EPERM \
+		ETXTBSY
+
+
+int msync(void *addr, size_t length, int flags);
+	on error: -1
+	valid errnos: EBUSY EINVAL ENOMEM
+
+int mprotect(void *addr, size_t len, int prot);
+	on error: -1
+	valid errnos: EACCES EINVAL ENOMEM
+
+int madvise(void *addr, size_t length, int advice);
+	on error: -1
+	valid errnos: EAGAIN EBADF EINVAL EIO ENOMEM
+
+v: #else
+v:   #warning "no mmap() (and friends) wrappers available"
+v: #endif
+
+
+v: #ifdef _POSIX_MEMLOCK_RANGE
+
+int mlock(const void *addr, size_t len);
+	on error: -1
+	valid errnos: ENOMEM EPERM EAGAIN EINVAL
+
+int munlock(const void *addr, size_t len);
+	on error: -1
+	valid errnos: ENOMEM EPERM EAGAIN EINVAL
+
+v: #else
+v:   #warning "no mlock()/munlock() wrappers available"
+v: #endif
+
+
+v: #ifdef _POSIX_MEMLOCK
+
+int mlockall(int flags);
+	on error: -1
+	valid errnos: ENOMEM EPERM EINVAL
+
+int munlockall(void);
+	on error: -1
+	valid errnos: ENOMEM EPERM
+
+v: #else
+v:   #warning "no mlockall()/munlockall() wrappers available"
+v: #endif
+