From: David Zeuthen Date: Wed, 16 Feb 2011 17:04:15 +0000 (-0500) Subject: Drop Controller, AtaDrive and ScsiDrive interfaces (for now) X-Git-Tag: upstream/2.1.2~480^2~149 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4fcd1cac202f85533d62b9fff2817f8c909d82ad;p=platform%2Fupstream%2Fudisks2.git Drop Controller, AtaDrive and ScsiDrive interfaces (for now) Signed-off-by: David Zeuthen --- diff --git a/data/org.freedesktop.UDisks2.xml b/data/org.freedesktop.UDisks2.xml index 4409d43..e485fc3 100644 --- a/data/org.freedesktop.UDisks2.xml +++ b/data/org.freedesktop.UDisks2.xml @@ -16,53 +16,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Makefile.am b/src/Makefile.am index 87a9a2f..adc70ab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,7 +50,6 @@ libudisks_daemon_la_SOURCES = \ udisksfstabprovider.h udisksfstabprovider.c \ udiskslinuxblock.h udiskslinuxblock.c \ udiskslinuxdrive.h udiskslinuxdrive.c \ - udiskslinuxcontroller.h udiskslinuxcontroller.c \ udisksfilesystemimpl.h udisksfilesystemimpl.c \ udisksbasejob.h udisksbasejob.c \ udisksspawnedjob.h udisksspawnedjob.c \ diff --git a/src/types.h b/src/types.h index 8f44aa2..153973e 100644 --- a/src/types.h +++ b/src/types.h @@ -40,9 +40,6 @@ typedef struct _UDisksLinuxBlock UDisksLinuxBlock; struct _UDisksLinuxDrive; typedef struct _UDisksLinuxDrive UDisksLinuxDrive; -struct _UDisksLinuxController; -typedef struct _UDisksLinuxController UDisksLinuxController; - struct _UDisksFilesystemImpl; typedef struct _UDisksFilesystemImpl UDisksFilesystemImpl; diff --git a/src/udiskslinuxcontroller.c b/src/udiskslinuxcontroller.c deleted file mode 100644 index 7352b07..0000000 --- a/src/udiskslinuxcontroller.c +++ /dev/null @@ -1,587 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2007-2010 David Zeuthen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include "config.h" - -#include -#include - -#include "udisksdaemon.h" -#include "udisksdaemonutil.h" -#include "udiskslinuxcontroller.h" - -/** - * SECTION:udiskslinuxcontroller - * @title: UDisksLinuxController - * @short_description: Linux Disk Controllers (ATA, SCSI, etc.) - * - * Object corresponding to a controller on Linux. - */ - -typedef struct _UDisksLinuxControllerClass UDisksLinuxControllerClass; - -/** - * UDisksLinuxController: - * - * The #UDisksLinuxController structure contains only private data and - * should only be accessed using the provided API. - */ -struct _UDisksLinuxController -{ - GDBusObject parent_instance; - - UDisksDaemon *daemon; - - GUdevDevice *device; - - /* interfaces */ - UDisksController *iface_controller; -}; - -struct _UDisksLinuxControllerClass -{ - GDBusObjectClass parent_class; -}; - -enum -{ - PROP_0, - PROP_DAEMON, - PROP_DEVICE -}; - -static gboolean udisks_linux_controller_check_device (GUdevDevice *device); - -G_DEFINE_TYPE (UDisksLinuxController, udisks_linux_controller, G_TYPE_DBUS_OBJECT); - -static void -udisks_linux_controller_finalize (GObject *object) -{ - UDisksLinuxController *controller = UDISKS_LINUX_CONTROLLER (object); - - /* note: we don't hold a ref to controller->daemon or controller->mount_monitor */ - - g_object_unref (controller->device); - - if (controller->iface_controller != NULL) - g_object_unref (controller->iface_controller); - - if (G_OBJECT_CLASS (udisks_linux_controller_parent_class)->finalize != NULL) - G_OBJECT_CLASS (udisks_linux_controller_parent_class)->finalize (object); -} - -static void -udisks_linux_controller_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - UDisksLinuxController *controller = UDISKS_LINUX_CONTROLLER (object); - - switch (prop_id) - { - case PROP_DAEMON: - g_value_set_object (value, udisks_linux_controller_get_daemon (controller)); - break; - - case PROP_DEVICE: - g_value_set_object (value, udisks_linux_controller_get_device (controller)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -udisks_linux_controller_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - UDisksLinuxController *controller = UDISKS_LINUX_CONTROLLER (object); - - switch (prop_id) - { - case PROP_DAEMON: - g_assert (controller->daemon == NULL); - /* we don't take a reference to the daemon */ - controller->daemon = g_value_get_object (value); - break; - - case PROP_DEVICE: - g_assert (controller->device == NULL); - controller->device = g_value_dup_object (value); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - -static void -udisks_linux_controller_init (UDisksLinuxController *controller) -{ -} - -static GObjectConstructParam * -find_construct_property (guint n_construct_properties, - GObjectConstructParam *construct_properties, - const gchar *name) -{ - guint n; - for (n = 0; n < n_construct_properties; n++) - if (g_strcmp0 (g_param_spec_get_name (construct_properties[n].pspec), name) == 0) - return &construct_properties[n]; - return NULL; -} - -/* unless given, compute object path from sysfs path */ -static GObject * -udisks_linux_controller_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties) -{ - GObjectConstructParam *device_cp; - GUdevDevice *device; - - device_cp = find_construct_property (n_construct_properties, construct_properties, "device"); - g_assert (device_cp != NULL); - - device = G_UDEV_DEVICE (g_value_get_object (device_cp->value)); - g_assert (device != NULL); - - if (!udisks_linux_controller_check_device (device)) - { - return NULL; - } - else - { - return G_OBJECT_CLASS (udisks_linux_controller_parent_class)->constructor (type, - n_construct_properties, - construct_properties); - } -} - -static void -strip_and_replace_with_uscore (gchar *s) -{ - guint n; - - if (s == NULL) - goto out; - - g_strstrip (s); - - for (n = 0; s != NULL && s[n] != '\0'; n++) - { - if (s[n] == ' ' || s[n] == '-') - s[n] = '_'; - } - - out: - ; -} - -static void -udisks_linux_controller_constructed (GObject *object) -{ - UDisksLinuxController *controller = UDISKS_LINUX_CONTROLLER (object); - gchar *vendor; - gchar *model; - gchar *serial; - GString *str; - - /* initial coldplug */ - udisks_linux_controller_uevent (controller, "add", NULL); - - /* compute the object path */ - vendor = g_strdup (udisks_controller_get_vendor (controller->iface_controller)); - model = g_strdup (udisks_controller_get_model (controller->iface_controller)); - serial = g_strdup (udisks_controller_get_serial (controller->iface_controller)); - strip_and_replace_with_uscore (vendor); - strip_and_replace_with_uscore (model); - strip_and_replace_with_uscore (serial); - str = g_string_new ("/org/freedesktop/UDisks2/controllers/"); - if (vendor == NULL && model == NULL && serial == NULL) - { - g_string_append (str, "controller"); - } - else - { - /* TODO: use slot information */ - - /* __ */ - if (vendor != NULL && strlen (vendor) > 0) - { - udisks_safe_append_to_object_path (str, vendor); - } - if (model != NULL && strlen (model) > 0) - { - if (str->str[str->len - 1] != '/') - g_string_append_c (str, '_'); - udisks_safe_append_to_object_path (str, model); - } - if (serial != NULL && strlen (serial) > 0) - { - if (str->str[str->len - 1] != '/') - g_string_append_c (str, '_'); - udisks_safe_append_to_object_path (str, serial); - } - } - g_free (vendor); - g_free (model); - g_free (serial); - g_dbus_object_set_object_path (G_DBUS_OBJECT (controller), str->str); - g_string_free (str, TRUE); - - if (G_OBJECT_CLASS (udisks_linux_controller_parent_class)->constructed != NULL) - G_OBJECT_CLASS (udisks_linux_controller_parent_class)->constructed (object); -} - -static void -udisks_linux_controller_class_init (UDisksLinuxControllerClass *klass) -{ - GObjectClass *gobject_class; - - gobject_class = G_OBJECT_CLASS (klass); - gobject_class->constructor = udisks_linux_controller_constructor; - gobject_class->finalize = udisks_linux_controller_finalize; - gobject_class->constructed = udisks_linux_controller_constructed; - gobject_class->set_property = udisks_linux_controller_set_property; - gobject_class->get_property = udisks_linux_controller_get_property; - - /** - * UDisksLinuxController:daemon: - * - * The #UDisksDaemon the object is for. - */ - g_object_class_install_property (gobject_class, - PROP_DAEMON, - g_param_spec_object ("daemon", - "Daemon", - "The daemon the object is for", - UDISKS_TYPE_DAEMON, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - - /** - * UDisksLinuxController:device: - * - * The #GUdevDevice for the object. Connect to the #GObject::notify - * signal to get notified whenever this is updated. - */ - g_object_class_install_property (gobject_class, - PROP_DEVICE, - g_param_spec_object ("device", - "Device", - "The device for the object", - G_UDEV_TYPE_DEVICE, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - -} - -/** - * udisks_linux_controller_new: - * @daemon: A #UDisksDaemon. - * @device: The #GUdevDevice for the sysfs controller device. - * - * Create a new controller object. - * - * Returns: A #UDisksLinuxController object or %NULL if @device does not represent a controller. Free with g_object_unref(). - */ -UDisksLinuxController * -udisks_linux_controller_new (UDisksDaemon *daemon, - GUdevDevice *device) -{ - GObject *object; - - g_return_val_if_fail (UDISKS_IS_DAEMON (daemon), NULL); - g_return_val_if_fail (G_UDEV_IS_DEVICE (device), NULL); - - object = g_object_new (UDISKS_TYPE_LINUX_CONTROLLER, - "daemon", daemon, - "device", device, - NULL); - - if (object != NULL) - return UDISKS_LINUX_CONTROLLER (object); - else - return NULL; -} - -/** - * udisks_linux_controller_get_daemon: - * @controller: A #UDisksLinuxController. - * - * Gets the daemon used by @controller. - * - * Returns: A #UDisksDaemon. Do not free, the object is owned by @controller. - */ -UDisksDaemon * -udisks_linux_controller_get_daemon (UDisksLinuxController *controller) -{ - g_return_val_if_fail (UDISKS_IS_LINUX_CONTROLLER (controller), NULL); - return controller->daemon; -} - -/** - * udisks_linux_controller_get_device: - * @controller: A #UDisksLinuxController. - * - * Gets the current #GUdevDevice for @controller. Connect to - * #GObject::notify to track changes to the #UDisksLinuxController:device - * property. - * - * Returns: A #GUdevDevice. Free with g_object_unref(). - */ -GUdevDevice * -udisks_linux_controller_get_device (UDisksLinuxController *controller) -{ - g_return_val_if_fail (UDISKS_IS_LINUX_CONTROLLER (controller), NULL); - return g_object_ref (controller->device); -} - -/* ---------------------------------------------------------------------------------------------------- */ - -typedef gboolean (*HasInterfaceFunc) (UDisksLinuxController *controller); -typedef void (*UpdateInterfaceFunc) (UDisksLinuxController *controller, - const gchar *uevent_action, - GDBusInterface *interface); - -static void -update_iface (UDisksLinuxController *controller, - const gchar *uevent_action, - HasInterfaceFunc has_func, - UpdateInterfaceFunc update_func, - GType stub_type, - gpointer _interface_pointer) -{ - gboolean has; - gboolean add; - GDBusInterface **interface_pointer = _interface_pointer; - - g_return_if_fail (controller != NULL); - g_return_if_fail (has_func != NULL); - g_return_if_fail (update_func != NULL); - g_return_if_fail (g_type_is_a (stub_type, G_TYPE_OBJECT)); - g_return_if_fail (g_type_is_a (stub_type, G_TYPE_DBUS_INTERFACE)); - g_return_if_fail (interface_pointer != NULL); - g_return_if_fail (*interface_pointer == NULL || G_IS_DBUS_INTERFACE (*interface_pointer)); - - add = FALSE; - has = has_func (controller); - if (*interface_pointer == NULL) - { - if (has) - { - *interface_pointer = g_object_new (stub_type, NULL); - add = TRUE; - } - } - else - { - if (!has) - { - g_dbus_object_remove_interface (G_DBUS_OBJECT (controller), G_DBUS_INTERFACE (*interface_pointer)); - g_object_unref (*interface_pointer); - *interface_pointer = NULL; - } - } - - if (*interface_pointer != NULL) - { - update_func (controller, uevent_action, G_DBUS_INTERFACE (*interface_pointer)); - if (add) - g_dbus_object_add_interface (G_DBUS_OBJECT (controller), G_DBUS_INTERFACE (*interface_pointer)); - } -} - -/* ---------------------------------------------------------------------------------------------------- */ -/* org.freedesktop.UDisks.Controller */ - -static gboolean -controller_check (UDisksLinuxController *controller) -{ - return TRUE; -} - -static void -controller_update (UDisksLinuxController *controller, - const gchar *uevent_action, - GDBusInterface *_iface) -{ - UDisksController *iface = UDISKS_CONTROLLER (_iface); - gchar *vendor; - gchar *model; - gchar *address; - - vendor = g_strdup (g_udev_device_get_property (controller->device, "ID_VENDOR_FROM_DATABASE")); - if (vendor == NULL) - { - vendor = g_strdup_printf ("[vendor=0x%04x subsys=0x%04x]", - g_udev_device_get_sysfs_attr_as_int (controller->device, "vendor"), - g_udev_device_get_sysfs_attr_as_int (controller->device, "subsystem_vendor")); - } - - model = g_strdup (g_udev_device_get_property (controller->device, "ID_MODEL_FROM_DATABASE")); - if (model == NULL) - { - vendor = g_strdup_printf ("[model=0x%04x subsys=0x%04x]", - g_udev_device_get_sysfs_attr_as_int (controller->device, "device"), - g_udev_device_get_sysfs_attr_as_int (controller->device, "subsystem_device")); - } - - udisks_controller_set_vendor (iface, vendor); - udisks_controller_set_model (iface, model); - - address = g_strdup (g_udev_device_get_property (controller->device, "PCI_SLOT_NAME")); - if (address != NULL) - { - gchar *s; - - g_strstrip (address); - udisks_controller_set_address (iface, address); - - s = g_strrstr (address, "."); - if (s != NULL) - { - GDir *dir; - gchar *slot_name; - - *s = '\0'; - - /* Now look in /sys/bus/pci/slots/SLOTNAME/address - annoyingly, there - * are no symlinks... grr.. - */ - slot_name = NULL; - dir = g_dir_open ("/sys/bus/pci/slots", 0, NULL); - if (dir != NULL) - { - const gchar *name; - while ((name = g_dir_read_name (dir)) != NULL && slot_name == NULL) - { - gchar *address_file; - gchar *address_for_slot; - address_file = g_strdup_printf ("/sys/bus/pci/slots/%s/address", name); - if (g_file_get_contents (address_file, &address_for_slot, NULL, NULL)) - { - g_strstrip (address_for_slot); - if (g_strcmp0 (address, address_for_slot) == 0) - { - slot_name = g_strdup (name); - } - g_free (address_for_slot); - } - g_free (address_file); - } - g_dir_close (dir); - } - - udisks_controller_set_physical_slot (iface, slot_name); - } - } - - g_free (vendor); - g_free (model); - g_free (address); -} - -/* ---------------------------------------------------------------------------------------------------- */ - -/** - * udisks_linux_controller_uevent: - * @controller: A #UDisksLinuxController. - * @action: Uevent action or %NULL - * @device: A new #GUdevDevice device object or %NULL if the device hasn't changed. - * - * Updates all information on interfaces on @controller. - */ -void -udisks_linux_controller_uevent (UDisksLinuxController *controller, - const gchar *action, - GUdevDevice *device) -{ - g_return_if_fail (UDISKS_IS_LINUX_CONTROLLER (controller)); - g_return_if_fail (device == NULL || G_UDEV_IS_DEVICE (device)); - - if (device != NULL) - { - g_object_unref (controller->device); - controller->device = g_object_ref (device); - g_object_notify (G_OBJECT (controller), "device"); - } - - update_iface (controller, action, controller_check, controller_update, - UDISKS_TYPE_CONTROLLER_STUB, &controller->iface_controller); -} - -/* ---------------------------------------------------------------------------------------------------- */ - -/* - * udisks_linux_controller_check_device: - * @device: A #GUdevDevice. - * - * Checks if we should even construct a #UDisksLinuxController for @device. - * - * Returns: %TRUE if we should construct an object, %FALSE otherwise. - */ -static gboolean -udisks_linux_controller_check_device (GUdevDevice *device) -{ - gboolean ret; - GDir *dir; - guint num_scsi_host_objects; - - ret = FALSE; - - num_scsi_host_objects = 0; - dir = g_dir_open (g_udev_device_get_sysfs_path (device), 0, NULL); - if (dir != NULL) - { - const gchar *name; - while ((name = g_dir_read_name (dir)) != NULL) - { - gint number; - if (sscanf (name, "host%d", &number) != 1) - continue; - - num_scsi_host_objects++; - } - g_dir_close (dir); - } - - /* For now, don't bother if no driver is bound */ - if (num_scsi_host_objects == 0) - goto out; - - ret = TRUE; - - out: - return ret; -} diff --git a/src/udiskslinuxcontroller.h b/src/udiskslinuxcontroller.h deleted file mode 100644 index 0229d0e..0000000 --- a/src/udiskslinuxcontroller.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- - * - * Copyright (C) 2007-2010 David Zeuthen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifndef __UDISKS_LINUX_CONTROLLER_H__ -#define __UDISKS_LINUX_CONTROLLER_H__ - -#include "types.h" -#include - -G_BEGIN_DECLS - -#define UDISKS_TYPE_LINUX_CONTROLLER (udisks_linux_controller_get_type ()) -#define UDISKS_LINUX_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UDISKS_TYPE_LINUX_CONTROLLER, UDisksLinuxController)) -#define UDISKS_IS_LINUX_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UDISKS_TYPE_LINUX_CONTROLLER)) - -GType udisks_linux_controller_get_type (void) G_GNUC_CONST; -UDisksLinuxController *udisks_linux_controller_new (UDisksDaemon *daemon, - GUdevDevice *device); -void udisks_linux_controller_uevent (UDisksLinuxController *controller, - const gchar *action, - GUdevDevice *device); -UDisksDaemon *udisks_linux_controller_get_daemon (UDisksLinuxController *controller); -GUdevDevice *udisks_linux_controller_get_device (UDisksLinuxController *controller); - -G_END_DECLS - -#endif /* __UDISKS_LINUX_CONTROLLER_H__ */ diff --git a/src/udiskslinuxdrive.c b/src/udiskslinuxdrive.c index f76799b..5712a95 100644 --- a/src/udiskslinuxdrive.c +++ b/src/udiskslinuxdrive.c @@ -25,7 +25,6 @@ #include "udisksdaemon.h" #include "udisksdaemonutil.h" #include "udiskslinuxdrive.h" -#include "udiskslinuxcontroller.h" /** * SECTION:udiskslinuxdrive @@ -53,8 +52,6 @@ struct _UDisksLinuxDrive /* interfaces */ UDisksDrive *iface_drive; - UDisksScsiDrive *iface_scsi_drive; - UDisksAtaDrive *iface_ata_drive; }; struct _UDisksLinuxDriveClass @@ -84,10 +81,6 @@ udisks_linux_drive_finalize (GObject *object) if (drive->iface_drive != NULL) g_object_unref (drive->iface_drive); - if (drive->iface_scsi_drive != NULL) - g_object_unref (drive->iface_scsi_drive); - if (drive->iface_ata_drive != NULL) - g_object_unref (drive->iface_ata_drive); if (G_OBJECT_CLASS (udisks_linux_drive_parent_class)->finalize != NULL) G_OBJECT_CLASS (udisks_linux_drive_parent_class)->finalize (object); @@ -438,59 +431,12 @@ drive_check (UDisksLinuxDrive *drive) return TRUE; } - -static gchar * -find_controller (GDBusObjectManager *object_manager, - GUdevDevice *drive_device) -{ - const gchar *drive_device_sysfs_path; - gchar *ret; - GList *objects; - GList *l; - - ret = NULL; - - drive_device_sysfs_path = g_udev_device_get_sysfs_path (drive_device); - - objects = g_dbus_object_manager_get_all (object_manager); - for (l = objects; l != NULL; l = l->next) - { - GDBusObject *object = G_DBUS_OBJECT (l->data); - UDisksLinuxController *controller; - GUdevDevice *controller_device; - const gchar *controller_sysfs_path; - - if (!UDISKS_IS_LINUX_CONTROLLER (object)) - continue; - - controller = UDISKS_LINUX_CONTROLLER (object); - controller_device = udisks_linux_controller_get_device (controller); - - controller_sysfs_path = g_udev_device_get_sysfs_path (controller_device); - - if (g_str_has_prefix (drive_device_sysfs_path, controller_sysfs_path)) - { - ret = g_dbus_object_get_object_path (object); - g_object_unref (controller_device); - goto out; - } - g_object_unref (controller_device); - } - - out: - g_list_foreach (objects, (GFunc) g_object_unref, NULL); - g_list_free (objects); - return ret; -} - static void drive_update (UDisksLinuxDrive *drive, const gchar *uevent_action, GDBusInterface *_iface) { UDisksDrive *iface = UDISKS_DRIVE (_iface); - GDBusObjectManager *object_manager; - gchar *controller_object_path; /* this is the _almost_ the same for both ATA and SCSI devices (cf. udev's ata_id and scsi_id) * but we special case since there are subtle differences... @@ -513,7 +459,6 @@ drive_update (UDisksLinuxDrive *drive, udisks_drive_set_revision (iface, g_udev_device_get_property (drive->device, "ID_REVISION")); udisks_drive_set_serial (iface, g_udev_device_get_property (drive->device, "ID_SERIAL_SHORT")); udisks_drive_set_wwn (iface, g_udev_device_get_property (drive->device, "ID_WWN_WITH_EXTENSION")); - udisks_drive_set_ctds (iface, g_udev_device_get_name (drive->device)); } else if (g_udev_device_get_property_as_boolean (drive->device, "ID_SCSI")) { @@ -543,7 +488,6 @@ drive_update (UDisksLinuxDrive *drive, udisks_drive_set_revision (iface, g_udev_device_get_property (drive->device, "ID_REVISION")); udisks_drive_set_serial (iface, g_udev_device_get_property (drive->device, "ID_SCSI_SERIAL")); udisks_drive_set_wwn (iface, g_udev_device_get_property (drive->device, "ID_WWN_WITH_EXTENSION")); - udisks_drive_set_ctds (iface, g_udev_device_get_name (drive->device)); } else { @@ -553,69 +497,10 @@ drive_update (UDisksLinuxDrive *drive, udisks_drive_set_revision (iface, g_udev_device_get_property (drive->device, "ID_REVISION")); udisks_drive_set_serial (iface, g_udev_device_get_property (drive->device, "ID_SERIAL_SHORT")); udisks_drive_set_wwn (iface, g_udev_device_get_property (drive->device, "ID_WWN_WITH_EXTENSION")); - udisks_drive_set_ctds (iface, g_udev_device_get_name (drive->device)); - } - - /* TODO: if this is slow we could have a cache or ensure that we - * only do this once or something else - */ - object_manager = udisks_daemon_get_object_manager (drive->daemon); - controller_object_path = find_controller (object_manager, drive->device); - if (controller_object_path != NULL) - { - udisks_drive_set_controller (iface, controller_object_path); - g_free (controller_object_path); - } - else - { - udisks_drive_set_controller (iface, "/"); } } /* ---------------------------------------------------------------------------------------------------- */ -/* org.freedesktop.UDisks.AtaDrive */ - -static gboolean -ata_drive_check (UDisksLinuxDrive *drive) -{ - if (g_udev_device_get_property_as_boolean (drive->device, "ID_ATA")) - return TRUE; - else - return FALSE; -} - -static void -ata_drive_update (UDisksLinuxDrive *drive, - const gchar *uevent_action, - GDBusInterface *_iface) -{ - //UDisksAtaDrive *iface = UDISKS_DRIVE (_iface); - - /* TODO */ -} - -/* ---------------------------------------------------------------------------------------------------- */ -/* org.freedesktop.UDisks.ScsiDrive */ - -static gboolean -scsi_drive_check (UDisksLinuxDrive *drive) -{ - if (g_udev_device_get_property_as_boolean (drive->device, "ID_SCSI")) - return TRUE; - else - return FALSE; -} - -static void -scsi_drive_update (UDisksLinuxDrive *drive, - const gchar *uevent_action, - GDBusInterface *_iface) -{ - //UDisksScsiDrive *iface = UDISKS_DRIVE (_iface); - /* TODO */ -} - -/* ---------------------------------------------------------------------------------------------------- */ /** * udisks_linux_drive_uevent: @@ -642,10 +527,6 @@ udisks_linux_drive_uevent (UDisksLinuxDrive *drive, update_iface (drive, action, drive_check, drive_update, UDISKS_TYPE_DRIVE_STUB, &drive->iface_drive); - update_iface (drive, action, ata_drive_check, ata_drive_update, - UDISKS_TYPE_ATA_DRIVE_STUB, &drive->iface_ata_drive); - update_iface (drive, action, scsi_drive_check, scsi_drive_update, - UDISKS_TYPE_SCSI_DRIVE_STUB, &drive->iface_scsi_drive); } /* ---------------------------------------------------------------------------------------------------- */ diff --git a/src/udiskslinuxprovider.c b/src/udiskslinuxprovider.c index 93c1e90..a536e90 100644 --- a/src/udiskslinuxprovider.c +++ b/src/udiskslinuxprovider.c @@ -25,7 +25,6 @@ #include "udiskslinuxprovider.h" #include "udiskslinuxblock.h" #include "udiskslinuxdrive.h" -#include "udiskslinuxcontroller.h" /** * SECTION:udiskslinuxprovider @@ -106,7 +105,7 @@ static void udisks_linux_provider_constructed (GObject *object) { UDisksLinuxProvider *provider = UDISKS_LINUX_PROVIDER (object); - const gchar *subsystems[] = {"block", "scsi", "pci", NULL}; + const gchar *subsystems[] = {"block", "scsi", NULL}; GList *devices; GList *l; @@ -130,13 +129,6 @@ udisks_linux_provider_constructed (GObject *object) g_free, (GDestroyNotify) g_object_unref); - /* TODO: maybe do two loops to properly handle dependency SNAFU? */ - devices = g_udev_client_query_by_subsystem (provider->gudev_client, "pci"); - for (l = devices; l != NULL; l = l->next) - udisks_linux_provider_handle_uevent (provider, "add", G_UDEV_DEVICE (l->data)); - g_list_foreach (devices, (GFunc) g_object_unref, NULL); - g_list_free (devices); - devices = g_udev_client_query_by_subsystem (provider->gudev_client, "scsi"); for (l = devices; l != NULL; l = l->next) udisks_linux_provider_handle_uevent (provider, "add", G_UDEV_DEVICE (l->data)); @@ -288,51 +280,6 @@ handle_scsi_uevent (UDisksLinuxProvider *provider, } static void -handle_pci_uevent (UDisksLinuxProvider *provider, - const gchar *action, - GUdevDevice *device) -{ - const gchar *sysfs_path; - UDisksLinuxController *controller; - UDisksDaemon *daemon; - - daemon = udisks_provider_get_daemon (UDISKS_PROVIDER (provider)); - sysfs_path = g_udev_device_get_sysfs_path (device); - - if (g_strcmp0 (action, "remove") == 0) - { - controller = g_hash_table_lookup (provider->sysfs_to_controller, sysfs_path); - if (controller != NULL) - { - gchar *object_path; - object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (controller)); - g_dbus_object_manager_unexport (udisks_daemon_get_object_manager (daemon), - object_path); - g_free (object_path); - g_warn_if_fail (g_hash_table_remove (provider->sysfs_to_controller, sysfs_path)); - } - } - else - { - controller = g_hash_table_lookup (provider->sysfs_to_controller, sysfs_path); - if (controller != NULL) - { - udisks_linux_controller_uevent (controller, action, device); - } - else - { - controller = udisks_linux_controller_new (daemon, device); - if (controller != NULL) - { - g_dbus_object_manager_export_and_uniquify (udisks_daemon_get_object_manager (daemon), - G_DBUS_OBJECT (controller)); - g_hash_table_insert (provider->sysfs_to_controller, g_strdup (sysfs_path), controller); - } - } - } -} - -static void udisks_linux_provider_handle_uevent (UDisksLinuxProvider *provider, const gchar *action, GUdevDevice *device) @@ -357,8 +304,4 @@ udisks_linux_provider_handle_uevent (UDisksLinuxProvider *provider, { handle_scsi_uevent (provider, action, device); } - else if (g_strcmp0 (subsystem, "pci") == 0) - { - handle_pci_uevent (provider, action, device); - } } diff --git a/tools/udisksctl.c b/tools/udisksctl.c index 8c65dec..0b7eb21 100644 --- a/tools/udisksctl.c +++ b/tools/udisksctl.c @@ -467,43 +467,6 @@ lookup_object_proxy_by_drive (const gchar *drive) return ret; } -static GDBusObjectProxy * -lookup_object_proxy_by_controller (const gchar *controller) -{ - GDBusObjectProxy *ret; - GList *object_proxies; - GList *l; - gchar *full_controller_object_path; - - ret = NULL; - - full_controller_object_path = g_strdup_printf ("/org/freedesktop/UDisks2/controllers/%s", controller); - - object_proxies = g_dbus_proxy_manager_get_all (manager); - for (l = object_proxies; l != NULL; l = l->next) - { - GDBusObjectProxy *object_proxy = G_DBUS_OBJECT_PROXY (l->data); - UDisksController *controller; - - if (g_strcmp0 (g_dbus_object_proxy_get_object_path (object_proxy), full_controller_object_path) != 0) - continue; - - controller = UDISKS_PEEK_CONTROLLER (object_proxy); - if (controller != NULL) - { - ret = g_object_ref (object_proxy); - goto out; - } - } - - out: - g_list_foreach (object_proxies, (GFunc) g_object_unref, NULL); - g_list_free (object_proxies); - g_free (full_controller_object_path); - - return ret; -} - /* ---------------------------------------------------------------------------------------------------- */ static gchar *opt_mount_unmount_object_path = NULL; @@ -864,14 +827,12 @@ handle_command_mount_unmount (gint *argc, static gchar *opt_info_object = NULL; static gchar *opt_info_device = NULL; static gchar *opt_info_drive = NULL; -static gchar *opt_info_controller = NULL; static const GOptionEntry command_info_entries[] = { { "object-path", 'p', 0, G_OPTION_ARG_STRING, &opt_info_object, "Object to get information about", NULL}, { "block-device", 'b', 0, G_OPTION_ARG_STRING, &opt_info_device, "Block device to get information about", NULL}, { "drive", 'd', 0, G_OPTION_ARG_STRING, &opt_info_drive, "Drive to get information about", NULL}, - { "controller", 'c', 0, G_OPTION_ARG_STRING, &opt_info_controller, "Controller to get information about", NULL}, { NULL } }; @@ -888,20 +849,17 @@ handle_command_info (gint *argc, gboolean complete_objects; gboolean complete_devices; gboolean complete_drives; - gboolean complete_controllers; GList *l; GList *object_proxies; GDBusObjectProxy *object_proxy; UDisksBlockDevice *block; UDisksDrive *drive; - UDisksController *controller; guint n; ret = 1; opt_info_object = NULL; opt_info_device = NULL; opt_info_drive = NULL; - opt_info_controller = NULL; modify_argv0_for_command (argc, argv, "info"); @@ -933,13 +891,6 @@ handle_command_info (gint *argc, remove_arg ((*argc) - 1, argc, argv); } - complete_controllers = FALSE; - if (request_completion && (g_strcmp0 (completion_prev, "--controller") == 0 || g_strcmp0 (completion_prev, "-c") == 0)) - { - complete_controllers = TRUE; - remove_arg ((*argc) - 1, argc, argv); - } - if (!g_option_context_parse (o, argc, argv, NULL)) { if (!request_completion) @@ -954,13 +905,11 @@ handle_command_info (gint *argc, if (request_completion && (opt_info_object == NULL && !complete_objects) && (opt_info_device == NULL && !complete_devices) && - (opt_info_drive == NULL && !complete_drives) && - (opt_info_controller == NULL && !complete_controllers)) + (opt_info_drive == NULL && !complete_drives)) { g_print ("--object-path \n" "--block-device \n" - "--drive \n" - "--controller \n"); + "--drive \n"); } if (complete_objects) @@ -1021,25 +970,6 @@ handle_command_info (gint *argc, goto out; } - if (complete_controllers) - { - object_proxies = g_dbus_proxy_manager_get_all (manager); - for (l = object_proxies; l != NULL; l = l->next) - { - object_proxy = G_DBUS_OBJECT_PROXY (l->data); - controller = UDISKS_PEEK_CONTROLLER (object_proxy); - if (controller != NULL) - { - const gchar *base; - base = g_strrstr (g_dbus_object_proxy_get_object_path (object_proxy), "/") + 1; - g_print ("%s \n", base); - } - } - g_list_foreach (object_proxies, (GFunc) g_object_unref, NULL); - g_list_free (object_proxies); - goto out; - } - /* done with completion */ if (request_completion) goto out; @@ -1072,15 +1002,6 @@ handle_command_info (gint *argc, goto out; } } - else if (opt_info_controller != NULL) - { - object_proxy = lookup_object_proxy_by_controller (opt_info_controller); - if (object_proxy == NULL) - { - g_printerr ("Error looking up object for controller %s\n", opt_info_controller); - goto out; - } - } else { s = g_option_context_get_help (o, FALSE, NULL); @@ -1101,7 +1022,6 @@ handle_command_info (gint *argc, g_free (opt_info_object); g_free (opt_info_device); g_free (opt_info_drive); - g_free (opt_info_controller); return ret; } @@ -1511,87 +1431,6 @@ handle_command_monitor (gint *argc, /* ---------------------------------------------------------------------------------------------------- */ -static void -parse_ctds (const gchar *ctds, - guint *c, - guint *d, - guint *t, - guint *s) -{ - if (sscanf (ctds, "%d:%d:%d:%d", c, d, t, s) != 4) - { - g_warning ("Error parsing `%s'", ctds); - *c = 0; - *d = 0; - *t = 0; - *s = 0; - } -} - -static gint -obj_proxy_cmp_controller (GDBusObjectProxy *a, - GDBusObjectProxy *b) -{ - UDisksController *ca; - UDisksController *cb; - - ca = UDISKS_PEEK_CONTROLLER (a); - cb = UDISKS_PEEK_CONTROLLER (b); - - if (ca != NULL && cb != NULL) - { - return g_strcmp0 (udisks_controller_get_address (ca), udisks_controller_get_address (cb)); - } - else - { - return obj_proxy_cmp (a, b); - } -} - -static gint -obj_proxy_cmp_ctds (GDBusObjectProxy *a, - GDBusObjectProxy *b) -{ - UDisksDrive *da; - UDisksDrive *db; - - da = UDISKS_PEEK_DRIVE (a); - db = UDISKS_PEEK_DRIVE (b); - - if (da != NULL && db != NULL) - { - guint c_a, t_a, d_a, s_a; - guint c_b, t_b, d_b, s_b; - - parse_ctds (udisks_drive_get_ctds (da), &c_a, &t_a, &d_a, &s_a); - parse_ctds (udisks_drive_get_ctds (db), &c_b, &t_b, &d_b, &s_b); - - if (c_a > c_b) - return 1; - else if (c_a < c_b) - return -1; - - if (t_a > t_b) - return 1; - else if (t_a < t_b) - return -1; - - if (d_a > d_b) - return 1; - else if (d_a < d_b) - return -1; - - if (s_a > s_b) - return 1; - else if (s_a < s_b) - return -1; - - return 0; - } - else - return obj_proxy_cmp (a, b); -} - /* built-in assumption: there is only one block device per drive */ static UDisksBlockDevice * find_block_for_drive (GList *object_proxies, @@ -1626,6 +1465,7 @@ static const GOptionEntry command_status_entries[] = { NULL } }; +#if 0 static void print_with_padding_and_ellipsis (const gchar *str, gint max_len) @@ -1651,6 +1491,7 @@ print_with_padding_and_ellipsis (const gchar *str, g_free (s); } } +#endif static gint handle_command_status (gint *argc, @@ -1664,7 +1505,6 @@ handle_command_status (gint *argc, gchar *s; GList *l; GList *object_proxies; - guint n; ret = 1; @@ -1694,58 +1534,28 @@ handle_command_status (gint *argc, object_proxies = g_dbus_proxy_manager_get_all (manager); - /* first, print all controllers - */ - - g_print ("NUM ADDRESS SLOT VENDOR MODEL \n" - "--------------------------------------------------------------------------------\n"); - /* 1 0000:00:1f.1 SLOT 1 Intel Corp… 82801HBM/HEM (ICH8M/ICH8M-E) SATA AH… */ - /* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */ - - /* sort according to e.g. PCI address */ - object_proxies = g_list_sort (object_proxies, (GCompareFunc) obj_proxy_cmp_controller); - for (l = object_proxies, n = 0; l != NULL; l = l->next, n++) - { - GDBusObjectProxy *object_proxy = G_DBUS_OBJECT_PROXY (l->data); - UDisksController *controller; - - controller = UDISKS_PEEK_CONTROLLER (object_proxy); - if (controller == NULL) - continue; - - g_print ("% 3d ", n); - print_with_padding_and_ellipsis (udisks_controller_get_address (controller), 14); - print_with_padding_and_ellipsis (udisks_controller_get_physical_slot (controller), 9); - print_with_padding_and_ellipsis (udisks_controller_get_vendor (controller), 12); - print_with_padding_and_ellipsis (udisks_controller_get_model (controller), 40); - g_print ("\n"); - } - g_print ("\n"); - - /* then, print all drives + /* print all drives * * We are guaranteed that, usually, * - * - CTDS <= 12 * - model <= 16 (SCSI: 16, ATA: 40) * - vendor <= 8 (SCSI: 8, ATA: 0) * - revision <= 8 (SCSI: 6, ATA: 8) * - serial <= 20 (SCSI: 16, ATA: 20) */ - g_print ("CTDS MODEL REVISION SERIAL BLOCK\n" + g_print ("LOCATION MODEL REVISION SERIAL BLOCK\n" "--------------------------------------------------------------------------------\n"); - /* (10,11,12,0) SEAGATE ST3300657SS 0006 3SJ1QNMQ00009052NECM sdaa */ + /* SEAGATE ST3300657SS 0006 3SJ1QNMQ00009052NECM sdaa */ /* 01234567890123456789012345678901234567890123456789012345678901234567890123456789 */ - /* sort according to Controller-Target-Drive */ - object_proxies = g_list_sort (object_proxies, (GCompareFunc) obj_proxy_cmp_ctds); + /* TODO: sort */ + //object_proxies = g_list_sort (object_proxies, (GCompareFunc) obj_proxy_cmp_ctds); for (l = object_proxies; l != NULL; l = l->next) { GDBusObjectProxy *object_proxy = G_DBUS_OBJECT_PROXY (l->data); UDisksDrive *drive; UDisksBlockDevice *block; const gchar *block_device; - const gchar *ctds; const gchar *vendor; const gchar *model; const gchar *revision; @@ -1767,7 +1577,6 @@ handle_command_status (gint *argc, block_device = "-"; } - ctds = udisks_drive_get_ctds (drive); vendor = udisks_drive_get_vendor (drive); model = udisks_drive_get_model (drive); revision = udisks_drive_get_revision (drive); @@ -1786,8 +1595,9 @@ handle_command_status (gint *argc, else vendor_model = g_strdup ("-"); + /* TODO: need to figure out LOCATION */ g_print ("%-13s %-25s %-9s %-20s %-8s\n", - ctds, + "", vendor_model, revision, serial,