示例#1
0
static gboolean
dummy_loop_object_process_uevent (StoragedModuleObject  *module_object,
                                  const gchar           *action,
                                  StoragedLinuxDevice   *device)
{
  DummyLoopObject *object;
  GList *link;

  g_return_val_if_fail (DUMMY_IS_LOOP_OBJECT (module_object), FALSE);
  g_return_val_if_fail (device == NULL || STORAGED_IS_LINUX_DEVICE (device), FALSE);

  if (! dummy_loop_object_should_include_device (device))
    return FALSE;

  object = DUMMY_LOOP_OBJECT (module_object);

  link = NULL;
  if (device != NULL)
    link = find_link_for_sysfs_path (object, g_udev_device_get_sysfs_path (device->udev_device));
  if (g_strcmp0 (action, "remove") == 0)
    {
      if (link != NULL)
        {
          g_object_unref (STORAGED_LINUX_DEVICE (link->data));
          object->devices = g_list_delete_link (object->devices, link);
        }
      else
        {
          storaged_warning ("Object doesn't have device with sysfs path %s on remove event",
                            g_udev_device_get_sysfs_path (device->udev_device));
        }
    }
  else
    {
      if (link != NULL)
        {
          g_object_unref (STORAGED_LINUX_DEVICE (link->data));
          link->data = g_object_ref (device);
        }
      else
        {
          if (device != NULL)
            {
              object->devices = g_list_append (object->devices, g_object_ref (device));
              g_object_notify (G_OBJECT (object), "device");
            }
        }
    }

  update_iface (STORAGED_OBJECT (object), action, linux_loop_check, linux_loop_connect, linux_loop_update,
                DUMMY_TYPE_LINUX_LOOP, &object->iface_loop);

  return TRUE;
}
示例#2
0
/**
 * udisks_linux_drive_object_uevent:
 * @object: A #UDisksLinuxDriveObject.
 * @action: Uevent action or %NULL
 * @device: A #UDisksLinuxDevice device object or %NULL if the device hasn't changed.
 *
 * Updates all information on interfaces on @drive.
 */
void
udisks_linux_drive_object_uevent (UDisksLinuxDriveObject *object,
                                  const gchar            *action,
                                  UDisksLinuxDevice      *device)
{
  GList *link;
  gboolean conf_changed;

  g_return_if_fail (UDISKS_IS_LINUX_DRIVE_OBJECT (object));
  g_return_if_fail (device == NULL || UDISKS_IS_LINUX_DEVICE (device));

  link = NULL;
  if (device != NULL)
    link = find_link_for_sysfs_path (object, g_udev_device_get_sysfs_path (device->udev_device));
  if (g_strcmp0 (action, "remove") == 0)
    {
      if (link != NULL)
        {
          g_object_unref (UDISKS_LINUX_DEVICE (link->data));
          object->devices = g_list_delete_link (object->devices, link);
        }
      else
        {
          udisks_warning ("Drive doesn't have device with sysfs path %s on remove event",
                          g_udev_device_get_sysfs_path (device->udev_device));
        }
    }
  else
    {
      if (link != NULL)
        {
          g_object_unref (UDISKS_LINUX_DEVICE (link->data));
          link->data = g_object_ref (device);
        }
      else
        {
          if (device != NULL)
            object->devices = g_list_append (object->devices, g_object_ref (device));
        }
    }

  conf_changed = FALSE;
  conf_changed |= update_iface (object, action, drive_check, drive_connect, drive_update,
                                UDISKS_TYPE_LINUX_DRIVE, &object->iface_drive);
  conf_changed |= update_iface (object, action, drive_ata_check, drive_ata_connect, drive_ata_update,
                                UDISKS_TYPE_LINUX_DRIVE_ATA, &object->iface_drive_ata);

  if (conf_changed)
    apply_configuration (object);
}
/**
 * storaged_linux_drive_object_uevent:
 * @object: A #StoragedLinuxDriveObject.
 * @action: Uevent action or %NULL
 * @device: A #StoragedLinuxDevice device object or %NULL if the device hasn't changed.
 *
 * Updates all information on interfaces on @drive.
 */
void
storaged_linux_drive_object_uevent (StoragedLinuxDriveObject *object,
                                    const gchar              *action,
                                    StoragedLinuxDevice      *device)
{
    GList *link;
    gboolean conf_changed;
    StoragedModuleManager *module_manager;
    GHashTableIter iter;
    gpointer key;
    ModuleInterfaceEntry *entry;

    g_return_if_fail (STORAGED_IS_LINUX_DRIVE_OBJECT (object));
    g_return_if_fail (device == NULL || STORAGED_IS_LINUX_DEVICE (device));

    link = NULL;
    if (device != NULL)
        link = find_link_for_sysfs_path (object, g_udev_device_get_sysfs_path (device->udev_device));
    if (g_strcmp0 (action, "remove") == 0)
    {
        if (link != NULL)
        {
            g_object_unref (STORAGED_LINUX_DEVICE (link->data));
            object->devices = g_list_delete_link (object->devices, link);
        }
        else
        {
            storaged_warning ("Drive doesn't have device with sysfs path %s on remove event",
                              device ? g_udev_device_get_sysfs_path (device->udev_device) : "(null device)");
        }
    }
    else
    {
        if (link != NULL)
        {
            g_object_unref (STORAGED_LINUX_DEVICE (link->data));
            link->data = g_object_ref (device);
        }
        else
        {
            if (device != NULL)
                object->devices = g_list_append (object->devices, g_object_ref (device));
        }
    }

    conf_changed = FALSE;
    conf_changed |= update_iface (STORAGED_OBJECT (object), action, drive_check, drive_connect, drive_update,
                                  STORAGED_TYPE_LINUX_DRIVE, &object->iface_drive);
    conf_changed |= update_iface (STORAGED_OBJECT (object), action, drive_ata_check, drive_ata_connect, drive_ata_update,
                                  STORAGED_TYPE_LINUX_DRIVE_ATA, &object->iface_drive_ata);

    /* Attach interfaces from modules */
    module_manager = storaged_daemon_get_module_manager (object->daemon);
    if (storaged_module_manager_get_modules_available (module_manager))
    {
        ensure_module_ifaces (object, module_manager);
        g_hash_table_iter_init (&iter, object->module_ifaces);
        while (g_hash_table_iter_next (&iter, &key, (gpointer *) &entry))
        {
            conf_changed |= update_iface (STORAGED_OBJECT (object), action, entry->has_func, entry->connect_func, entry->update_func,
                                          (GType) key, &entry->interface);
        }
    }

    if (conf_changed)
        apply_configuration (object);
}