[Box Backup-commit] COMMIT r2299 - box/trunk/lib/intercept
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Fri Sep 26 21:24:11 BST 2008
Author: chris
Date: 2008-09-26 21:24:11 +0100 (Fri, 26 Sep 2008)
New Revision: 2299
Modified:
box/trunk/lib/intercept/intercept.cpp
box/trunk/lib/intercept/intercept.h
Log:
Fix compilation of open64() intercept.
Modified: box/trunk/lib/intercept/intercept.cpp
===================================================================
--- box/trunk/lib/intercept/intercept.cpp 2008-09-26 20:23:34 UTC (rev 2298)
+++ box/trunk/lib/intercept/intercept.cpp 2008-09-26 20:24:11 UTC (rev 2299)
@@ -22,6 +22,7 @@
#endif
#include <errno.h>
+#include <stdarg.h>
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
@@ -232,7 +233,11 @@
}
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 @@
}
}
+ 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 @@
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)
Modified: box/trunk/lib/intercept/intercept.h
===================================================================
--- box/trunk/lib/intercept/intercept.h 2008-09-26 20:23:34 UTC (rev 2298)
+++ box/trunk/lib/intercept/intercept.h 2008-09-26 20:24:11 UTC (rev 2299)
@@ -23,14 +23,17 @@
typedef struct dirent *(readdir_t) (DIR *dir);
typedef int (closedir_t)(DIR *dir);
#if defined __GNUC__ && __GNUC__ >= 2
-#define LINUX_WEIRD_LSTAT
-#define STAT_STRUCT struct stat /* should be stat64 */
- typedef int (lstat_t) (int ver, const char *file_name,
- STAT_STRUCT *buf);
+ #if _FILE_OFFSET_BITS == 64
+ #define DEFINE_ONLY_OPEN64
+ #endif
+ #define LINUX_WEIRD_LSTAT
+ #define STAT_STRUCT struct stat /* should be stat64 */
+ typedef int (lstat_t) (int ver, const char *file_name,
+ STAT_STRUCT *buf);
#else
-#define STAT_STRUCT struct stat
- typedef int (lstat_t) (const char *file_name,
- STAT_STRUCT *buf);
+ #define STAT_STRUCT struct stat
+ typedef int (lstat_t) (const char *file_name,
+ STAT_STRUCT *buf);
#endif
}
More information about the Boxbackup-commit
mailing list