Ejemplo n.º 1
0
void
storage_mdraid_update (StorageMDRaid *mdraid)
{
    UDisksMDRaid *udisks_mdraid = mdraid->udisks_mdraid;
    CockpitStorageMDRaid *iface = COCKPIT_STORAGE_MDRAID (mdraid);
    StorageProvider *provider = storage_object_get_provider (mdraid->object);
    UDisksClient *udisks_client = storage_provider_get_udisks_client (provider);

    cockpit_storage_mdraid_set_uuid (iface, udisks_mdraid_get_uuid (udisks_mdraid));
    cockpit_storage_mdraid_set_name (iface, udisks_mdraid_get_name (udisks_mdraid));
    cockpit_storage_mdraid_set_level (iface, udisks_mdraid_get_level (udisks_mdraid));
    cockpit_storage_mdraid_set_num_devices (iface, udisks_mdraid_get_num_devices (udisks_mdraid));
    cockpit_storage_mdraid_set_size (iface, udisks_mdraid_get_size (udisks_mdraid));
    cockpit_storage_mdraid_set_sync_action (iface, udisks_mdraid_get_sync_action (udisks_mdraid));
    cockpit_storage_mdraid_set_sync_completed (iface, udisks_mdraid_get_sync_completed (udisks_mdraid));
    cockpit_storage_mdraid_set_sync_rate (iface, udisks_mdraid_get_sync_rate (udisks_mdraid));
    cockpit_storage_mdraid_set_sync_remaining_time (iface, udisks_mdraid_get_sync_remaining_time (udisks_mdraid));
    cockpit_storage_mdraid_set_degraded (iface, udisks_mdraid_get_degraded (udisks_mdraid));
    {
        gs_free gchar *loc = g_locale_to_utf8 (udisks_mdraid_get_bitmap_location (udisks_mdraid),
                                               -1, NULL, NULL, NULL);
        cockpit_storage_mdraid_set_bitmap_location (iface, loc);
    }
    cockpit_storage_mdraid_set_chunk_size (iface, udisks_mdraid_get_chunk_size (udisks_mdraid));

    GVariantBuilder devices;
    g_variant_builder_init (&devices, G_VARIANT_TYPE("a(oiast)"));

    GVariantIter iter;
    gint disk_slot;
    const gchar *disk_block_objpath;
    gs_unref_variant GVariant *disk_states = NULL;
    guint64 disk_num_errors;
    g_variant_iter_init (&iter, udisks_mdraid_get_active_devices (udisks_mdraid));
    while (g_variant_iter_next (&iter, "(&oi@asta{sv})",
                                &disk_block_objpath,
                                &disk_slot,
                                &disk_states,
                                &disk_num_errors,
                                NULL))
    {
        UDisksObject *udisks_object;
        UDisksBlock *udisks_block;
        StorageObject *object;

        if ((udisks_object = udisks_client_peek_object (udisks_client, disk_block_objpath))
                && (udisks_block = udisks_object_peek_block (udisks_object))
                && (object = storage_provider_lookup_for_udisks_block (provider, udisks_block)))
        {
            g_variant_builder_add (&devices, "(oi@ast)",
                                   g_dbus_object_get_object_path (G_DBUS_OBJECT(object)),
                                   disk_slot,
                                   disk_states,
                                   disk_num_errors);
        }
    }
    cockpit_storage_mdraid_set_active_devices (iface, g_variant_builder_end (&devices));
}
Ejemplo n.º 2
0
static gboolean
walk_block_parents (UDisksClient *client,
                    GDBusObjectManager  *objman,
                    UDisksBlock *block,
                    ObjectWalker *walker,
                    gpointer user_data,
                    GError **error)
{
  /* Parents are
     - of a block that is a logical volume, the logical volume object
     - of a clear text device, the encrypted device.

     XXX - support the whole tree.
  */

  while (block)
    {
      const gchar *path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (block));
      LvmLogicalVolumeBlock *lvm_block =
        LVM_LOGICAL_VOLUME_BLOCK (g_dbus_object_manager_get_interface (objman, path,
                                                                       "com.redhat.lvm2.LogicalVolumeBlock"));

      const gchar *logical_volume_path =
        (lvm_block ? lvm_logical_volume_block_get_logical_volume (lvm_block) : "/");
      const gchar *crypto_path = udisks_block_get_crypto_backing_device (block);

      if (g_strcmp0 (logical_volume_path, "/") != 0)
        {
          gs_unref_object LvmObject *logical_volume_object =
            LVM_OBJECT (g_dbus_object_manager_get_object (objman, logical_volume_path));

          if (logical_volume_object)
            {
              if (!walker (client, G_DBUS_OBJECT (logical_volume_object), user_data, error))
                return FALSE;
            }
          block = NULL;
        }
      else if (g_strcmp0 (crypto_path, "/") != 0)
        {
          UDisksObject *crypto_object = udisks_client_peek_object (client, crypto_path);
          if (crypto_object)
            {
              if (!walker (client, G_DBUS_OBJECT (crypto_object), user_data, error))
                return FALSE;
            }
          block = udisks_object_peek_block (crypto_object);
        }
      else
        block = NULL;
    }

  return TRUE;
}
Ejemplo n.º 3
0
static void
provider_update_block (StorageProvider *provider,
                       const gchar *path)
{
  UDisksObject *udisks_object = udisks_client_peek_object (provider->udisks_client, path);
  if (udisks_object == NULL)
    return;

  UDisksBlock *udisks_block = udisks_object_peek_block (udisks_object);
  if (udisks_block == NULL)
    return;

  StorageObject *storage_object = storage_provider_lookup_for_udisks_block (provider, udisks_block);
  if (storage_object == NULL)
    return;

  CockpitStorageBlock *storage_block = cockpit_object_peek_storage_block (COCKPIT_OBJECT (storage_object));
  if (storage_block == NULL)
    return;

  storage_block_update (STORAGE_BLOCK (storage_block));
}