Accepting request 59055 from home:hpjansson:branches:GNOME:Factory

thanks

OBS-URL: https://build.opensuse.org/request/show/59055
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/glib2?expand=0&rev=130
This commit is contained in:
Vincent Untz 2011-01-26 17:43:19 +00:00 committed by Git OBS Bridge
parent fc214d405f
commit f9311c5117
3 changed files with 292 additions and 0 deletions

View File

@ -0,0 +1,284 @@
diff --git a/gio/glocaldirectorymonitor.c b/gio/glocaldirectorymonitor.c
index 6aea9a0..49b2084 100644
--- a/gio/glocaldirectorymonitor.c
+++ b/gio/glocaldirectorymonitor.c
@@ -266,26 +266,78 @@ get_default_local_directory_monitor (gpointer data)
return (gpointer)G_TYPE_INVALID;
}
+static gpointer
+get_default_remote_directory_monitor (gpointer data)
+{
+ GLocalDirectoryMonitorClass *chosen_class = NULL;
+ GLocalDirectoryMonitorClass **ret = data;
+ GIOExtensionPoint *ep;
+ GIOExtension *extension;
+ GLocalDirectoryMonitorClass *klass;
+
+ _g_io_modules_ensure_loaded ();
+
+ ep = g_io_extension_point_lookup (G_LOCAL_DIRECTORY_MONITOR_EXTENSION_POINT_NAME);
+
+ extension = g_io_extension_point_get_extension_by_name (ep, "fam");
+ if (!extension)
+ return (gpointer)G_TYPE_INVALID;
+
+ klass = G_LOCAL_DIRECTORY_MONITOR_CLASS (g_io_extension_ref_class (extension));
+
+ if (klass->is_supported ())
+ chosen_class = klass;
+ else
+ g_type_class_unref (klass);
+
+ if (chosen_class)
+ {
+ *ret = chosen_class;
+ return (gpointer)G_TYPE_FROM_CLASS (chosen_class);
+ }
+ else
+ return (gpointer)G_TYPE_INVALID;
+}
+
GFileMonitor*
_g_local_directory_monitor_new (const char *dirname,
GFileMonitorFlags flags,
+ gboolean is_remote_fs,
GError **error)
{
- static GOnce once_init = G_ONCE_INIT;
GTypeClass *type_class;
GFileMonitor *monitor;
GType type;
type_class = NULL;
- g_once (&once_init, get_default_local_directory_monitor, &type_class);
- type = (GType)once_init.retval;
-
monitor = NULL;
+
+ if (is_remote_fs)
+ {
+ static GOnce once_init = G_ONCE_INIT;
+
+ g_once (&once_init, get_default_remote_directory_monitor, &type_class);
+ type = (GType)once_init.retval;
+ }
+ else
+ {
+ static GOnce once_init = G_ONCE_INIT;
+
+ g_once (&once_init, get_default_local_directory_monitor, &type_class);
+ type = (GType)once_init.retval;
+ }
+
if (type != G_TYPE_INVALID)
monitor = G_FILE_MONITOR (g_object_new (type, "dirname", dirname, "flags", flags, NULL));
- else
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Unable to find default local directory monitor type"));
+
+ if (!monitor)
+ {
+ if (is_remote_fs)
+ monitor = _g_local_directory_monitor_new (dirname, flags, FALSE, error);
+ else
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Unable to find default local directory monitor type"));
+ }
/* This is non-null on first pass here. Unref the class now.
* This is to avoid unloading the module and then loading it
diff --git a/gio/glocaldirectorymonitor.h b/gio/glocaldirectorymonitor.h
index 418634e..b0a0d5a 100644
--- a/gio/glocaldirectorymonitor.h
+++ b/gio/glocaldirectorymonitor.h
@@ -64,6 +64,7 @@ GType g_local_directory_monitor_get_type (void) G_GNUC_CONST;
GFileMonitor * _g_local_directory_monitor_new (const char *dirname,
GFileMonitorFlags flags,
+ gboolean is_remote_fs,
GError **error);
G_END_DECLS
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index ec290e7..d8661ba 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -2344,6 +2344,57 @@ g_local_file_move (GFile *source,
return TRUE;
}
+static gboolean
+is_remote_fs (GLocalFile *local)
+{
+ const char *fsname;
+
+ fsname = NULL;
+
+#ifdef USE_STATFS
+ struct statfs statfs_buffer;
+ int statfs_result = 0;
+
+#if STATFS_ARGS == 2
+ statfs_result = statfs (local->filename, &statfs_buffer);
+#elif STATFS_ARGS == 4
+ statfs_result = statfs (local->filename, &statfs_buffer,
+ sizeof (statfs_buffer), 0);
+#endif
+
+#elif defined(USE_STATVFS)
+ struct statvfs statfs_buffer;
+
+ statfs_result = statvfs (local->filename, &statfs_buffer);
+#else
+ return FALSE;
+#endif
+
+ if (statfs_result == -1)
+ return FALSE;
+
+#ifdef USE_STATFS
+#if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME)
+ fsname = statfs_buffer.f_fstypename;
+#else
+ fsname = get_fs_type (statfs_buffer.f_type);
+#endif
+
+#elif defined(USE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
+ fsname = statfs_buffer.f_basetype;
+#endif
+
+ if (fsname != NULL)
+ {
+ if (strcmp (fsname, "nfs") == 0)
+ return TRUE;
+ if (strcmp (fsname, "nfs4") == 0)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static GFileMonitor*
g_local_file_monitor_dir (GFile *file,
GFileMonitorFlags flags,
@@ -2351,7 +2402,7 @@ g_local_file_monitor_dir (GFile *file,
GError **error)
{
GLocalFile* local_file = G_LOCAL_FILE(file);
- return _g_local_directory_monitor_new (local_file->filename, flags, error);
+ return _g_local_directory_monitor_new (local_file->filename, flags, is_remote_fs (local_file), error);
}
static GFileMonitor*
@@ -2361,7 +2412,7 @@ g_local_file_monitor_file (GFile *file,
GError **error)
{
GLocalFile* local_file = G_LOCAL_FILE(file);
- return _g_local_file_monitor_new (local_file->filename, flags, error);
+ return _g_local_file_monitor_new (local_file->filename, flags, is_remote_fs (local_file), error);
}
static void
diff --git a/gio/glocalfilemonitor.c b/gio/glocalfilemonitor.c
index 8405d3a..5fc2163 100644
--- a/gio/glocalfilemonitor.c
+++ b/gio/glocalfilemonitor.c
@@ -191,26 +191,78 @@ get_default_local_file_monitor (gpointer data)
return (gpointer)G_TYPE_INVALID;
}
+static gpointer
+get_default_remote_file_monitor (gpointer data)
+{
+ GLocalFileMonitorClass *chosen_class = NULL;
+ GLocalFileMonitorClass **ret = data;
+ GIOExtensionPoint *ep;
+ GIOExtension *extension;
+ GLocalFileMonitorClass *klass;
+
+ _g_io_modules_ensure_loaded ();
+
+ ep = g_io_extension_point_lookup (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME);
+
+ extension = g_io_extension_point_get_extension_by_name (ep, "fam");
+ if (!extension)
+ return (gpointer)G_TYPE_INVALID;
+
+ klass = G_LOCAL_FILE_MONITOR_CLASS (g_io_extension_ref_class (extension));
+
+ if (klass->is_supported ())
+ chosen_class = klass;
+ else
+ g_type_class_unref (klass);
+
+ if (chosen_class)
+ {
+ *ret = chosen_class;
+ return (gpointer)G_TYPE_FROM_CLASS (chosen_class);
+ }
+ else
+ return (gpointer)G_TYPE_INVALID;
+}
+
GFileMonitor*
_g_local_file_monitor_new (const char *pathname,
GFileMonitorFlags flags,
+ gboolean is_remote_fs,
GError **error)
{
- static GOnce once_init = G_ONCE_INIT;
GTypeClass *type_class;
GFileMonitor *monitor;
GType type;
type_class = NULL;
- g_once (&once_init, get_default_local_file_monitor, &type_class);
- type = (GType)once_init.retval;
-
monitor = NULL;
+
+ if (is_remote_fs)
+ {
+ static GOnce once_init = G_ONCE_INIT;
+
+ g_once (&once_init, get_default_remote_file_monitor, &type_class);
+ type = (GType)once_init.retval;
+ }
+ else
+ {
+ static GOnce once_init = G_ONCE_INIT;
+
+ g_once (&once_init, get_default_local_file_monitor, &type_class);
+ type = (GType)once_init.retval;
+ }
+
if (type != G_TYPE_INVALID)
monitor = G_FILE_MONITOR (g_object_new (type, "filename", pathname, "flags", flags, NULL));
- else
- g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- _("Unable to find default local file monitor type"));
+
+ if (!monitor)
+ {
+ if (is_remote_fs)
+ monitor = _g_local_file_monitor_new (pathname, flags, FALSE, error);
+ else
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Unable to find default local file monitor type"));
+ }
/* This is non-null on first pass here. Unref the class now.
* This is to avoid unloading the module and then loading it
diff --git a/gio/glocalfilemonitor.h b/gio/glocalfilemonitor.h
index 6643866..dff3d81 100644
--- a/gio/glocalfilemonitor.h
+++ b/gio/glocalfilemonitor.h
@@ -57,6 +57,7 @@ GType g_local_file_monitor_get_type (void) G_GNUC_CONST;
GFileMonitor * _g_local_file_monitor_new (const char *pathname,
GFileMonitorFlags flags,
+ gboolean is_remote_fs,
GError **error);
G_END_DECLS

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Jan 24 17:06:56 CET 2011 - hpj@novell.com
- Add glib2-force-fam-for-remote-fs.patch (bgo#592211).
-------------------------------------------------------------------
Fri Jan 14 10:36:01 CET 2011 - vuntz@opensuse.org

View File

@ -46,6 +46,8 @@ Patch8: glib2-bnc379332-desktop-su.patch
Patch10: glib2-bgo569829-gettext-gkeyfile.patch
# PATCH-FEATURE-OPENSUSE glib2-fate300461-gettext-gkeyfile-suse.patch fate300461 vuntz@novell.com -- Look for translation of desktop entry strings via gettext, part that deals with the openSUSE specific infrastructure (with desktop_translations)
Patch11: glib2-fate300461-gettext-gkeyfile-suse.patch
# PATCH-FIX-OPENSUSE glib2-force-fam-for-remote-fs.patch bgo592211 hpj@novell.com -- Try monitoring files on NFS mounts via FAM before falling back to inotify.
Patch12: glib2-force-fam-for-remote-fs.patch
BuildRequires: fam-devel
BuildRequires: fdupes
BuildRequires: gcc-c++
@ -248,6 +250,7 @@ translation-update-upstream
%patch8
%patch10 -p1
%patch11 -p1
%patch12 -p1
cp -a %{S:1} %{S:2} %{S:3} .
cp -a %{S:4} gnome_defaults.conf
if ! test -f %{_datadir}/aclocal/gtk-doc.m4 ; then