From: David Zeuthen Date: Tue, 18 Oct 2011 17:51:47 +0000 (-0400) Subject: udisks: Also accept a --no-debug option and use it for activation X-Git-Tag: upstream/2.1.2~452 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f3a2eed1a0e486903b8f89af0ca6decdeace6d7;p=platform%2Fupstream%2Fudisks2.git udisks: Also accept a --no-debug option and use it for activation Otherwise syslog gets spammed via D-Bus' system bus activation helper via systemd (got it? got it!). Signed-off-by: David Zeuthen --- diff --git a/data/org.freedesktop.UDisks2.service.in b/data/org.freedesktop.UDisks2.service.in index 924059a..f127a69 100644 --- a/data/org.freedesktop.UDisks2.service.in +++ b/data/org.freedesktop.UDisks2.service.in @@ -1,5 +1,5 @@ [D-BUS Service] Name=org.freedesktop.UDisks2 -Exec=@privlibdir@/udisksd +Exec=@privlibdir@/udisksd --no-debug User=root diff --git a/doc/man/udisksd.xml b/doc/man/udisksd.xml index 40b0938..38a47fb 100644 --- a/doc/man/udisksd.xml +++ b/doc/man/udisksd.xml @@ -21,6 +21,8 @@ udisksd + + @@ -62,6 +64,22 @@ + + + + + Do not print debug or informational messages on stdout/stderr. + + + + + + + + Do not handle SIGINT for controlled shutdown. + + + diff --git a/src/main.c b/src/main.c index 5cba85e..a330a58 100644 --- a/src/main.c +++ b/src/main.c @@ -32,11 +32,13 @@ static GMainLoop *loop = NULL; static gboolean opt_replace = FALSE; +static gboolean opt_no_debug = FALSE; static gboolean opt_no_sigint = FALSE; static GOptionEntry opt_entries[] = { - {"replace", 0, 0, G_OPTION_ARG_NONE, &opt_replace, "Replace existing daemon", NULL}, - {"no-sigint", 0, 0, G_OPTION_ARG_NONE, &opt_no_sigint, "Do not handle SIGINT for controlled shutdown", NULL}, + {"replace", 'r', 0, G_OPTION_ARG_NONE, &opt_replace, "Replace existing daemon", NULL}, + {"no-debug", 'n', 0, G_OPTION_ARG_NONE, &opt_no_debug, "Don't print debug information on stdout/stderr", NULL}, + {"no-sigint", 's', 0, G_OPTION_ARG_NONE, &opt_no_sigint, "Do not handle SIGINT for controlled shutdown", NULL}, {NULL } }; @@ -118,6 +120,26 @@ main (int argc, goto out; } + /* TODO: this hammer is too big - it would be a lot better to configure the + * logging routines and avoid printf(3) overhead and so on + */ + if (opt_no_debug) + { + gint dev_null_fd; + dev_null_fd = open ("/dev/null", O_RDWR); + if (dev_null_fd >= 0) + { + dup2 (dev_null_fd, STDIN_FILENO); + dup2 (dev_null_fd, STDOUT_FILENO); + dup2 (dev_null_fd, STDERR_FILENO); + close (dev_null_fd); + } + else + { + g_warning ("Error opening /dev/null: %m"); + } + } + udisks_notice ("udisks daemon version %s starting", PACKAGE_VERSION); loop = g_main_loop_new (NULL, FALSE);