pkgsrc/sysutils/coreutils/patches/patch-ab
tron a8e8d82674 Change version check to figure out whether NetBSD supports the statvfs(2)
systen call. We now assumes that it only exists in NetBSD 2.99.x and
newer. This will avoid build problems under the upcoming NetBSD 2.1
release. Mark this package as unusable for NetBSD-2.0[D-H]-* (a few
very old NetBSD-current versions which have statvfs(2) but a version
number smaller than 2.99.x).
2005-08-28 09:07:21 +00:00

79 lines
2 KiB
Text

$NetBSD: patch-ab,v 1.7 2005/08/28 09:07:21 tron Exp $
--- lib/mountlist.c.orig Mon Jan 26 03:58:12 2004
+++ lib/mountlist.c
@@ -173,6 +173,11 @@ xatoi (char *cp)
#if MOUNTED_GETMNTINFO
+# if defined(__NetBSD__) && (__NetBSD_Version__ > 299000000)
+# define statfs statvfs
+# define HAVE_F_FSTYPENAME_IN_STATFS 1
+# endif
+
# if ! HAVE_F_FSTYPENAME_IN_STATFS
static char *
fstype_to_string (short t)
@@ -296,6 +301,11 @@ fstype_to_string (int t)
}
#endif /* MOUNTED_VMOUNT */
+#ifdef __INTERIX
+# include <dirent.h>
+# include <sys/statvfs.h>
+#endif
+
/* Return a list of the currently mounted filesystems, or NULL on error.
Add each entry to the tail of the list so that they stay in order.
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
@@ -804,6 +814,50 @@ read_filesystem_list (int need_fs_type)
free (entries);
}
#endif /* MOUNTED_VMOUNT. */
+
+#ifdef __INTERIX /* Interix. */
+ {
+ DIR *devfs = opendir ("/dev/fs");
+ struct dirent *de;
+ struct statvfs svfs;
+ char fsname[] = "/dev/fs/#"; /* writable */
+
+ if (devfs == NULL)
+ return NULL;
+
+ while ((de = readdir (devfs)) != NULL)
+ {
+ if (strlen (de->d_name) != 1)
+ {
+ /* "Drive letters" should all be exactly one character long. */
+ continue;
+ }
+
+ fsname[8] = de->d_name[0];
+
+ if (statvfs (fsname, &svfs) != 0)
+ {
+ /* Could be an offline network fs or empty removable; don't fail. */
+ continue;
+ }
+
+ me = xmalloc (sizeof *me);
+
+ me->me_devname = xstrdup (svfs.f_mntfromname);
+ me->me_mountdir = xstrdup (svfs.f_mntonname);
+ me->me_type = xstrdup (svfs.f_fstypename);
+ me->me_dev = (dev_t)svfs.f_fsid;
+ me->me_dummy = (svfs.f_type == ST_FSTYPE_OFS ? 1 : 0);
+ me->me_remote = ((svfs.f_type == ST_FSTYPE_SAMBA
+ || svfs.f_type == ST_FSTYPE_NFS) ? 1 : 0);
+ me->me_type_malloced = 1;
+
+ /* Add to the linked list. */
+ *mtail = me;
+ mtail = &me->me_next;
+ }
+ }
+#endif
*mtail = NULL;
return mount_list;