[Box Backup-dev] RC 3 testing: NetBSD 3.0 fails

Per Thomsen boxbackup-dev@fluffy.co.uk
Tue, 21 Feb 2006 09:30:32 -0800


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

On 2/21/06 8:19 AM, Martin Ebourne wrote:
> [resend]
>
> On Mon, 2006-02-20 at 12:01 -0800, Per Thomsen wrote:
>> When running configure on NetBSD, I get the following error:
>>
>> configure: error: cannot work out how to discover mount points on your
>> platform
>>
>> I've narrowed it down to the fact that NetBSD doesn't use the 'statfs'
>> struct, but rather 'statvfs'. I am not an autoconf hacker, so I don't
>> know how to make that addition, but if I hack the configure script to
>> use the 'statvfs' struct in its test program, the configure completes
>> (of course it doesn't work beyond completing the script; I can't make
>> anything).
>
> The autoconf magic should be as below. You'll need to ./bootstrap.
>
> You'll then need to change the code to make use of the extra defines and
> do the right thing. I don't have any way of testing this, and need
> sleep, so that's left as an exercise.
I have the full set of diffs that create a working set of executables
(with test failures, mind you).

I have attached the diff.

WARNING: this is very much a work in progress, I just thought that if
someone else was working on the same thing, it would be useful to share
the diffs.

There are several instances of pointer conversions that the compiler
will not accept. To get the build working, I simply changed them to what
worked. These are mostly related to the 'EV_SET' macro in <sys/event.h>.
It might need to be ifdef'ed, or a macro created for each platform, or
something.

I'm relatively confident in the mount-point changes I made, but
obviously would like feedback on it. There is a different way to do some
of the changes I made (involving creating a macro for the statfs/statvfs
call), and if you don't like the way it looks now, that's an easy change.
>
> Cheers,
>
> Martin.
>
> ------------------------------------------------------------------------
>
> Index: infrastructure/m4/ax_check_mount_point.m4
>
> ===================================================================
>
> --- infrastructure/m4/ax_check_mount_point.m4	(revision 474)
>
> +++ infrastructure/m4/ax_check_mount_point.m4	(working copy)
>
> @@ -7,9 +7,11 @@
>
>  dnl HAVE_MNTENT_H
>
>  dnl HAVE_SYS_MNTTAB_H
>
>  dnl HAVE_SYS_MOUNT_H
>
> +dnl HAVE_SYS_STATVFS_H
>
>  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
>
> @@ -18,21 +20,25 @@
>
>  dnl @license AllPermissive
>
>  
>
>  AC_DEFUN([AX_CHECK_MOUNT_POINT], [
>
> -  AC_CHECK_FUNCS([getmntent statfs])
>
> -  AC_CHECK_HEADERS([sys/param.h])
>
> +  AC_CHECK_FUNCS([getmntent statfs statvfs])
>
> +  AC_CHECK_HEADERS([sys/param.h sys/statvfs.h])
>
>    AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/mount.h],,, [[
>
>      #include <stdio.h>
>
>      #ifdef HAVE_SYS_PARAM_H
>
>        #include <sys/param.h>
>
>      #endif
>
>      ]])
>
> -  # BSD
>
> +  # OpenBSD/FreeBSD
>
>    AC_CHECK_MEMBERS([struct statfs.f_mntonname],,, [[
>
>      #ifdef HAVE_SYS_PARAM_H
>
>        #include <sys/param.h>
>
>      #endif
>
>      #include <sys/mount.h>
>
>      ]])
>
> +  # NetBSD
>
> +  AC_CHECK_MEMBERS([struct statvfs.f_mntonname],,, [[
>
> +    #include <sys/statvfs.h>
>
> +    ]])
>   
See my diff below... I think all you need is to include <sys/mount.h>,
since it explicitly includes <sys/statvfs.h>

Again, I'm no guru on this stuff, so I defer to you... My diff worked,
and produced a workable Makefile.
>    # Linux
>
>    AC_CHECK_MEMBERS([struct mntent.mnt_dir],,, [[#include <mntent.h>]])
>
>    # Solaris
>
> @@ -41,6 +47,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
>   
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


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

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: lib/server/SocketListen.h
===================================================================
--- lib/server/SocketListen.h	(revision 482)
+++ lib/server/SocketListen.h	(working copy)
@@ -253,7 +253,7 @@
 	// --------------------------------------------------------------------------
 	void FillInKEvent(struct kevent &rEvent, int Flags = 0) const
 	{
-		EV_SET(&rEvent, mSocketHandle, EVFILT_READ, 0, 0, 0, (void*)this);
+		EV_SET(&rEvent, mSocketHandle, EVFILT_READ, 0, 0, 0, (int)this);
 	}
 #else
 	// --------------------------------------------------------------------------
Index: lib/common/WaitForEvent.h
===================================================================
--- lib/common/WaitForEvent.h	(revision 482)
+++ lib/common/WaitForEvent.h	(working copy)
@@ -70,7 +70,7 @@
 		pItem->FillInKEvent(e, Flags);
 		// Fill in extra flags to say what to do
 		e.flags |= EV_ADD;
-		e.udata = (void*)pItem;
+		e.udata = (int)pItem;
 		if(::kevent(mKQueue, &e, 1, NULL, 0, NULL) == -1)
 		{
 			THROW_EXCEPTION(CommonException, KEventErrorAdd)
Index: lib/common/WaitForEvent.cpp
===================================================================
--- lib/common/WaitForEvent.cpp	(revision 482)
+++ lib/common/WaitForEvent.cpp	(working copy)
@@ -123,7 +123,7 @@
 
 	case 1:
 		// Event happened!
-		return e.udata;
+		return (void *)e.udata;
 		break;
 		
 	default:
Index: lib/common/EventWatchFilesystemObject.cpp
===================================================================
--- lib/common/EventWatchFilesystemObject.cpp	(revision 482)
+++ lib/common/EventWatchFilesystemObject.cpp	(working copy)
@@ -91,7 +91,7 @@
 // --------------------------------------------------------------------------
 void EventWatchFilesystemObject::FillInKEvent(struct kevent &rEvent, int Flags) const
 {
-	EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, NOTE_DELETE | NOTE_WRITE, 0, (void*)this);
+	EV_SET(&rEvent, mDescriptor, EVFILT_VNODE, EV_CLEAR, NOTE_DELETE | NOTE_WRITE, 0, (int)this);
 }
 #else
 void EventWatchFilesystemObject::FillInPoll(int &fd, short &events, int Flags) const
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)
 				}

--------------040705040307060102040000--