[gvfs/wip/oholy/debug: 2/10] daemon: Allow controlling debug output from main daemon



commit acbee7ea7f3a24c9e521d19087068b9cc255241a
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Wed Nov 5 23:17:52 2014 +0000

    daemon: Allow controlling debug output from main daemon
    
    Allow controlling whether backends spawned from the main daemon start
    with debug output enabled by adding a --debug command-line parameter and
    responding to the SIGUSR2 signal.  Note that sending SIGUSR2 to the main
    daemon does not affect any already spawned backends.
    
    E.g. to capture the login debugging from the sftp backend without having
    to restart the main daemon:
    $ pkill -x -USR2 gvfsd
    $ gvfs-mount sftp://...
    $ journalctl -n 40
    
    If --debug is given on the command-line, debug output is enabled for
    spawned daemons by default.  Sending SIGUSR2 will then turn it off.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=740660

 daemon/main.c  |    8 ++++++++
 daemon/mount.c |    9 ++++++++-
 man/gvfsd.xml  |    6 ++++++
 3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/daemon/main.c b/daemon/main.c
index bcadc9e..106119e 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -28,6 +28,7 @@
 #include "gvfsdaemon.h"
 #include "gvfsbackendtest.h"
 #include <gvfsdaemonprotocol.h>
+#include <gvfsutils.h>
 #include "mount.h"
 #include <locale.h>
 
@@ -139,6 +140,7 @@ main (int argc, char *argv[])
   GVfsDaemon *daemon;
   gboolean replace;
   gboolean no_fuse;
+  gboolean debugging;
   gboolean show_version;
   GError *error;
   guint name_owner_id;
@@ -147,6 +149,7 @@ main (int argc, char *argv[])
   const GOptionEntry options[] = {
     { "replace", 'r', 0, G_OPTION_ARG_NONE, &replace,  N_("Replace old daemon."), NULL },
     { "no-fuse", 0, 0, G_OPTION_ARG_NONE, &no_fuse,  N_("Don't start fuse."), NULL },
+    { "debug", 'd', 0, G_OPTION_ARG_NONE, &debugging,  N_("Enable debug output."), NULL },
     { "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Show program version."), NULL},
     { NULL }
   };
@@ -157,6 +160,8 @@ main (int argc, char *argv[])
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
 
+  gvfs_setup_debug_handler ();
+
 #ifdef SIGPIPE
   signal (SIGPIPE, SIG_IGN);
 #endif
@@ -170,6 +175,7 @@ main (int argc, char *argv[])
 
   replace = FALSE;
   no_fuse = FALSE;
+  debugging = FALSE;
   show_version = FALSE;
 
   if (g_getenv ("GVFS_DISABLE_FUSE") != NULL)
@@ -192,6 +198,8 @@ main (int argc, char *argv[])
 
   g_option_context_free (context);
 
+  gvfs_set_debug (debugging);
+
   if (show_version)
     {
       g_print (PACKAGE_STRING "\n");
diff --git a/daemon/mount.c b/daemon/mount.c
index 9d8fb00..e10e145 100644
--- a/daemon/mount.c
+++ b/daemon/mount.c
@@ -33,6 +33,7 @@
 #include "gmountoperationdbus.h"
 #include "gvfsdaemonprotocol.h"
 #include <gvfsdbus.h>
+#include <gvfsutils.h>
 
 typedef struct {
   char *display_name;
@@ -439,7 +440,13 @@ spawn_mount (MountData *data)
           return;
         }
 
-      exec = g_strconcat (data->mountable->exec, " --spawner ", g_dbus_connection_get_unique_name 
(connection), " ", data->obj_path, NULL);
+      exec = g_strconcat (data->mountable->exec,
+                          gvfs_get_debug () ? " --debug" : "",
+                          " --spawner ",
+                          g_dbus_connection_get_unique_name (connection),
+                          " ",
+                          data->obj_path,
+                          NULL);
       if (!g_spawn_command_line_async (exec, &error))
        {
           g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (data->spawner));
diff --git a/man/gvfsd.xml b/man/gvfsd.xml
index f257eeb..6b678a5 100644
--- a/man/gvfsd.xml
+++ b/man/gvfsd.xml
@@ -92,6 +92,12 @@
                                 <listitem><para>Don't start the fuse filesystem.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><option>-d</option>, <option>--debug</option></term>
+
+                                <listitem><para>Enable debug output.</para></listitem>
+                        </varlistentry>
+
                 </variablelist>
         </refsect1>
 


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