summaryrefslogtreecommitdiff
path: root/x11-fm/nautilus/files/patch-ac
blob: 632cbbc8420aa136b690757eff36343e7f7e20ac (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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
$FreeBSD$

--- libnautilus-extensions/nautilus-volume-monitor.c.orig	Tue Jan 16 03:31:56 2001
+++ libnautilus-extensions/nautilus-volume-monitor.c	Wed Jan 31 21:29:21 2001
@@ -60,7 +60,13 @@
 #include <fstab.h>
 #endif
 
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#else
 #include <mntent.h>
+#endif
 
 #ifdef MOUNT_AUDIO_CD
 
@@ -264,16 +270,25 @@
 GList *
 nautilus_volume_monitor_get_removable_volumes (NautilusVolumeMonitor *monitor)
 {
+#ifndef __FreeBSD__
 	FILE *file;
-	GList *volumes;
 	struct mntent *ent;
+#else
+	struct fstab *ent;
+#endif
+	GList *volumes;
 	NautilusVolume *volume;
 	
 	volumes = NULL;
 	
+#ifndef __FreeBSD__
 	file = setmntent (_PATH_MNTTAB, "r");
 	g_return_val_if_fail (file != NULL, NULL);
+#else
+	setfsent();
+#endif
 	
+#ifndef __FreeBSD__
 	while ((ent = getmntent (file)) != NULL) {
 		/* Use noauto as our way of determining a removable volume */
 		if (strstr (ent->mnt_opts, MNTOPT_NOAUTO) != NULL) {
@@ -281,6 +296,15 @@
 			volume->device_path = g_strdup (ent->mnt_fsname);
 			volume->mount_path = g_strdup (ent->mnt_dir);
 			volume->filesystem = g_strdup (ent->mnt_type);
+#else /* FreeBSD, probably ;) */
+	while ((ent = getfsent ()) != NULL) {
+		/* Use noauto as our way of determining a removable volume */
+		if (strstr (ent->fs_mntops, "noauto") != NULL) {
+			volume = g_new0 (NautilusVolume, 1);
+			volume->device_path = g_strdup (ent->fs_spec);
+			volume->mount_path = g_strdup (ent->fs_file);
+			volume->filesystem = g_strdup (ent->fs_vfstype);
+#endif
 			if (mount_volume_add_filesystem (volume)) {
 				mount_volume_get_name (volume);
 				volumes = g_list_append (volumes, volume);
@@ -290,7 +314,11 @@
 		}	
 	}
 			
+#ifndef __FreeBSD__
 	fclose (file);
+#else
+	endfsent();
+#endif
 	
 #ifdef MOUNT_AUDIO_CD
 	volume = g_new0 (NautilusVolume, 1);
@@ -682,15 +710,27 @@
 {
 	GList *current_mounts = NULL;
 	NautilusVolume *volume = NULL;
+#ifndef __FreeBSD__
 	FILE *fh;
 	char line[PATH_MAX * 3];
 	char device_name[sizeof (line)];
 	NautilusStringList *list;
+#else
+	struct statfs *mounted;
+	int mounted_num;
+	int i;
+#endif
 
+#ifndef __FreeBSD__
 	/* Open /proc/mounts */
 	fh = fopen (PATH_PROC_MOUNTS, "r");
 	g_return_val_if_fail (fh != NULL, NULL);
+#else
+	mounted_num = getmntinfo(&mounted, MNT_WAIT);
+	g_return_val_if_fail (mounted_num > 0, NULL);
+#endif
 
+#ifndef __FreeBSD__
 	while (fgets (line, sizeof(line), fh)) {
 		if (sscanf (line, "%s", device_name) == 1) {
 				list = nautilus_string_list_new_from_tokens (line, " ", FALSE);
@@ -702,17 +742,25 @@
 					volume->device_path = nautilus_string_list_nth (list, 0);
 					volume->mount_path = nautilus_string_list_nth (list, 1);
 					volume->filesystem = nautilus_string_list_nth (list, 2);
-
+#else
+	for (i = 0; i < mounted_num; i++) {
+		volume = g_new0 (NautilusVolume, 1);
+		volume->device_path = g_strdup(mounted[i].f_mntfromname);
+		volume->mount_path = g_strdup(mounted[i].f_mntonname);
+		volume->filesystem = g_strdup(mounted[i].f_fstypename);
+#endif /* __FreeBSD__ */
 					if (mount_volume_add_filesystem (volume)) {
 						mount_volume_get_name (volume);
 						current_mounts = g_list_append (current_mounts, volume);
 					} else {
 						nautilus_volume_monitor_free_volume (volume);
 					}					
+#ifndef __FreeBSD__
 				}				
 				nautilus_string_list_free (list);
 			}			
 		}
+#endif
   	}
 
 #ifdef MOUNT_AUDIO_CD
@@ -728,7 +776,9 @@
 	}
 #endif
 
+#ifndef __FreeBSD__
 	fclose (fh);
+#endif
 	
 	return current_mounts;
 
@@ -889,6 +939,45 @@
 	return TRUE;
 }
 
+#ifdef 0
+#ifdef __FreeBSD__
+static void
+fstab_add_mount_volume (NautilusVolumeMonitor *monitor, struct fstab *ent)
+{
+	NautilusVolume *volume;
+	gboolean mounted;
+
+	volume = g_new0 (NautilusVolume, 1);
+	volume->device_path = g_strdup(ent->fs_spec);
+	volume->mount_path = g_strdup(ent->fs_file);
+
+	mounted = FALSE;
+
+	if (nautilus_str_has_prefix (ent->fs_spec, "/dev/fd")) {
+		mounted = mount_volume_floppy_add (monitor, volume);
+	} else if (strcmp (ent->fs_vfstype, "ufs") == 0) {
+		mounted = mount_volume_ext2_add (volume);
+	} else if (strcmp (ent->fs_vfstype, "nfs") == 0) {
+		mounted = mount_volume_nfs_add (volume);
+	} else if (strcmp (ent->fs_vfstype, "cd9660") == 0) {
+		mounted = mount_volume_iso9660_add (volume);
+	} else if (strcmp (ent->fs_vfstype, "msdos") == 0) {
+		mounted = mount_volume_msdos_add (volume);
+	}
+
+	if (mounted) {
+		volume->is_read_only = strstr (ent->fs_type, FSTAB_RO) != NULL;
+		monitor->details->volumes = g_list_append (monitor->details->volumes, volume);
+		mount_volume_add_aliases (monitor, volume->device_path, volume);
+	} else {
+		g_free (volume->device_path);
+		g_free (volume->mount_path);
+		g_free (volume);
+	}
+}
+#endif
+#endif
+
 static void
 cdrom_ioctl_get_info (int fd)
 {
@@ -1025,6 +1114,14 @@
 			break;
 		}
 	}
+#ifdef __FreeBSD__
+	struct fstab *ent;
+
+	setfsent ();
+	while ((ent = getfsent ())) 
+		fstab_add_mount_volume (monitor, ent);
+	endfsent ();
+#endif	/* __FreeBSD__ */
 }
 #endif