summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2008-01-23 22:46:06 +0000
committerChris Wilson <chris+github@qwirx.com>2008-01-23 22:46:06 +0000
commit8dd345eb9ecb8626d1097ebfcde99a28781bfca6 (patch)
treedcc13e0c823833f98756079967f90b2533aa9735
parent82bb4df7578149a3e08e9b52f7f8a2ff882f81d0 (diff)
Fix raidfile tests on FreeBSD 7
-rw-r--r--infrastructure/m4/ax_check_syscall_lseek.m415
-rw-r--r--lib/intercept/intercept.cpp5
2 files changed, 17 insertions, 3 deletions
diff --git a/infrastructure/m4/ax_check_syscall_lseek.m4 b/infrastructure/m4/ax_check_syscall_lseek.m4
index 6bf93c23..491cc1ed 100644
--- a/infrastructure/m4/ax_check_syscall_lseek.m4
+++ b/infrastructure/m4/ax_check_syscall_lseek.m4
@@ -24,7 +24,7 @@ AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [
#ifdef HAVE___SYSCALL_NEED_DEFN
extern "C" off_t __syscall(quad_t number, ...);
#endif
- #ifndef HAVE_SYSCALL
+ #ifdef HAVE___SYSCALL // always use it if we have it
#undef syscall
#define syscall __syscall
#endif
@@ -33,7 +33,18 @@ AC_DEFUN([AX_CHECK_SYSCALL_LSEEK], [
int res = 0;
if(fh>=0)
{
- res = syscall(SYS_lseek, fh, 0, SEEK_SET, 99);
+ // This test tries first to seek to position 0, with NO
+ // "dummy argument". If lseek does actually require a dummy
+ // argument, then it will eat SEEK_SET for the offset and
+ // try to use 99 as whence, which is invalid, so res will be
+ // -1, the program will return zero and
+ // have_lseek_dummy_param=yes
+ // (whew! that took 1 hour to figure out)
+ // The "dummy argument" probably means that it takes a 64-bit
+ // offset, so this was probably a bug anyway, and now that
+ // we cast the offset to off_t, it should never be needed
+ // (if my reasoning is correct).
+ res = syscall(SYS_lseek, fh, (off_t)0, SEEK_SET, 99);
close(fh);
}
unlink("lseektest");
diff --git a/lib/intercept/intercept.cpp b/lib/intercept/intercept.cpp
index e5e29e24..65514ae2 100644
--- a/lib/intercept/intercept.cpp
+++ b/lib/intercept/intercept.cpp
@@ -50,11 +50,14 @@
extern "C" off_t
TEST_lseek(int fildes, off_t offset, int whence);
#else
+ // if we have __syscall, we should use it for everything
+ // (on FreeBSD 7 this is required for 64-bit alignment of off_t).
+ // if not, we should continue to use the old syscall().
#ifdef HAVE___SYSCALL_NEED_DEFN
// Need this, not declared in syscall.h nor unistd.h
extern "C" off_t __syscall(quad_t number, ...);
#endif
- #ifndef HAVE_SYSCALL
+ #ifdef HAVE___SYSCALL
#undef syscall
#define syscall __syscall
#endif