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)); }
static void udisks_client_get_object_info_for_mdraid (UDisksClient *client, UDisksMDRaid *mdraid, UDisksPartition *partition, UDisksObjectInfo *info) { UDisksBlock *block = NULL; guint64 size = 0; gchar *size_str = NULL; const gchar *name; const gchar *level; gchar *s; block = udisks_client_get_block_for_mdraid (client, mdraid); size = udisks_mdraid_get_size (mdraid); if (size > 0) size_str = udisks_client_get_size_for_display (client, size, FALSE, FALSE); name = udisks_mdraid_get_name (mdraid); s = strstr (name, ":"); if (s != NULL && strlen (s) > 1) info->name = g_strdup (s + 1); else info->name = g_strdup (name); info->icon = g_themed_icon_new_with_default_fallbacks ("drive-multidisk"); info->icon_symbolic = g_themed_icon_new_with_default_fallbacks ("drive-multidisk-symbolic"); level = udisks_mdraid_get_level (mdraid); if (size_str != NULL) { /* Translators: Used to format the description for a RAID array. * The first %s is the size (e.g. '42.0 GB'). * The second %s is the level (e.g. 'RAID-5 Array'). */ info->description = g_strdup_printf (C_("mdraid-desc", "%s %s"), size_str, format_mdraid_level (level)); } else { info->description = g_strdup (format_mdraid_level (level)); } if (partition != NULL) { /* Translators: Used to describe a partition of a RAID Array. * The %d is the partition number. * The %s is the description for the drive (e.g. "2 TB RAID-5"). */ s = g_strdup_printf (C_("part-raid", "Partition %d of %s"), udisks_partition_get_number (partition), info->description); g_free (info->description); info->description = s; } if (strlen (info->name) > 0) { if (block != NULL) { /* Translators: String used for one-liner description of running RAID array. * The first %s is the array name (e.g. "AlphaGo"). * The second %s is the size and level (e.g. "2 TB RAID-5"). * The third %s is the special device file (e.g. "/dev/sda"). */ info->one_liner = g_strdup_printf (C_("one-liner-mdraid-running", "%s — %s (%s)"), info->name, info->description, udisks_block_get_preferred_device (block)); } else { /* Translators: String used for one-liner description of non-running RAID array. * The first %s is the array name (e.g. "AlphaGo"). * The second %s is the size and level (e.g. "2 TB RAID-5"). */ info->one_liner = g_strdup_printf (C_("one-liner-mdraid-not-running", "%s — %s"), info->name, info->description); } } else { if (block != NULL) { /* Translators: String used for one-liner description of running RAID array w/o a name. * The first %s is the array name (e.g. "AlphaGo"). * The second %s is the size and level (e.g. "2 TB RAID-5"). * The third %s is the special device file (e.g. "/dev/sda"). */ info->one_liner = g_strdup_printf (C_("one-liner-mdraid-no-name-running", "%s — %s"), info->description, udisks_block_get_preferred_device (block)); } else { /* Translators: String used for one-liner description of non-running RAID array w/o a name. * The first %s is the array name (e.g. "AlphaGo"). * The second %s is the size and level (e.g. "2 TB RAID-5"). */ info->one_liner = g_strdup_printf (C_("one-liner-mdraid-no-name-not-running", "%s"), info->description); } } g_clear_object (&block); info->sort_key = g_strdup_printf ("01_mdraid_%s_%d", udisks_mdraid_get_uuid (mdraid), partition != NULL ? udisks_partition_get_number (partition) : 0); }