summaryrefslogtreecommitdiff
path: root/devel/glib2/patches/patch-ba
blob: 902a045ef8ceaa22e476618bd691e02d24ac69e9 (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
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
201
202
203
204
205
206
207
208
209
210
211
$NetBSD: patch-ba,v 1.11 2013/04/20 08:59:29 obache Exp $

* http://bugzilla.gnome.org/show_bug.cgi?id=583330
* http://bugzilla.gnome.org/show_bug.cgi?id=697365

--- gio/gunixmounts.c.orig	2013-04-15 21:22:13.000000000 +0000
+++ gio/gunixmounts.c
@@ -155,6 +155,9 @@ struct _GUnixMountMonitor {
   GFileMonitor *fstab_monitor;
   GFileMonitor *mtab_monitor;
 
+  guint mount_poller_source;
+  GList *mount_poller_mounts;
+
   GSource *proc_mounts_watch_source;
 };
 
@@ -167,6 +170,8 @@ static GUnixMountMonitor *the_mount_moni
 static GList *_g_get_unix_mounts (void);
 static GList *_g_get_unix_mount_points (void);
 
+static guint64 mount_poller_time = 0;
+
 G_DEFINE_TYPE (GUnixMountMonitor, g_unix_mount_monitor, G_TYPE_OBJECT);
 
 #define MOUNT_POLL_INTERVAL 4000
@@ -193,6 +198,7 @@ G_DEFINE_TYPE (GUnixMountMonitor, g_unix
 #endif
 
 #if (defined(HAVE_GETVFSSTAT) || defined(HAVE_GETFSSTAT)) && defined(HAVE_FSTAB_H) && defined(HAVE_SYS_MOUNT_H)
+#include <sys/param.h>
 #include <sys/ucred.h>
 #include <sys/mount.h>
 #include <fstab.h>
@@ -243,22 +249,30 @@ g_unix_is_mount_path_system_internal (co
     "/",              /* we already have "Filesystem root" in Nautilus */ 
     "/bin",
     "/boot",
+    "/compat/linux/proc",
+    "/compat/linux/sys",
     "/dev",
     "/etc",
     "/home",
     "/lib",
     "/lib64",
+    "/libexec",
     "/live/cow",
     "/live/image",
     "/media",
     "/mnt",
     "/opt",
+    "/rescue",
     "/root",
     "/sbin",
     "/srv",
     "/tmp",
     "/usr",
+    "/usr/X11R6",
     "/usr/local",
+    "/usr/obj",
+    "/usr/ports",
+    "/usr/src",
     "/var",
     "/var/crash",
     "/var/local",
@@ -602,7 +616,7 @@ get_mtab_monitor_file (void)
 static GList *
 _g_get_unix_mounts (void)
 {
-#if defined(HAVE_GETVFSSTAT)
+#if defined(HAVE_GETVFSSTAT) && !defined(__DragonFly__)
   struct statvfs *mntent = NULL;
 #elif defined(HAVE_GETFSSTAT)
   struct statfs *mntent = NULL;
@@ -615,7 +629,7 @@ _g_get_unix_mounts (void)
   GList *return_list;
   
   /* Pass NOWAIT to avoid blocking trying to update NFS mounts. */
-#if defined(HAVE_GETVFSSTAT)
+#if defined(HAVE_GETVFSSTAT) && !defined(__DragonFly__)
   num_mounts = getvfsstat (NULL, 0, ST_NOWAIT);
 #elif defined(HAVE_GETFSSTAT)
   num_mounts = getfsstat (NULL, 0, MNT_NOWAIT);
@@ -625,7 +639,7 @@ _g_get_unix_mounts (void)
 
   bufsize = num_mounts * sizeof (*mntent);
   mntent = g_malloc (bufsize);
-#if defined(HAVE_GETVFSSTAT)
+#if defined(HAVE_GETVFSSTAT) && !defined(__DragonFly__)
   num_mounts = getvfsstat (mntent, bufsize, ST_NOWAIT);
 #elif defined(HAVE_GETFSSTAT)
   num_mounts = getfsstat (mntent, bufsize, MNT_NOWAIT);
@@ -641,9 +655,15 @@ _g_get_unix_mounts (void)
       
       mount_entry->mount_path = g_strdup (mntent[i].f_mntonname);
       mount_entry->device_path = g_strdup (mntent[i].f_mntfromname);
+#if defined(__digital__)
+      mount_entry->filesystem_type = g_strdup ("unknown");
+#else
       mount_entry->filesystem_type = g_strdup (mntent[i].f_fstypename);
-#if defined(HAVE_GETVFSSTAT)
+#endif
+#if defined(HAVE_GETVFSSTAT) && !defined(__DragonFly__)
       if (mntent[i].f_flag & ST_RDONLY)
+#elif defined(__digital__)
+      if (mntent[i].f_flags & M_RDONLY)
 #elif defined(HAVE_GETFSSTAT)
       if (mntent[i].f_flags & MNT_RDONLY)
 #endif
@@ -774,9 +794,11 @@ _g_get_unix_mount_points (void)
           (strcmp (mntent->mnt_dir, "none") == 0))
 	continue;
 
+#if defined (HAVE_HASMNTOPT)
       /* We ignore bind fstab entries, as we ignore bind mounts anyway */
       if (hasmntopt (mntent, "bind"))
         continue;
+#endif
 
       mount_entry = g_new0 (GUnixMountPoint, 1);
       mount_entry->mount_path = g_strdup (mntent->mnt_dir);
@@ -1126,6 +1148,10 @@ get_mounts_timestamp (void)
       if (stat (monitor_file, &buf) == 0)
 	return (guint64)buf.st_mtime;
     }
+  else
+    {
+      return mount_poller_time;
+    }
   return 0;
 }
 
@@ -1271,6 +1297,13 @@ g_unix_mount_monitor_finalize (GObject *
       g_object_unref (monitor->mtab_monitor);
     }
 
+  if (monitor->mount_poller_source > 0)
+    {
+      g_source_remove (monitor->mount_poller_source);
+      g_list_foreach (monitor->mount_poller_mounts, (GFunc)g_unix_mount_free, NULL);
+      g_list_free (monitor->mount_poller_mounts);
+    }
+
   the_mount_monitor = NULL;
 
   G_OBJECT_CLASS (g_unix_mount_monitor_parent_class)->finalize (object);
@@ -1362,6 +1395,51 @@ proc_mounts_changed (GIOChannel   *chann
   return TRUE;
 }
 
+static gboolean
+mount_change_poller (gpointer user_data)
+{
+  GUnixMountMonitor *mount_monitor;
+  GList *current_mounts;
+  gboolean has_changed = FALSE;
+
+  mount_monitor = user_data;
+  current_mounts = _g_get_unix_mounts ();
+
+  if (g_list_length (current_mounts) != g_list_length (mount_monitor->mount_poller_mounts))
+    {
+      g_list_foreach (mount_monitor->mount_poller_mounts, (GFunc)g_unix_mount_free, NULL);
+      has_changed = TRUE;
+    }
+  else
+    {
+      int i;
+
+      for (i = 0; i < g_list_length (current_mounts); i++)
+        {
+          GUnixMountEntry *m1;
+         GUnixMountEntry *m2;
+
+         m1 = (GUnixMountEntry *)g_list_nth_data (current_mounts, i);
+         m2 = (GUnixMountEntry *)g_list_nth_data (mount_monitor->mount_poller_mounts, i);
+          if (! has_changed && g_unix_mount_compare (m1, m2) != 0)
+            has_changed = TRUE;
+
+         g_unix_mount_free (m2);
+       }
+    }
+
+  g_list_free (mount_monitor->mount_poller_mounts);
+  mount_monitor->mount_poller_mounts = current_mounts;
+
+  if (has_changed)
+    {
+      mount_poller_time = (guint64)time (NULL);
+      g_signal_emit (mount_monitor, signals[MOUNTS_CHANGED], 0);
+    }
+
+  return TRUE;
+}
+
 static void
 g_unix_mount_monitor_init (GUnixMountMonitor *monitor)
 {
@@ -1416,6 +1494,12 @@ g_unix_mount_monitor_init (GUnixMountMon
           g_signal_connect (monitor->mtab_monitor, "changed", (GCallback)mtab_file_changed, monitor);
         }
     }
+  else
+    {
+      monitor->mount_poller_mounts = _g_get_unix_mounts ();
+      mount_poller_time = (guint64)time (NULL);
+      monitor->mount_poller_source = g_timeout_add_seconds (3, (GSourceFunc)mount_change_poller, monitor);
+    }
 }
 
 /**