summaryrefslogtreecommitdiff
path: root/sysutils/coreutils/patches/patch-ab
blob: 26602c9b314df52019a789fb73a76330be9cc56d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
$NetBSD: patch-ab,v 1.6 2005/03/21 14:44:08 tv 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__ > 200030000)
+# 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;