Blob Blame History Raw
From 449994908141e6af9f8f6a5909923ff0d2cf1506 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Wed, 04 Mar 2009 19:23:04 +0000
Subject: add a --dump option to devkit-disks(1)

---
diff --git a/doc/man/devkit-disks.xml b/doc/man/devkit-disks.xml
index 422ae94..de46bae 100644
--- a/doc/man/devkit-disks.xml
+++ b/doc/man/devkit-disks.xml
@@ -37,6 +37,15 @@
     <title>OPTIONS</title>
     <variablelist>
       <varlistentry>
+        <term><option>--dump</option></term>
+        <listitem>
+          <para>
+            Dump all information about all devices. Please include this when filing bugs.
+          </para>
+        </listitem>
+      </varlistentry>
+
+      <varlistentry>
         <term><option>--enumerate</option></term>
         <listitem>
           <para>
diff --git a/tools/devkit-disks-bash-completion.sh b/tools/devkit-disks-bash-completion.sh
index c163e54..656b91d 100644
--- a/tools/devkit-disks-bash-completion.sh
+++ b/tools/devkit-disks-bash-completion.sh
@@ -17,7 +17,7 @@ __devkit_disks() {
     elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--unmount" ] ; then
         COMPREPLY=($(compgen -W "$(devkit-disks --enumerate)" -- $cur))
     else
-        COMPREPLY=($(IFS=: compgen -S' ' -W "--inhibit-polling:--inhibit-all-polling:--enumerate:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options" -- $cur))
+        COMPREPLY=($(IFS=: compgen -S' ' -W "--dump:--inhibit-polling:--inhibit-all-polling:--enumerate:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options" -- $cur))
     fi
 }
 
diff --git a/tools/devkit-disks.c b/tools/devkit-disks.c
index 5ad1d78..eb4bc9c 100644
--- a/tools/devkit-disks.c
+++ b/tools/devkit-disks.c
@@ -53,6 +53,7 @@ static DBusGConnection     *bus = NULL;
 static DBusGProxy          *disks_proxy = NULL;
 static GMainLoop           *loop;
 
+static gboolean      opt_dump              = FALSE;
 static gboolean      opt_enumerate         = FALSE;
 static gboolean      opt_monitor           = FALSE;
 static gboolean      opt_monitor_detail    = FALSE;
@@ -1239,6 +1240,12 @@ out:
 
 /* ---------------------------------------------------------------------------------------------------- */
 
+static gint
+ptr_str_array_compare (const gchar **a, const gchar **b)
+{
+        return g_strcmp0 (*a, *b);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -1248,6 +1255,7 @@ main (int argc, char **argv)
         unsigned int         n;
         static GOptionEntry  entries []     = {
                 { "enumerate", 0, 0, G_OPTION_ARG_NONE, &opt_enumerate, "Enumerate objects paths for devices", NULL },
+                { "dump", 0, 0, G_OPTION_ARG_NONE, &opt_dump, "Dump all information about all devices", NULL },
                 { "monitor", 0, 0, G_OPTION_ARG_NONE, &opt_monitor, "Monitor activity from the disk daemon", NULL },
                 { "monitor-detail", 0, 0, G_OPTION_ARG_NONE, &opt_monitor_detail, "Monitor with detail", NULL },
                 { "show-info", 0, 0, G_OPTION_ARG_STRING, &opt_show_info, "Show information about object path", NULL },
@@ -1319,7 +1327,24 @@ main (int argc, char **argv)
                                  G_TYPE_DOUBLE,
                                  G_TYPE_INVALID);
 
-        if (opt_enumerate) {
+        if (opt_dump) {
+                GPtrArray *devices;
+                if (!org_freedesktop_DeviceKit_Disks_enumerate_devices (disks_proxy, &devices, &error)) {
+                        g_warning ("Couldn't enumerate devices: %s", error->message);
+                        g_error_free (error);
+                        goto out;
+                }
+                g_ptr_array_sort (devices, (GCompareFunc) ptr_str_array_compare);
+                g_print ("========================================================================\n");
+                for (n = 0; n < devices->len; n++) {
+                        char *object_path = devices->pdata[n];
+                        do_show_info (object_path);
+                        g_print ("\n"
+                                 "========================================================================\n");
+                }
+                g_ptr_array_foreach (devices, (GFunc) g_free, NULL);
+                g_ptr_array_free (devices, TRUE);
+        } else if (opt_enumerate) {
                 GPtrArray *devices;
                 if (!org_freedesktop_DeviceKit_Disks_enumerate_devices (disks_proxy, &devices, &error)) {
                         g_warning ("Couldn't enumerate devices: %s", error->message);
--
cgit v0.8.2