summaryrefslogtreecommitdiffstats
path: root/sysutils/gnome-mount/files/patch-src_gnome-mount.c
blob: 61d5c544ae64b89d07083acd775a22603bff31ff (plain) (blame)
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
--- src/gnome-mount.c.orig  Sun Sep 17 01:17:54 2006
+++ src/gnome-mount.c   Mon Nov 13 21:40:26 2006
@@ -51,9 +51,14 @@
 #include <libhal.h>
 #include <libhal-storage.h>
 
-#ifndef sun
+#if !defined(sun) && !defined(__FreeBSD__)
 #include <mntent.h>
-#else
+#elif defined(__FreeBSD__)
+#include <fstab.h>
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#elif defined(sun)
 #include <sys/mnttab.h>
 #endif
 
@@ -582,19 +587,24 @@ static char *
 get_mntent_mount_point(const char *device_file)
 {
    char *mount_point;
+#if! defined(sun) && !defined(__FreeBSD__)
    FILE *f;
-#ifndef sun
    struct mntent mnt;
    struct mntent *mnte;
    char buf[512];
-#else
+#elif defined(__FreeBSD__)
+   struct statfs *mounts;
+   int n_mounts;
+   int i;
+#elif defined(sun)
+   FILE *f;
    struct mnttab mnt;
    struct mnttab mpref = { NULL, NULL, NULL, NULL, NULL };
 #endif
 
    mount_point = NULL;
 
-#ifndef sun
+#if !defined(sun) && !defined(__FreeBSD__)
    if ((f = setmntent ("/proc/mounts", "r")) != NULL) {
        
        while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
@@ -608,7 +618,7 @@ get_mntent_mount_point(const char *devic
        endmntent (f);
    }
 
-#else /* sun */
+#elif defined(sun) /* sun */
 
    if ((f = fopen(MNTTAB, "r")) != NULL) {
        mpref.mnt_special = (char *)device_file;
@@ -617,8 +627,13 @@ get_mntent_mount_point(const char *devic
        }
        fclose(f);
    }
-
-#endif /* sun */
+#elif defined(__FreeBSD__)
+   n_mounts = getmntinfo(&mounts, MNT_NOWAIT);
+   for (i = 0; i < n_mounts; i++) {
+       if (!strcmp(mounts[i].f_mntfromname, device_file))
+           mount_point = g_strdup (mounts[i].f_mntonname);
+   }
+#endif /* sun && __FreeBSD__ */
 
 out:
    return (mount_point);