From bdeed403805ca32cb7d53db5b80ced223b64d04b Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Thu, 2 Apr 2009 14:37:57 -0400 Subject: [PATCH] export device-major and device-minor properties This makes it easier for clients wanting to fool around with /proc/self/mountinfo themselves. --- src/devkit-disks-device-private.h | 3 +-- src/devkit-disks-device.c | 16 ++++++++++++++++ src/org.freedesktop.DeviceKit.Disks.Device.xml | 10 ++++++++++ tools/devkit-disks.c | 9 +++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/devkit-disks-device-private.h b/src/devkit-disks-device-private.h index 09b9cb1..a8d2d7c 100644 --- a/src/devkit-disks-device-private.h +++ b/src/devkit-disks-device-private.h @@ -93,13 +93,12 @@ struct DevkitDisksDevicePrivate /* if non-zero, the id of the idle for emitting a 'change' signal */ guint emit_changed_idle_id; - dev_t dev; /* not exported */ - /**************/ /* properties */ /*************/ char *device_file; + dev_t dev; GPtrArray *device_file_by_id; GPtrArray *device_file_by_path; gboolean device_is_system_internal; diff --git a/src/devkit-disks-device.c b/src/devkit-disks-device.c index 4d2f90b..d909fb5 100644 --- a/src/devkit-disks-device.c +++ b/src/devkit-disks-device.c @@ -131,6 +131,8 @@ enum PROP_0, PROP_NATIVE_PATH, + PROP_DEVICE_MAJOR, + PROP_DEVICE_MINOR, PROP_DEVICE_FILE, PROP_DEVICE_FILE_BY_ID, PROP_DEVICE_FILE_BY_PATH, @@ -297,6 +299,12 @@ get_property (GObject *object, g_value_set_string (value, device->priv->native_path); break; + case PROP_DEVICE_MAJOR: + g_value_set_int64 (value, major (device->priv->dev)); + break; + case PROP_DEVICE_MINOR: + g_value_set_int64 (value, minor (device->priv->dev)); + break; case PROP_DEVICE_FILE: g_value_set_string (value, device->priv->device_file); break; @@ -704,6 +712,14 @@ devkit_disks_device_class_init (DevkitDisksDeviceClass *klass) g_param_spec_string ("native-path", NULL, NULL, NULL, G_PARAM_READABLE)); g_object_class_install_property ( object_class, + PROP_DEVICE_MAJOR, + g_param_spec_int64 ("device-major", NULL, NULL, -G_MAXINT64, G_MAXINT64, 0, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, + PROP_DEVICE_MINOR, + g_param_spec_int64 ("device-minor", NULL, NULL, -G_MAXINT64, G_MAXINT64, 0, G_PARAM_READABLE)); + g_object_class_install_property ( + object_class, PROP_DEVICE_FILE, g_param_spec_string ("device-file", NULL, NULL, NULL, G_PARAM_READABLE)); g_object_class_install_property ( diff --git a/src/org.freedesktop.DeviceKit.Disks.Device.xml b/src/org.freedesktop.DeviceKit.Disks.Device.xml index de0163d..6465486 100644 --- a/src/org.freedesktop.DeviceKit.Disks.Device.xml +++ b/src/org.freedesktop.DeviceKit.Disks.Device.xml @@ -1285,6 +1285,16 @@ OS specific native path of the device. On Linux this is the sysfs path, for example /sys/devices/pci0000:00/0000:00:1f.2/host2/target2:0:1/2:0:1:0/block/sda. + + + Major for the device or -1 if not set. + + + + + Major for the device or -1 if not set. + + UNIX special device file for device. Example: /dev/sda. diff --git a/tools/devkit-disks.c b/tools/devkit-disks.c index d85ca86..eedd4b8 100644 --- a/tools/devkit-disks.c +++ b/tools/devkit-disks.c @@ -345,6 +345,8 @@ typedef struct { char *native_path; + gint64 device_major; + gint64 device_minor; char *device_file; char **device_file_by_id; char **device_file_by_path; @@ -476,6 +478,10 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props) if (strcmp (key, "native-path") == 0) props->native_path = g_strdup (g_value_get_string (value)); + else if (strcmp (key, "device-major") == 0) + props->device_major = g_value_get_int64 (value); + else if (strcmp (key, "device-minor") == 0) + props->device_minor = g_value_get_int64 (value); else if (strcmp (key, "device-file") == 0) props->device_file = g_strdup (g_value_get_string (value)); else if (strcmp (key, "device-file-by-id") == 0) @@ -982,6 +988,9 @@ do_show_info (const char *object_path) g_print ("Showing information for %s\n", object_path); g_print (" native-path: %s\n", props->native_path); + g_print (" device: %" G_GINT64_MODIFIER "d:%" G_GINT64_MODIFIER "d\n", + props->device_major, + props->device_minor); g_print (" device-file: %s\n", props->device_file); for (n = 0; props->device_file_by_id[n] != NULL; n++) g_print (" by-id: %s\n", (char *) props->device_file_by_id[n]); -- 2.7.4