From 6414d5ae5db291dfed4bd5f0107076bfd0969ca3 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sat, 10 Oct 2009 18:53:19 +0200 Subject: [PATCH 2/2] Bug 24446 – Provide option to track ram/loop devices This is mainly useful for testing, but might be wanted in special setups as well. --- src/devkit-disks-daemon.c | 12 +++++++++++- src/devkit-disks-daemon.h | 4 +++- src/devkit-disks-device.c | 5 +++-- src/main.c | 4 +++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/devkit-disks-daemon.c b/src/devkit-disks-daemon.c index fd9de2c..cf3bb8c 100644 --- a/src/devkit-disks-daemon.c +++ b/src/devkit-disks-daemon.c @@ -121,6 +121,8 @@ struct DevkitDisksDaemonPrivate GList *inhibitors; GList *spindown_inhibitors; + + gboolean virtual_fs; }; static void devkit_disks_daemon_class_init (DevkitDisksDaemonClass *klass); @@ -1033,7 +1035,7 @@ error: DevkitDisksDaemon * -devkit_disks_daemon_new (void) +devkit_disks_daemon_new (gboolean virtual_fs) { DevkitDisksDaemon *daemon; GList *devices; @@ -1043,6 +1045,8 @@ devkit_disks_daemon_new (void) daemon = DEVKIT_DISKS_DAEMON (g_object_new (DEVKIT_DISKS_TYPE_DAEMON, NULL)); + daemon->priv->virtual_fs = virtual_fs; + if (!register_disks_daemon (DEVKIT_DISKS_DAEMON (daemon))) { g_object_unref (daemon); goto error; @@ -2024,4 +2028,10 @@ devkit_disks_daemon_drive_unset_all_spindown_timeouts (DevkitDisksDaemon *da return TRUE; } +gboolean +devkit_disks_daemon_local_virtual_fs (DevkitDisksDaemon *daemon) +{ + return daemon->priv->virtual_fs; +} + /*--------------------------------------------------------------------------------------------------------------*/ diff --git a/src/devkit-disks-daemon.h b/src/devkit-disks-daemon.h index 3164734..16727b7 100644 --- a/src/devkit-disks-daemon.h +++ b/src/devkit-disks-daemon.h @@ -70,7 +70,7 @@ GType devkit_disks_error_get_type (void); GQuark devkit_disks_error_quark (void); GType devkit_disks_daemon_get_type (void) G_GNUC_CONST; -DevkitDisksDaemon *devkit_disks_daemon_new (void); +DevkitDisksDaemon *devkit_disks_daemon_new (gboolean virtual_fs); /* local methods */ @@ -125,6 +125,8 @@ gboolean devkit_disks_daemon_local_has_polling_inhibitors (DevkitDisks gboolean devkit_disks_daemon_local_is_inhibited (DevkitDisksDaemon *daemon); +gboolean devkit_disks_daemon_local_virtual_fs (DevkitDisksDaemon *daemon); + DevkitDisksMountMonitor *devkit_disks_daemon_local_get_mount_monitor (DevkitDisksDaemon *daemon); typedef struct { diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c index 5af03ce..4bd7b61 100644 --- a/src/devkit-disks-device.c +++ b/src/devkit-disks-device.c @@ -3457,8 +3457,9 @@ devkit_disks_device_new (DevkitDisksDaemon *daemon, GUdevDevice *d) native_path = g_udev_device_get_sysfs_path (d); /* ignore ram and loop devices */ - if (g_str_has_prefix (native_path, "/sys/devices/virtual/block/ram") || - g_str_has_prefix (native_path, "/sys/devices/virtual/block/loop")) + if (!devkit_disks_daemon_local_virtual_fs (daemon) && + (g_str_has_prefix (native_path, "/sys/devices/virtual/block/ram") || + g_str_has_prefix (native_path, "/sys/devices/virtual/block/loop"))) goto out; device = DEVKIT_DISKS_DEVICE (g_object_new (DEVKIT_DISKS_TYPE_DEVICE, NULL)); diff --git a/src/main.c b/src/main.c index c229132..235ac4d 100644 --- a/src/main.c +++ b/src/main.c @@ -124,8 +124,10 @@ main (int argc, char **argv) DBusGConnection *bus; int ret; static gboolean replace; + static gboolean virtual; static GOptionEntry entries [] = { { "replace", 0, 0, G_OPTION_ARG_NONE, &replace, "Replace existing daemon", NULL }, + { "virtual", 0, 0, G_OPTION_ARG_NONE, &virtual, "Also track loop and ramdisk devices", NULL }, { NULL } }; @@ -179,7 +181,7 @@ main (int argc, char **argv) g_debug ("Starting devkit-disks-daemon version %s", VERSION); - disks_daemon = devkit_disks_daemon_new (); + disks_daemon = devkit_disks_daemon_new (virtual); if (disks_daemon == NULL) { goto out; -- 1.6.3.3