bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

coreutils-6.0: compilation failure on NetBSD 3.0 (1)


From: Bruno Haible
Subject: coreutils-6.0: compilation failure on NetBSD 3.0 (1)
Date: Fri, 18 Aug 2006 14:17:48 +0200
User-agent: KMail/1.9.1

Hi,

On NetBSD 3.0/x86, coreutils fail to compile like this:

if gcc -std=gnu99 -DHAVE_CONFIG_H -DLIBDIR=\"/home/bruno/gnu/lib\" -I. -I. -I.. 
 -I.. -I.  -I/home/bruno/gnu/include   -g -O2 -MT mountlist.o -MD -MP -MF 
".deps/mountlist.Tpo" -c -o mountlist.o mountlist.c;  then mv -f 
".deps/mountlist.Tpo" ".deps/mountlist.Po"; else rm -f ".deps/mountlist.Tpo"; 
exit 1; fi
mountlist.c: In function `fstype_to_string':
mountlist.c:178: error: case label does not reduce to an integer constant
mountlist.c:194: error: case label does not reduce to an integer constant
mountlist.c:198: error: case label does not reduce to an integer constant
mountlist.c:202: error: case label does not reduce to an integer constant
mountlist.c:206: error: case label does not reduce to an integer constant
mountlist.c:214: error: case label does not reduce to an integer constant
mountlist.c:218: error: case label does not reduce to an integer constant
mountlist.c:222: error: case label does not reduce to an integer constant
mountlist.c:226: error: case label does not reduce to an integer constant
mountlist.c:230: error: case label does not reduce to an integer constant
mountlist.c:234: error: case label does not reduce to an integer constant
mountlist.c:238: error: case label does not reduce to an integer constant
mountlist.c:242: error: case label does not reduce to an integer constant
mountlist.c:246: error: case label does not reduce to an integer constant
mountlist.c:254: error: case label does not reduce to an integer constant
mountlist.c: At top level:
mountlist.c:265: warning: `struct statfs' declared inside parameter list
mountlist.c:265: warning: its scope is only this definition or declaration, 
which is probably not what you want
mountlist.c: In function `fsp_to_string':
mountlist.c:270: error: dereferencing pointer to incomplete type
mountlist.c: In function `read_file_system_list':
mountlist.c:406: warning: passing arg 1 of `getmntinfo' from incompatible 
pointer type
mountlist.c:409: error: increment of pointer to unknown structure
mountlist.c:409: error: arithmetic on pointer to an incomplete type
mountlist.c:411: warning: passing arg 1 of `fsp_to_string' from incompatible 
pointer type
mountlist.c:414: error: dereferencing pointer to incomplete type
mountlist.c:415: error: dereferencing pointer to incomplete type
*** Error code 1

The reason is that none of the existing codes for getting the list of
mounted file systems works on NetBSD 3.0.

NetBSD doesn't have 'struct statfs' any more. But it has the POSIX
'struct statvfs' and (for backward compatibility, only when __LIBC12_SOURCE__
defined, not by default) 'struct statfs12'.

It has a getmntinfo function documented like this:

  #include <sys/types.h>
  #include <sys/statvfs.h>
  int getmntinfo (struct statvfs **mntbufp, flags);

But careful! This function's asm name is __getmntinfo13; you can therefore
not test for it through AC_CHECK_FUNC. (What you get through the asm name
'getmntinfo' is a weak symbol currently identical to the older function whose
declaration would be
  int getmntinfo (struct statfs12 **mntbufp, flags);
I don't think this weak symbol will go away; it will probably be redirected
to the new __getmntinfo13 at some point in the future.)

How to distinguish between this getmntinfo and the older 4.4BSD one? I propose
to do it by looking at the declaration in <sys/statvfs.h>. If the declaration
does not specify the argument types or if is has 'struct statfs **', it's a
4.4BSD getmntinfo; otherwise it must be a new one taking 'struct statvfs **'.

This patch works on NetBSD 3.0, and passes "make check".  After it, you might
want to rename MOUNTED_GETMNTINFO to MOUNTED_GETMNTINFO1.


2006-08-18  Bruno Haible  <address@hidden>

        Add support for NetBSD 3.0.
        * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS): Also check for
        sys/statvfs.h. When getmntinfo was found, check its declaration and
        set either MOUNTED_GETMNTINFO or MOUNTED_GETMNTINFO2 depending on it.
        * lib/mountlist.c [MOUNTED_GETMNTINFO2]: Include sys/statvfs.h.
        (ME_DUMMY): Treat "kernfs" as a dummy.
        (read_file_system_list) [MOUNTED_GETMNTINFO2]: Implement.

--- m4/ls-mntd-fs.m4.bak        2006-02-15 08:11:05.000000000 +0100
+++ m4/ls-mntd-fs.m4    2006-08-18 03:33:51.000000000 +0200
@@ -1,4 +1,4 @@
-#serial 21
+#serial 22
 # How to list mounted file systems.
 
 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
@@ -28,7 +28,7 @@
 AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
   [
 AC_CHECK_FUNCS(listmntent getmntinfo)
-AC_CHECK_HEADERS_ONCE(sys/param.h)
+AC_CHECK_HEADERS_ONCE(sys/param.h sys/statvfs.h)
 
 # We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
 # NGROUPS (as the array dimension for a struct member) without a definition.
@@ -232,10 +232,36 @@
     ])
   AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo)
   if test $fu_cv_sys_mounted_getmntinfo = yes; then
-    ac_list_mounted_fs=found
-    AC_DEFINE(MOUNTED_GETMNTINFO, 1,
-             [Define if there is a function named getmntinfo for reading the
-               list of mounted file systems.  (4.4BSD, Darwin)])
+    AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
+    AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo2,
+      [
+        AC_TRY_COMPILE([
+#include <sys/types.h>
+#if HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+#endif
+#if HAVE_SYS_STATVFS_H
+# include <sys/statvfs.h>
+#endif
+extern int getmntinfo (struct statfs **, int);
+          ], [],
+          [fu_cv_sys_mounted_getmntinfo2=no],
+          [fu_cv_sys_mounted_getmntinfo2=yes])
+      ])
+    AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
+    if test $fu_cv_sys_mounted_getmntinfo2 = no; then
+      ac_list_mounted_fs=found
+      AC_DEFINE(MOUNTED_GETMNTINFO, 1,
+               [Define if there is a function named getmntinfo for reading the
+                 list of mounted file systems and it returns an array of
+                 'struct statfs'.  (4.4BSD, Darwin)])
+    else
+      ac_list_mounted_fs=found
+      AC_DEFINE(MOUNTED_GETMNTINFO2, 1,
+               [Define if there is a function named getmntinfo for reading the
+                 list of mounted file systems and it returns an array of
+                 'struct statvfs'.  (NetBSD 3.0)])
+    fi
   fi
 fi
 
--- lib/mountlist.c.bak 2006-07-20 09:59:31.000000000 +0200
+++ lib/mountlist.c     2006-08-18 04:14:14.000000000 +0200
@@ -82,6 +82,10 @@
 # include <sys/mount.h>
 #endif
 
+#ifdef MOUNTED_GETMNTINFO2     /* NetBSD 3.0.  */
+# include <sys/statvfs.h>
+#endif
+
 #ifdef MOUNTED_GETMNT          /* Ultrix.  */
 # include <sys/mount.h>
 # include <sys/fs_types.h>
@@ -147,6 +151,8 @@
      || strcmp (Fs_type, "none") == 0          \
      || strcmp (Fs_type, "proc") == 0          \
      || strcmp (Fs_type, "subfs") == 0         \
+     /* for NetBSD 3.0 */                      \
+     || strcmp (Fs_type, "kernfs") == 0                \
      /* for Irix 6.5 */                                \
      || strcmp (Fs_type, "ignore") == 0)
 #endif
@@ -426,6 +432,32 @@
   }
 #endif /* MOUNTED_GETMNTINFO */
 
+#ifdef MOUNTED_GETMNTINFO2     /* NetBSD 3.0.  */
+  {
+    struct statvfs *fsp;
+    int entries;
+
+    entries = getmntinfo (&fsp, MNT_NOWAIT);
+    if (entries < 0)
+      return NULL;
+    for (; entries-- > 0; fsp++)
+      {
+       me = xmalloc (sizeof *me);
+       me->me_devname = xstrdup (fsp->f_mntfromname);
+       me->me_mountdir = xstrdup (fsp->f_mntonname);
+       me->me_type = xstrdup (fsp->f_fstypename);
+       me->me_type_malloced = 1;
+       me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
+       me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
+       me->me_dev = (dev_t) -1;        /* Magic; means not known yet. */
+
+       /* Add to the linked list. */
+       *mtail = me;
+       mtail = &me->me_next;
+      }
+  }
+#endif /* MOUNTED_GETMNTINFO2 */
+
 #ifdef MOUNTED_GETMNT          /* Ultrix.  */
   {
     int offset = 0;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]