diff options
author | Reinhard Tartler <siretart@tauware.de> | 2018-02-20 21:49:13 -0500 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2018-02-20 21:49:13 -0500 |
commit | f28f88e5e72ba1499409047a9d6985eb312c0232 (patch) | |
tree | c9c267f18264b3dfe715a363935bb6ac20904492 /lib/intercept/intercept.cpp | |
parent | e19a5db232e1ef90e9a02159d2fbd9707ffe4373 (diff) | |
parent | 6d7e9562e8485591a4888f1fc2d3c6c657dc7a01 (diff) |
Merge tag 'BoxBackup-0.12.master.180102.6d7e956' into upstream
Diffstat (limited to 'lib/intercept/intercept.cpp')
-rw-r--r-- | lib/intercept/intercept.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/intercept/intercept.cpp b/lib/intercept/intercept.cpp index 7a33b610..72bd8d4e 100644 --- a/lib/intercept/intercept.cpp +++ b/lib/intercept/intercept.cpp @@ -15,7 +15,6 @@ #include <sys/syscall.h> #endif #include <sys/types.h> -#include <unistd.h> #ifdef HAVE_SYS_UIO_H #include <sys/uio.h> @@ -132,7 +131,7 @@ void intercept_setup_error(const char *filename, unsigned int errorafter, int er intercept_delay_ms = 0; } -void intercept_setup_delay(const char *filename, unsigned int delay_after, +void intercept_setup_delay(const char *filename, unsigned int delay_after, int delay_ms, int syscall_to_delay, int num_delays) { BOX_TRACE("Setup for delay: " << filename << @@ -243,6 +242,10 @@ extern "C" int open(const char *path, int flags, ...) #endif // DEFINE_ONLY_OPEN64 { + // Some newer architectures don't have an open() syscall, but use openat() instead. + // In these cases we will need to call sys_openat() instead of sys_open(). + // https://chromium.googlesource.com/linux-syscall-support/ + if(intercept_count > 0) { if(intercept_filename != NULL && @@ -265,6 +268,8 @@ extern "C" int #ifdef PLATFORM_NO_SYSCALL int r = TEST_open(path, flags, mode); +#elif HAVE_DECL_SYS_OPENAT && !HAVE_DECL_SYS_OPEN + int r = syscall(SYS_openat, AT_FDCWD, path, flags, mode); #else int r = syscall(SYS_open, path, flags, mode); #endif @@ -390,7 +395,7 @@ lseek(int fildes, off_t offset, int whence) #else #ifdef HAVE_LSEEK_DUMMY_PARAM off_t r = syscall(SYS_lseek, fildes, 0 /* extra 0 required here! */, offset, whence); - #elif defined(_FILE_OFFSET_BITS) + #elif defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 32 // Don't bother trying to call SYS__llseek on 32 bit since it is // fiddly and not needed for the tests off_t r = syscall(SYS_lseek, fildes, (uint32_t)offset, whence); @@ -514,7 +519,7 @@ DIR *opendir(const char *dirname) { if (opendir_real == NULL) { - opendir_real = (opendir_t*)find_function("opendir"); + opendir_real = (opendir_t*)find_function(FUNC_OPENDIR); } if (opendir_real == NULL) @@ -547,7 +552,7 @@ struct dirent *readdir(DIR *dir) if (readdir_real == NULL) { - readdir_real = (readdir_t*)find_function("readdir"); + readdir_real = (readdir_t*)find_function(FUNC_READDIR); } if (readdir_real == NULL) |