diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-09-26 20:24:11 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-09-26 20:24:11 +0000 |
commit | 4bb33be645a37da5af0f27b3593985148e366388 (patch) | |
tree | 99275778f7320baf2de95ebd87a666e2d680dccb /lib/intercept/intercept.cpp | |
parent | e40140f8af64b1ddf5941182b0d367eeb6567fcf (diff) |
Fix compilation of open64() intercept.
Diffstat (limited to 'lib/intercept/intercept.cpp')
-rw-r--r-- | lib/intercept/intercept.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/intercept/intercept.cpp b/lib/intercept/intercept.cpp index 4208ce97..9a15971a 100644 --- a/lib/intercept/intercept.cpp +++ b/lib/intercept/intercept.cpp @@ -22,6 +22,7 @@ #endif #include <errno.h> +#include <stdarg.h> #ifdef HAVE_DLFCN_H #include <dlfcn.h> @@ -232,7 +233,11 @@ int intercept_reterr() } extern "C" int -open(const char *path, int flags, mode_t mode) +#ifdef DEFINE_ONLY_OPEN64 + open64(const char *path, int flags, ...) +#else + open(const char *path, int flags, ...) +#endif // DEFINE_ONLY_OPEN64 { if(intercept_count > 0) { @@ -245,6 +250,15 @@ open(const char *path, int flags, mode_t mode) } } + mode_t mode = 0; + if (flags & O_CREAT) + { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + } + #ifdef PLATFORM_NO_SYSCALL int r = TEST_open(path, flags, mode); #else @@ -266,14 +280,27 @@ open(const char *path, int flags, mode_t mode) return r; } +#ifndef DEFINE_ONLY_OPEN64 extern "C" int -open64(const char *path, int flags, mode_t mode) +// open64(const char *path, int flags, mode_t mode) +// open64(const char *path, int flags, ...) +open64 (__const char *path, int flags, ...) { + mode_t mode = 0; + if (flags & O_CREAT) + { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + } + // With _FILE_OFFSET_BITS set to 64 this should really use (flags | // O_LARGEFILE) here, but not actually necessary for the tests and not // worth the trouble finding O_LARGEFILE return open(path, flags, mode); } +#endif // !DEFINE_ONLY_OPEN64 extern "C" int close(int d) |