gvfs r1156 - in trunk: . daemon



Author: alexl
Date: Mon Jan 21 12:04:06 2008
New Revision: 1156
URL: http://svn.gnome.org/viewvc/gvfs?rev=1156&view=rev

Log:
2008-01-21  Alexander Larsson  <alexl redhat com>

        * daemon/mount.c:
	Reload the list of mountables on SIGUSR1



Modified:
   trunk/ChangeLog
   trunk/daemon/mount.c

Modified: trunk/daemon/mount.c
==============================================================================
--- trunk/daemon/mount.c	(original)
+++ trunk/daemon/mount.c	Mon Jan 21 12:04:06 2008
@@ -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 @@
 }
 
 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 @@
 			  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 @@
     }
 }
 
+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 @@
 }
 
 
+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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]