[Box Backup-dev] NetBSD 3.0 patch

Per Thomsen boxbackup-dev@fluffy.co.uk
Wed, 22 Feb 2006 23:51:51 -0800


This is a multi-part message in MIME format.
--------------000009070301090206070306
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Here is the patch for NetBSD 3.0.

List of changes:

    * configure.ac: added a (hackish) check for netbsd, which excludes
      checking for kqueue.
    * ax_check_mount_point.m4: statvfs changes
    * bin/bbackupd/BackupDaemon.cpp: using the
      HAVE_STRUCT_STATVFS_F_MNTONNAME macro to ifdef the code.

I tested the configure changes on FC4 as well, and they seemed to have
no adverse impact. I am no expert on autoconf, so please check my work.

I ran the full debug tests on NetBSD. Same results as before:
common: PASSED
crypto: PASSED
compress: FAILED: Exception caught: St9bad_alloc
basicserver: PASSED
raidfile: PASSED
backupstore: PASSED
backupstorefix: FAILED: Exception caught: BackupStore
CouldNotFindEntryInDirectory
backupstorepatch: FAILED: 2 tests failed
backupdiff: PASSED
bbackupd: FAILED: 2 tests failed    

Then ran the bbackupd debug test. Again, 4 failures WRT bbackupquery
return codes:
FAILURE: Condition [compareReturnValue == 1*256] failed at
testbbackupd.cpp(838)
FAILURE: Condition [compareReturnValue == 1*256] failed at
testbbackupd.cpp(846)
FAILURE: Condition [compareReturnValue == 1*256] failed at
testbbackupd.cpp(850)
FAILURE: Condition [compareReturnValue == 1*256] failed at
testbbackupd.cpp(860)
FAILED: 4 tests failed
bbackupd: FAILED: 4 tests failed   


Then bbackupd release. All tests passed. Same as before.

Finally, backupstorepatch debug. All tests passed. Also as before.

Let me know if you want me to run more tests.

Thanks,
Per

-- 
Per Reedtz Thomsen | Reedtz Consulting, LLC | F: 209 883 4119
V: 209 883 4102    |   pthomsen@reedtz.com  | C: 209 996 9561
GPG ID: 1209784F   |  Yahoo! Chat: pthomsen | AIM: pthomsen


--------------000009070301090206070306
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
 name="NetBSD-Patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="NetBSD-Patch"

Index: infrastructure/m4/ax_check_mount_point.m4
===================================================================
--- infrastructure/m4/ax_check_mount_point.m4	(revision 482)
+++ infrastructure/m4/ax_check_mount_point.m4	(working copy)
@@ -10,6 +10,7 @@
 dnl HAVE_STRUCT_MNTENT_MNT_DIR
 dnl HAVE_STRUCT_MNTTAB_MNT_MOUNTP
 dnl HAVE_STRUCT_STATFS_F_MNTONNAME
+dnl HAVE_STRUCT_STATvFS_F_MNTONNAME
 dnl Also ACTION-IF-TRUE and ACTION-IF-FALSE are run as appropriate
 dnl
 dnl @category C
@@ -33,6 +34,13 @@
     #endif
     #include <sys/mount.h>
     ]])
+  # NetBSD
+  AC_CHECK_MEMBERS([struct statvfs.f_mntonname],,, [[
+    #ifdef HAVE_SYS_PARAM_H
+      #include <sys/param.h>
+    #endif
+    #include <sys/mount.h>
+    ]])
   # Linux
   AC_CHECK_MEMBERS([struct mntent.mnt_dir],,, [[#include <mntent.h>]])
   # Solaris
@@ -41,6 +49,7 @@
     #include <sys/mnttab.h>
     ]])
   if test "x$ac_cv_member_struct_statfs_f_mntonname" = "xyes" || \
+     test "x$ac_cv_member_struct_statvfs_f_mntonname" = "xyes" || \
      test "x$ac_cv_member_struct_mntent_mnt_dir" = "xyes" || \
      test "x$ac_cv_member_struct_mnttab_mnt_mountp" = "xyes"
   then
Index: configure.ac
===================================================================
--- configure.ac	(revision 482)
+++ configure.ac	(working copy)
@@ -136,7 +136,14 @@
 AC_FUNC_ERROR_AT_LINE
 AC_TYPE_SIGNAL
 AC_FUNC_STAT
-AC_CHECK_FUNCS([getpeereid kqueue lchown setproctitle getpid])
+# NetBSD implements kqueue too differently for us to get it fixed by 0.10
+# TODO: Remove this when NetBSD kqueue implementation is working
+netbsd_hack=`echo $target_os | sed 's/netbsd.*/netbsd/'`
+if test "$netbsd_hack" = "netbsd"; then
+  AC_CHECK_FUNCS([getpeereid lchown setproctitle getpid])
+else
+  AC_CHECK_FUNCS([getpeereid kqueue lchown setproctitle getpid])
+fi
 AX_FUNC_SYSCALL
 AX_CHECK_SYSCALL_LSEEK
 AC_CHECK_FUNCS([listxattr llistxattr getxattr lgetxattr setxattr lsetxattr])
Index: bin/bbackupd/BackupDaemon.cpp
===================================================================
--- bin/bbackupd/BackupDaemon.cpp	(revision 482)
+++ bin/bbackupd/BackupDaemon.cpp	(working copy)
@@ -1170,7 +1170,7 @@
 
 
 
-#ifndef HAVE_STRUCT_STATFS_F_MNTONNAME
+#if !defined(HAVE_STRUCT_STATFS_F_MNTONNAME) && !defined(HAVE_STRUCT_STATVFS_F_NMTONNAME)
 	// string comparison ordering for when mount points are handled
 	// by code, rather than the OS.
 	typedef struct
@@ -1234,7 +1234,7 @@
 	int numIDMaps = 0;
 
 #ifdef HAVE_MOUNTS
-#ifndef HAVE_STRUCT_STATFS_F_MNTONNAME
+#if !defined(HAVE_STRUCT_STATFS_F_MNTONNAME) && !defined(HAVE_STRUCT_STATVFS_F_MNTONNAME)
 	// Linux and others can't tell you where a directory is mounted. So we
 	// have to read the mount entries from /etc/mtab! Bizarre that the OS
 	// itself can't tell you, but there you go.
@@ -1308,7 +1308,7 @@
 		ASSERT(*i == "/");
 	}
 #endif // n NDEBUG
-#endif // n HAVE_STRUCT_STATFS_F_MNTONNAME
+#endif // n HAVE_STRUCT_STATFS_F_MNTONNAME || n HAVE_STRUCT_STATVFS_F_MNTONNAME
 #endif // HAVE_MOUNTS
 
 	// Then... go through each of the entries in the configuration,
@@ -1332,11 +1332,16 @@
 			// Do a fsstat on the pathname to find out which mount it's on
 			{
 
-#if defined HAVE_STRUCT_STATFS_F_MNTONNAME || defined WIN32
+#if defined HAVE_STRUCT_STATFS_F_MNTONNAME || defined HAVE_STRUCT_STATVFS_F_MNTONNAME || defined WIN32
 
 				// BSD style statfs -- includes mount point, which is nice.
+#ifdef HAVE_STRUCT_STATVFS_F_MNTONNAME
+				struct statvfs s;
+				if(::statvfs(ploc->mPath.c_str(), &s) != 0)
+#else // HAVE_STRUCT_STATVFS_F_MNTONNAME
 				struct statfs s;
 				if(::statfs(ploc->mPath.c_str(), &s) != 0)
+#endif // HAVE_STRUCT_STATVFS_F_MNTONNAME
 				{
 					THROW_EXCEPTION(CommonException, OSFileError)
 				}

--------------000009070301090206070306--