git » libfiu » commit 2dafdf7

preload/posix: Use #ifdef for stat() and friends

author Alberto Bertogli
2012-08-26 19:55:40 UTC
committer Alberto Bertogli
2012-08-26 21:46:15 UTC
parent 98a0f745cc79af11ace6416142bcc6855daeb02a

preload/posix: Use #ifdef for stat() and friends

stat(), fstat() and lstat() are often defined as macros instead of functions,
which makes them much harder to override.

They were commented out, and this patch changes that to individual #ifdef, so
they can be enabled on platforms which have them as proper functions.

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

preload/posix/modules/posix.io.mod +27 -25

diff --git a/preload/posix/modules/posix.io.mod b/preload/posix/modules/posix.io.mod
index 4d31077..474e1fb 100644
--- a/preload/posix/modules/posix.io.mod
+++ b/preload/posix/modules/posix.io.mod
@@ -11,6 +11,7 @@ include: <poll.h>
 include: <fcntl.h>
 include: <errno.h>
 
+
 fiu name base: posix/io/oc/
 
 # open() has its own custom wrapper
@@ -111,31 +112,32 @@ int rename(const char *oldpath, const char *newpath);
 		ENOENT ENOMEM ENOSPC ENOTDIR ENOTEMPTY EPERM EROFS EXDEV
 
 
-# NOTE: These are disabled because the stat family function is usually defined
-# within one of the standard headers, which (besides being ugly) makes
-# overriding them this way much harder. The definitions below are commented
-# out for reference and testing purposes.
-#
-#fiu name base: posix/io/stat/
-#
-#include: <sys/types.h>
-#include: <sys/stat.h>
-#include: <unistd.h>
-#
-#int stat(const char *path, struct stat *buf);
-#	on error: -1
-#	valid errnos: EACCES EBADF EFAULT ELOOP ENAMETOOLONG ENOENT ENOMEM \
-#		ENOTDIR EOVERFLOW
-#
-#int fstat(int fd, struct stat *buf);
-#	on error: -1
-#	valid errnos: EACCES EBADF EFAULT ELOOP ENAMETOOLONG ENOENT ENOMEM \
-#		ENOTDIR EOVERFLOW
-#
-#int lstat(const char *path, struct stat *buf);
-#	on error: -1
-#	valid errnos: EACCES EBADF EFAULT ELOOP ENAMETOOLONG ENOENT ENOMEM \
-#		ENOTDIR EOVERFLOW
+# NOTE: These are #ifdef'ed because stat() and friends are usually defined as
+# macros within one of the standard headers, which (besides being ugly) makes
+# overriding them this way much harder.
+
+fiu name base: posix/io/stat/
+
+v: #ifndef stat
+int stat(const char *path, struct stat *buf);
+	on error: -1
+	valid errnos: EACCES EBADF EFAULT ELOOP ENAMETOOLONG ENOENT ENOMEM \
+		ENOTDIR EOVERFLOW
+v: #endif
+
+v: #ifndef fstat
+int fstat(int fd, struct stat *buf);
+	on error: -1
+	valid errnos: EACCES EBADF EFAULT ELOOP ENAMETOOLONG ENOENT ENOMEM \
+		ENOTDIR EOVERFLOW
+v: #endif
+
+v: #ifndef lstat
+int lstat(const char *path, struct stat *buf);
+	on error: -1
+	valid errnos: EACCES EBADF EFAULT ELOOP ENAMETOOLONG ENOENT ENOMEM \
+		ENOTDIR EOVERFLOW
+v: #endif
 
 
 fiu name base: posix/io/net/