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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
$NetBSD: patch-ab,v 1.3 2009/03/10 05:24:36 dsainty Exp $
--- src/gnome-mount.c.orig 2008-04-17 11:41:32.000000000 +1200
+++ src/gnome-mount.c 2009-03-10 17:11:00.000000000 +1300
@@ -30,6 +30,7 @@
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
+#include <locale.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -51,9 +52,9 @@
#define NOTIFY_EXPIRES_DEFAULT -1
#endif
-#if !defined(sun) && !defined(__FreeBSD__)
+#if !defined(sun) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
#include <mntent.h>
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
#include <fstab.h>
#include <sys/param.h>
#include <sys/ucred.h>
@@ -677,15 +678,19 @@
get_mntent_mount_point(const char *device_file)
{
char *mount_point;
-#if! defined(sun) && !defined(__FreeBSD__)
+#if! defined(sun) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
FILE *f;
struct mntent mnt;
struct mntent *mnte;
char buf[512];
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
struct statfs *mounts;
int n_mounts;
int i;
+#elif defined(__NetBSD__)
+ struct statvfs *mounts;
+ int n_mounts;
+ int i;
#elif defined(sun)
FILE *f;
struct mnttab mnt;
@@ -694,7 +699,7 @@
mount_point = NULL;
-#if !defined(sun) && !defined(__FreeBSD__)
+#if !defined(sun) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
if ((f = setmntent ("/proc/mounts", "r")) != NULL) {
while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
@@ -717,13 +722,13 @@
}
fclose(f);
}
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
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__ */
+#endif /* sun && __FreeBSD__ && __NetBSD__ && __DragonFly__ */
out:
return (mount_point);
@@ -862,7 +867,7 @@
static gboolean
fstab_open (gpointer *handle)
{
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
return setfsent () == 1;
#else
*handle = fopen ("/etc/fstab", "r");
@@ -873,7 +878,7 @@
static char *
fstab_next (gpointer handle, char **mount_point)
{
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
struct fstab *fstab;
fstab = getfsent ();
@@ -901,7 +906,7 @@
static void
fstab_close (gpointer handle)
{
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
endfsent ();
#else
fclose (handle);
@@ -1116,7 +1121,7 @@
return ret;
}
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
#define MOUNT "/sbin/mount"
#define UMOUNT "/sbin/umount"
#else
@@ -1451,7 +1456,7 @@
if (volume == NULL && (mount_options->len == 0)) {
/* volume from a non-pollable drive, just set uid.. */
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
snprintf (uidbuf, sizeof (uidbuf) - 1, "uid=%u", getuid ());
#else
snprintf (uidbuf, sizeof (uidbuf) - 1, "-u=%u", getuid ());
@@ -1482,7 +1487,7 @@
g_debug ("read default option '%s' from gconf strlist key %s", option, key);
/* special workaround to replace "uid=" with "uid=<actual uid of caller>" */
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__)
if (strcmp (option, "uid=") == 0) {
g_free (option);
option = g_strdup_printf ("uid=%u", getuid ());
|