コード例 #1
0
ファイル: udiskslinuxdriveobject.c プロジェクト: GinoM/eudisk
/**
 * 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);
}
コード例 #2
0
ファイル: udiskslinuxblockobject.c プロジェクト: GinoM/eudisk
/**
 * udisks_linux_block_object_uevent:
 * @object: A #UDisksLinuxBlockObject.
 * @action: Uevent action or %NULL
 * @device: A new #UDisksLinuxDevice device object or %NULL if the device hasn't changed.
 *
 * Updates all information on interfaces on @object.
 */
void
udisks_linux_block_object_uevent (UDisksLinuxBlockObject *object,
                                  const gchar            *action,
                                  UDisksLinuxDevice      *device)
{
  g_return_if_fail (UDISKS_IS_LINUX_BLOCK_OBJECT (object));
  g_return_if_fail (device == NULL || UDISKS_IS_LINUX_DEVICE (device));

  if (device != NULL)
    {
      g_object_unref (object->device);
      object->device = g_object_ref (device);
      g_object_notify (G_OBJECT (object), "device");
    }

  update_iface (object, action, block_device_check, block_device_connect, block_device_update,
                UDISKS_TYPE_LINUX_BLOCK, &object->iface_block_device);
  update_iface (object, action, filesystem_check, filesystem_connect, filesystem_update,
                UDISKS_TYPE_LINUX_FILESYSTEM, &object->iface_filesystem);
  update_iface (object, action, swapspace_check, swapspace_connect, swapspace_update,
                UDISKS_TYPE_LINUX_SWAPSPACE, &object->iface_swapspace);
  update_iface (object, action, encrypted_check, encrypted_connect, encrypted_update,
                UDISKS_TYPE_LINUX_ENCRYPTED, &object->iface_encrypted);
  update_iface (object, action, loop_check, loop_connect, loop_update,
                UDISKS_TYPE_LINUX_LOOP, &object->iface_loop);
  update_iface (object, action, partition_table_check, partition_table_connect, partition_table_update,
                UDISKS_TYPE_LINUX_PARTITION_TABLE, &object->iface_partition_table);
  update_iface (object, action, partition_check, partition_connect, partition_update,
                UDISKS_TYPE_LINUX_PARTITION, &object->iface_partition);
}
コード例 #3
0
ファイル: dummyloopobject.c プロジェクト: frankzhao/storaged
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;
}
コード例 #4
0
/**
 * storaged_linux_block_object_uevent:
 * @object: A #StoragedLinuxBlockObject.
 * @action: Uevent action or %NULL
 * @device: A new #StoragedLinuxDevice device object or %NULL if the device hasn't changed.
 *
 * Updates all information on interfaces on @object.
 */
void
storaged_linux_block_object_uevent (StoragedLinuxBlockObject *object,
                                    const gchar              *action,
                                    StoragedLinuxDevice      *device)
{
    StoragedModuleManager *module_manager;
    GHashTableIter iter;
    gpointer key;
    ModuleInterfaceEntry *entry;

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

    if (device != NULL)
    {
        g_object_unref (object->device);
        object->device = g_object_ref (device);
        g_object_notify (G_OBJECT (object), "device");
    }

    update_iface (STORAGED_OBJECT (object), action, block_device_check, block_device_connect, block_device_update,
                  STORAGED_TYPE_LINUX_BLOCK, &object->iface_block_device);
    update_iface (STORAGED_OBJECT (object), action, filesystem_check, filesystem_connect, filesystem_update,
                  STORAGED_TYPE_LINUX_FILESYSTEM, &object->iface_filesystem);
    update_iface (STORAGED_OBJECT (object), action, swapspace_check, swapspace_connect, swapspace_update,
                  STORAGED_TYPE_LINUX_SWAPSPACE, &object->iface_swapspace);
    update_iface (STORAGED_OBJECT (object), action, encrypted_check, encrypted_connect, encrypted_update,
                  STORAGED_TYPE_LINUX_ENCRYPTED, &object->iface_encrypted);
    update_iface (STORAGED_OBJECT (object), action, loop_check, loop_connect, loop_update,
                  STORAGED_TYPE_LINUX_LOOP, &object->iface_loop);
    update_iface (STORAGED_OBJECT (object), action, partition_table_check, partition_table_connect, partition_table_update,
                  STORAGED_TYPE_LINUX_PARTITION_TABLE, &object->iface_partition_table);
    update_iface (STORAGED_OBJECT (object), action, partition_check, partition_connect, partition_update,
                  STORAGED_TYPE_LINUX_PARTITION, &object->iface_partition);

    /* 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))
        {
            update_iface (STORAGED_OBJECT (object), action, entry->has_func, entry->connect_func, entry->update_func,
                          (GType) key, &entry->interface);
        }
    }
}
コード例 #5
0
/**
 * 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);
}
コード例 #6
0
/**
 * udisks_linux_mdraid_object_uevent:
 * @object: A #UDisksLinuxMDRaidObject.
 * @action: Uevent action or %NULL
 * @device: A #UDisksLinuxDevice device object or %NULL if the device hasn't changed.
 * @is_member: %TRUE if @device is a member, %FALSE if it's the raid device.
 *
 * Updates all information on interfaces on @mdraid.
 */
void
udisks_linux_mdraid_object_uevent (UDisksLinuxMDRaidObject *object,
                                   const gchar             *action,
                                   UDisksLinuxDevice       *device,
                                   gboolean                 is_member)
{
  gboolean conf_changed = FALSE;

  g_return_if_fail (UDISKS_IS_LINUX_MDRAID_OBJECT (object));
  g_return_if_fail (UDISKS_IS_LINUX_DEVICE (device));

  /* udisks_debug ("is_member=%d for uuid %s and device %s", is_member, object->uuid, g_udev_device_get_device_file (device->udev_device)); */

  if (is_member)
    {
      GList *link = NULL;
      link = NULL;
      if (device != NULL)
        link = find_link_for_sysfs_path_for_member (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->member_devices = g_list_delete_link (object->member_devices, link);
            }
          else
            {
              udisks_warning ("MDRaid with UUID %s doesn't have member device with sysfs path %s on remove event",
                              object->uuid,
                              g_udev_device_get_sysfs_path (device->udev_device));
            }
        }
      else
        {
          if (link != NULL)
            {
              if (device != link->data)
                {
                  g_object_unref (UDISKS_LINUX_DEVICE (link->data));
                  link->data = g_object_ref (device);
                }
            }
          else
            {
              if (device != NULL)
                {
                  object->member_devices = g_list_append (object->member_devices, g_object_ref (device));
                }
            }
        }
    }
  else
    {
      /* Skip partitions of raid devices */
      if (g_strcmp0 (g_udev_device_get_devtype (device->udev_device), "disk") != 0)
        goto out;

      if (g_strcmp0 (action, "remove") == 0)
        {
          if (object->raid_device != NULL)
            if (g_strcmp0 (g_udev_device_get_sysfs_path (object->raid_device->udev_device),
                           g_udev_device_get_sysfs_path (device->udev_device)) == 0)
              {
                g_clear_object (&object->raid_device);
                raid_device_removed (object, object->raid_device);
              }
            else
              {
                udisks_warning ("MDRaid with UUID %s doesn't have raid device with sysfs path %s on remove event (it has %s)",
                                object->uuid,
                                g_udev_device_get_sysfs_path (device->udev_device),
                                g_udev_device_get_sysfs_path (object->raid_device->udev_device));
              }
          else
            {
              udisks_warning ("MDRaid with UUID %s doesn't have raid device with sysfs path %s on remove event",
                              object->uuid,
                              g_udev_device_get_sysfs_path (device->udev_device));
            }
        }
      else
        {
          if (object->raid_device == NULL)
            {
              object->raid_device = g_object_ref (device);
              raid_device_added (object, object->raid_device);
            }
          else
            {
              if (device != object->raid_device)
                {
                  /* device changed -- remove and re-add the file watchers */
                  raid_device_removed (object, object->raid_device);
                  g_clear_object (&object->raid_device);
                  object->raid_device = g_object_ref (device);
                  raid_device_added (object, object->raid_device);
                }
            }
        }
    }

  /* if we don't have any devices, no point in updating (we should get nuked soon anyway) */
  if (udisks_linux_mdraid_object_have_devices (object))
    {
      conf_changed = FALSE;
      conf_changed |= update_iface (object, action, mdraid_check, mdraid_connect, mdraid_update,
                                    UDISKS_TYPE_LINUX_MDRAID, &object->iface_mdraid);
    }
 out:
  ;
}