summaryrefslogtreecommitdiff
path: root/daemon/mount.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2008-01-21 12:04:06 +0000
committerAlexander Larsson <alexl@src.gnome.org>2008-01-21 12:04:06 +0000
commit6bf042ace2a56ce759a969cee35056c841d8258d (patch)
treed947b704a4904fe75d86673581cbf3164c9f1440 /daemon/mount.c
parentf7a63407b5da35622088f98256a348335a8cf51a (diff)
downloadgvfs-6bf042ace2a56ce759a969cee35056c841d8258d.tar.gz
Reload the list of mountables on SIGUSR1
2008-01-21 Alexander Larsson <alexl@redhat.com> * daemon/mount.c: Reload the list of mountables on SIGUSR1 svn path=/trunk/; revision=1156
Diffstat (limited to 'daemon/mount.c')
-rw-r--r--daemon/mount.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/daemon/mount.c b/daemon/mount.c
index cfda6779..96ac6684 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -23,6 +23,8 @@
#include <config.h>
#include <string.h>
+#include <unistd.h>
+#include <signal.h>
#include <glib.h>
#include <dbus/dbus.h>
@@ -136,6 +138,15 @@ lookup_mountable (GMountSpec *spec)
}
static void
+vfs_mountable_free (VfsMountable *mountable)
+{
+ g_free (mountable->type);
+ g_free (mountable->exec);
+ g_free (mountable->dbus_name);
+ g_free (mountable);
+}
+
+static void
vfs_mount_free (VfsMount *mount)
{
g_free (mount->display_name);
@@ -486,6 +497,8 @@ read_mountable_config (void)
mountable->dbus_name = g_key_file_get_string (keyfile, "Mount", "DBusName", NULL);
mountable->automount = g_key_file_get_boolean (keyfile, "Mount", "AutoMount", NULL);
+
+ g_print ("Mountables type=%s\n", mountable->type);
mountables = g_list_prepend (mountables, mountable);
}
}
@@ -498,6 +511,15 @@ read_mountable_config (void)
}
}
+static void
+re_read_mountable_config (void)
+{
+ g_list_foreach (mountables, (GFunc)vfs_mountable_free, NULL);
+ g_list_free (mountables);
+ mountables = NULL;
+
+ read_mountable_config ();
+}
/************************************************************************
* Support for keeping track of active mounts *
@@ -992,14 +1014,51 @@ mount_tracker_filter_func (DBusConnection *conn,
}
+static int reload_pipes[2];
+
+static void
+sigusr1_handler (int sig)
+{
+ while (write (reload_pipes[1], "a", 1) != 1)
+ ;
+}
+
+static gboolean
+reload_pipes_cb (GIOChannel *io,
+ GIOCondition condition,
+ gpointer data)
+{
+ char a;
+
+ while (read (reload_pipes[0], &a, 1) != 1)
+ ;
+
+ re_read_mountable_config ();
+
+ return TRUE;
+}
+
void
mount_init (void)
{
DBusConnection *conn;
DBusError error;
+ struct sigaction sa;
+ GIOChannel *io;
read_mountable_config ();
+ if (pipe (reload_pipes) != -1)
+ {
+ io = g_io_channel_unix_new (reload_pipes[0]);
+ g_io_add_watch (io, G_IO_IN, reload_pipes_cb, NULL);
+
+ sa.sa_handler = sigusr1_handler;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ sigaction (SIGUSR1, &sa, NULL);
+ }
+
conn = dbus_bus_get (DBUS_BUS_SESSION, NULL);
if (!dbus_connection_register_object_path (conn, G_VFS_DBUS_MOUNTTRACKER_PATH,