Пример #1
0
static gboolean
walk_logical_volume (GDBusObjectManager *objman,
                     LvmLogicalVolume *vol,
                     LogicalVolumeWalker *walker,
                     gpointer user_data,
                     GError **error)
{
  if (!walker (objman, vol, user_data, error))
    return FALSE;

  const gchar *vol_objpath = g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (vol)));
  LvmVolumeGroup *group = lvm_util_get_volume_group_for_logical_volume (objman, vol);
  GList *siblings = group ? lvm_util_get_logical_volumes_for_volume_group (objman, group) : NULL;
  gboolean ret = TRUE;

  for (GList *l = siblings; l; l = l->next)
    {
      LvmLogicalVolume *s = l->data;

      if ((g_strcmp0 (lvm_logical_volume_get_type_ (s), "snapshot") == 0
           && g_strcmp0 (lvm_logical_volume_get_origin (s), vol_objpath) == 0)
          || (g_strcmp0 (lvm_logical_volume_get_type_ (s), "thin") == 0
              && g_strcmp0 (lvm_logical_volume_get_thin_pool (s), vol_objpath) == 0))
        {
          if (!walk_logical_volume (objman, s, walker, user_data, error))
            {
              ret = FALSE;
              break;
            }
        }
    }

  g_list_free_full (siblings, g_object_unref);
  return ret;
}
static void hev_dbus_interface_test_method_call(GDBusConnection *connection,
			const gchar *sender, const gchar *object_path,
			const gchar *interface_name, const gchar *method_name,
			GVariant *parameters, GDBusMethodInvocation *invocation,
			gpointer user_data)
{
	HevDBusInterfaceTest *self = HEV_DBUS_INTERFACE_TEST(user_data);
	HevDBusObjectTest *obj = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	obj = HEV_DBUS_OBJECT_TEST(g_dbus_interface_get_object(G_DBUS_INTERFACE(self)));

	if(0 == g_strcmp0(method_name, "Set"))
	{
		const gchar *value = NULL;
		GVariant *variant = NULL;

		g_variant_get(parameters, "(&s)", &value);
		value = hev_dbus_object_test_set(obj, value);
		variant = g_variant_new("(s)", value);
		g_dbus_method_invocation_return_value(invocation, variant);
		g_variant_unref(variant);
	}
	else if(0 == g_strcmp0(method_name, "Get"))
	{
		const gchar *value = NULL;
		GVariant *variant = NULL;

		value = hev_dbus_object_test_get(obj);
		variant = g_variant_new("(s)", value);
		g_dbus_method_invocation_return_value(invocation, variant);
		g_variant_unref(variant);
	}
}
Пример #3
0
static gboolean
cleanup_logical_volume_walker (GDBusObjectManager *objman,
                               LvmLogicalVolume *logical_volume,
                               gpointer user_data,
                               GError **error)
{
  StorageProvider *provider = user_data;
  UDisksBlock *block = lvm_util_peek_block_for_logical_volume (storage_provider_get_lvm_object_manager (provider),
                                                               storage_provider_get_udisks_client (provider),
                                                               logical_volume);
  if (block)
    {
      /* The logical volume is active, let's clean it up by walking
         the tree of block devices hanging off of it.
       */
      return cleanup_block (provider, block, error);
    }
  else
    {
      /* The logical volume is inactive, let's clean it up by removing
         the remembered configs from its children.
      */
      LvmObject *object = LVM_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (logical_volume)));
      GList *remembered_configs = storage_provider_get_and_forget_remembered_configs
        (provider, g_dbus_object_get_object_path (G_DBUS_OBJECT (object)));
      for (GList *l = remembered_configs; l; l = l->next)
        {
          GVariant *config = l->data;
          storage_remove_config (provider, NULL, config);
        }
      g_list_free_full (remembered_configs, (GDestroyNotify)g_variant_unref);
      return TRUE;
    }
}
Пример #4
0
static void
on_job_completed (UDisksJob *job,
                  gboolean success,
                  const gchar *message,
                  gpointer user_data)
{
  StorageDaemon *self = STORAGE_DAEMON (user_data);
  GDBusObject *object;

  object = g_dbus_interface_get_object (G_DBUS_INTERFACE (job));
  g_assert (object != NULL);

  /* Unexport job */
  g_dbus_object_manager_server_unexport (self->object_manager,
                                         g_dbus_object_get_object_path (object));

  /* free the allocated job object */
  g_object_unref (job);

  /* returns the reference we took when connecting to the
   * UDisksJob::completed signal in storage_daemon_launch_{spawned,threaded}_job()
   * below
   */
  g_object_unref (self);

  g_assert (self->num_jobs > 0);
  self->num_jobs--;
  maybe_finished (self);
}
Пример #5
0
static gboolean
handle_add (CockpitMachines *object,
            GDBusMethodInvocation *invocation,
            const gchar *arg_address,
            const gchar *arg_host_key)
{
  GError *error = NULL;
  Machines *machines = MACHINES (object);
  Machine *machine;

  if (g_strcmp0 (arg_address, "") == 0)
    {
      error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
                           "IP address or host name cannot be empty.");
      g_dbus_method_invocation_take_error (invocation, error);
      return TRUE;
    }

  machine = machines_add (machines, arg_address, arg_host_key, &error);
  if (machine)
    {
      GDBusObject *obj = g_dbus_interface_get_object (G_DBUS_INTERFACE (machine));
      cockpit_machines_complete_add (object, invocation, g_dbus_object_get_object_path (obj));
    }
  else
    g_dbus_method_invocation_take_error (invocation, error);

  return TRUE;
}
Пример #6
0
static gboolean
on_account_handle_ensure_credentials (GoaAccount            *account,
                                      GDBusMethodInvocation *invocation,
                                      gpointer               user_data)
{
  GoaDaemon *daemon = GOA_DAEMON (user_data);
  GoaProvider *provider;
  GoaObject *object;

  object = GOA_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (account)));
  provider = goa_provider_get_for_provider_type (goa_account_get_provider_type (account));
  if (provider == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             GOA_ERROR,
                                             GOA_ERROR_FAILED,
                                             "Unsupported account type %s for id %s (no provider)",
                                             goa_account_get_provider_type (account),
                                             goa_account_get_id (account));
      goto out;
    }

  goa_provider_ensure_credentials (provider,
                                   object,
                                   NULL, /* GCancellable */
                                   (GAsyncReadyCallback) ensure_credentials_cb,
                                   ensure_data_new (daemon, object, invocation));

 out:
  return TRUE; /* invocation was handled */
}
Пример #7
0
static UDisksBlock *
peek_block_for_logical_volume (UDisksLogicalVolume *volume,
                               UDisksDaemon        *daemon)
{
  UDisksBlock *ret = NULL;
  GDBusObject *object;
  GList *l, *objects = NULL;
  UDisksBlockLVM2 *block_lvm2;

  object = g_dbus_interface_get_object (G_DBUS_INTERFACE (volume));
  if (object == NULL)
    goto out;

  objects = udisks_daemon_get_objects (daemon);
  for (l = objects; l != NULL; l = l->next)
    {
      block_lvm2 = udisks_object_peek_block_lvm2 (UDISKS_OBJECT(l->data));
      if (block_lvm2 &&
          g_strcmp0 (udisks_block_lvm2_get_logical_volume (block_lvm2),
                     g_dbus_object_get_object_path (object)) == 0)
        {
          ret = udisks_object_peek_block (UDISKS_OBJECT(l->data));
          goto out;
        }
    }

 out:
  g_list_free_full (objects, g_object_unref);
  return ret;
}
Пример #8
0
const gchar *
setting_get_object_path (Setting *setting)
{
  g_return_val_if_fail (IS_SETTING (setting), NULL);
  GDBusObject *object = NULL;
  object = g_dbus_interface_get_object (G_DBUS_INTERFACE (setting));
  return g_dbus_object_get_object_path (object);
}
Пример #9
0
static gboolean
teardown_logical_volume (UDisksLogicalVolume   *volume,
                         UDisksDaemon          *daemon,
                         GDBusMethodInvocation *invocation,
                         GVariant              *options,
                         GError               **error)
{
  GDBusObject *volume_object;
  UDisksObject *group_object;
  UDisksVolumeGroup *group;
  UDisksLogicalVolume *sibling_volume;
  GList *siblings;
  GList *l;

  if (!udisks_linux_logical_volume_teardown_block (volume,
                                                   daemon,
                                                   invocation,
                                                   options,
                                                   error))
    return FALSE;

  /* Recurse for pool members and snapshots.
   */

  volume_object = g_dbus_interface_get_object (G_DBUS_INTERFACE (volume));
  group_object = udisks_daemon_find_object (daemon, udisks_logical_volume_get_volume_group (volume));
  if (volume_object && group_object)
    {
      group = udisks_object_peek_volume_group (group_object);
      if (group)
        {
          siblings = udisks_linux_volume_group_get_logical_volumes (group, daemon);
          for (l = siblings; l; l = l->next)
            {
              sibling_volume = UDISKS_LOGICAL_VOLUME (l->data);
              if (g_strcmp0 (udisks_logical_volume_get_thin_pool (sibling_volume),
                             g_dbus_object_get_object_path (volume_object)) == 0 ||
                  g_strcmp0 (udisks_logical_volume_get_origin (sibling_volume),
                             g_dbus_object_get_object_path (volume_object)) == 0)
                {
                  if (!teardown_logical_volume (sibling_volume,
                                                daemon,
                                                invocation,
                                                options,
                                                error))
                    {
                      g_list_free_full (siblings, g_object_unref);
                      return FALSE;
                    }
                }
            }
          g_list_free_full (siblings, g_object_unref);
        }
    }

  return TRUE;
}
Пример #10
0
static gboolean
handle_delete_partition (CockpitStorageBlock *object,
                         GDBusMethodInvocation *invocation)
{
  StorageBlock *block = STORAGE_BLOCK(object);
  StorageProvider *provider = storage_object_get_provider (block->object);

  GError *error = NULL;

  if (!auth_check_sender_role (invocation, COCKPIT_ROLE_STORAGE_ADMIN))
    return TRUE;

  UDisksObject *udisks_object =
    (UDisksObject *) g_dbus_interface_get_object(G_DBUS_INTERFACE (block->udisks_block));
  if (udisks_object == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "No object!?");
      g_error_free (error);
      return TRUE;
    }

  UDisksPartition *part = udisks_object_peek_partition (udisks_object);
  if (part == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "Block device is not a partition");
      g_error_free (error);
      return TRUE;
    }

  if (!storage_cleanup_block (provider,
                              block->udisks_block,
                              &error)
      || !udisks_partition_call_delete_sync (part,
                                             g_variant_new ("a{sv}", NULL),
                                             NULL,
                                             &error))
    {
      g_dbus_error_strip_remote_error (error);
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "%s", error->message);
      g_error_free (error);
      return TRUE;
    }

  cockpit_storage_block_complete_delete_partition (object, invocation);
  return TRUE;
}
Пример #11
0
static gboolean
on_handle_remove_alpha (TestFrobber *frobber,
                        GDBusMethodInvocation *invocation,
                        gpointer user_data)
{
  TestObjectSkeleton *enclosing;
  enclosing = TEST_OBJECT_SKELETON (g_dbus_interface_get_object (G_DBUS_INTERFACE (frobber)));
  if (test_object_peek_alpha (TEST_OBJECT (enclosing)) != NULL)
    test_object_skeleton_set_alpha (enclosing, NULL);
  test_frobber_complete_add_alpha (frobber, invocation);
  return TRUE;
}
Пример #12
0
static UDisksBlock *
create_partition (StorageBlock *block,
                  guint64 offset,
                  guint64 size,
                  const gchar *type,
                  GError **error)
{
  UDisksObject *udisks_object =
    (UDisksObject *) g_dbus_interface_get_object (G_DBUS_INTERFACE (block->udisks_block));
  if (udisks_object == NULL)
    {
      g_set_error (error, COCKPIT_ERROR, COCKPIT_ERROR_FAILED,
                   "No object!?");
      return NULL;
    }

  UDisksPartitionTable *table = udisks_object_peek_partition_table (udisks_object);
  if (table == NULL)
    {
      g_set_error (error, COCKPIT_ERROR, COCKPIT_ERROR_FAILED,
                   "Block device has no partition table");
      return NULL;
    }

  gs_free gchar *part_object_path = NULL;

  if (!udisks_partition_table_call_create_partition_sync (table,
                                                          offset,
                                                          size,
                                                          type,
                                                          "",
                                                          g_variant_new ("a{sv}", NULL),
                                                          &part_object_path,
                                                          NULL,
                                                          error))
    return NULL;

  StorageProvider *provider = storage_object_get_provider (block->object);
  UDisksClient *client = storage_provider_get_udisks_client (provider);
  udisks_client_settle (client);

  gs_unref_object UDisksObject *partition_object =
      udisks_client_get_object (client, part_object_path);
  UDisksBlock *partition_block = udisks_object_peek_block (partition_object);
  if (partition_block == NULL)
    {
      g_set_error (error, COCKPIT_ERROR, COCKPIT_ERROR_FAILED,
                   "Partition has no associated block device");
      return NULL;
    }

  return partition_block;
}
Пример #13
0
static gboolean
handle_unlock (CockpitStorageBlock *object,
               GDBusMethodInvocation *invocation,
               const gchar *arg_passphrase)
{
  StorageBlock *block = STORAGE_BLOCK(object);
  GError *error = NULL;

  if (!auth_check_sender_role (invocation, COCKPIT_ROLE_STORAGE_ADMIN))
    return TRUE;

  UDisksObject *udisks_object =
    (UDisksObject *) g_dbus_interface_get_object(G_DBUS_INTERFACE (block->udisks_block));
  if (udisks_object == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "No object!?");
      g_error_free (error);
      return TRUE;
    }

  UDisksEncrypted *enc = udisks_object_peek_encrypted (udisks_object);
  if (enc == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "Block device is not encrypted");
      g_error_free (error);
      return TRUE;
    }

  if (!udisks_encrypted_call_unlock_sync (enc,
                                          arg_passphrase,
                                          g_variant_new ("a{sv}", NULL),
                                          NULL,
                                          NULL,
                                          &error))
    {
      g_dbus_error_strip_remote_error (error);
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "%s", error->message);
      g_error_free (error);
      return TRUE;
    }

  cockpit_storage_block_complete_unlock (object, invocation);
  return TRUE;
}
static gboolean
on_handle_get_password (GoaPasswordBased      *interface,
                        GDBusMethodInvocation *invocation,
                        const gchar           *id,
                        gpointer               user_data)
{
  GoaObject *object;
  GoaAccount *account;
  GoaProvider *provider;
  GError *error;
  GVariant *credentials;
  gchar *password;

  /* TODO: maybe log what app is requesting access */

  password = NULL;
  credentials = NULL;

  object = GOA_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (interface)));
  account = goa_object_peek_account (object);
  provider = goa_provider_get_for_provider_type (goa_account_get_provider_type (account));

  error = NULL;
  credentials = goa_utils_lookup_credentials_sync (provider,
                                                   object,
                                                   NULL, /* GCancellable* */
                                                   &error);
  if (credentials == NULL)
    {
      g_dbus_method_invocation_take_error (invocation, error);
      goto out;
    }

  if (!g_variant_lookup (credentials, "password", "s", &password))
    {
      g_dbus_method_invocation_return_error (invocation,
                                             GOA_ERROR,
                                             GOA_ERROR_FAILED, /* TODO: more specific */
                                             _("Did not find password with username `%s' in credentials"),
                                             id);
      goto out;
    }

  goa_password_based_complete_get_password (interface, invocation, password);

 out:
  g_free (password);
  if (credentials != NULL)
    g_variant_unref (credentials);
  g_object_unref (provider);
  return TRUE; /* invocation was handled */
}
Пример #15
0
static gboolean
handle_mount (CockpitStorageBlock *object,
              GDBusMethodInvocation *invocation)
{
  StorageBlock *block = STORAGE_BLOCK(object);
  GError *error = NULL;

  if (!auth_check_sender_role (invocation, COCKPIT_ROLE_STORAGE_ADMIN))
    return TRUE;

  UDisksObject *udisks_object =
    (UDisksObject *) g_dbus_interface_get_object(G_DBUS_INTERFACE (block->udisks_block));
  if (udisks_object == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "No object!?");
      g_error_free (error);
      return TRUE;
    }

  UDisksFilesystem *fsys = udisks_object_peek_filesystem (udisks_object);
  if (fsys == NULL)
    {
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "Block device is not a filesystem");
      g_error_free (error);
      return TRUE;
    }

  if (!udisks_filesystem_call_mount_sync (fsys,
                                          g_variant_new ("a{sv}", NULL),
                                          NULL,
                                          NULL,
                                          &error))
    {
      g_dbus_error_strip_remote_error (error);
      g_dbus_method_invocation_return_error (invocation,
                                             COCKPIT_ERROR,
                                             COCKPIT_ERROR_FAILED,
                                             "%s", error->message);
      g_error_free (error);
      return TRUE;
    }

  cockpit_storage_block_complete_mount (object, invocation);
  return TRUE;
}
Пример #16
0
void
setting_unexport (Setting *setting)
{
  g_return_if_fail (IS_SETTING (setting));

  GDBusObjectManagerServer *object_manager;
  GDBusObject *object;

  object_manager = daemon_get_object_manager (setting->daemon);

  object = g_dbus_interface_get_object (G_DBUS_INTERFACE (setting));
  if (object != NULL)
    g_dbus_object_manager_server_unexport (object_manager,
                                        g_dbus_object_get_object_path (object));
}
Пример #17
0
static void hev_dbus_interface_test_constructed(GObject *obj)
{
	GDBusObject *dbus_obj = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	G_OBJECT_CLASS(hev_dbus_interface_test_parent_class)->constructed(obj);

	dbus_obj = g_dbus_interface_get_object(G_DBUS_INTERFACE(obj));

	/* Connect object signals */
	g_signal_connect(G_OBJECT(dbus_obj), "notify::value",
				G_CALLBACK(hev_dbus_object_test_notify_value_handler), obj);
	g_signal_connect(G_OBJECT(dbus_obj), "changed",
				G_CALLBACK(hev_dbus_object_test_changed_handler), obj);
}
Пример #18
0
static void
user_removed (ActUserManager *um,
              ActUser *user,
              Accounts *accounts)
{
  GDBusObjectManagerServer *object_manager_server = daemon_get_object_manager (daemon_get ());

  Account *acc = g_hash_table_lookup (accounts->act_user_to_account, user);
  if (acc)
    {
      account_update (acc, NULL);
      g_dbus_object_manager_server_unexport (object_manager_server,
         g_dbus_object_get_object_path (g_dbus_interface_get_object (G_DBUS_INTERFACE (acc))));
      g_hash_table_remove (accounts->act_user_to_account, user);
    }
}
Пример #19
0
static gboolean
cleanup_block_walker (UDisksClient *client,
                      UDisksBlock *block,
                      gboolean is_leaf,
                      gpointer user_data,
                      GError **error)
{
  StorageProvider *provider = user_data;
  UDisksObject *object = UDISKS_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (block)));
  UDisksEncrypted *enc = udisks_object_peek_encrypted (object);

  if (enc)
    {
      UDisksBlock *cleartext = udisks_client_get_cleartext_block (client, block);
      if (cleartext)
        {
          /* The crypto backing device is unlocked and the cleartext
             device has been cleaned up.  Lock the backing device so
             that we can format or wipe it later.
          */
          if (enc && !udisks_encrypted_call_lock_sync (enc,
                                                       g_variant_new ("a{sv}", NULL),
                                                       NULL,
                                                       error))
            return FALSE;
        }
      else
        {
          /* The crypto backing device is locked and the cleartext
             device has not been cleaned up (since it doesn't exist).
             Remove its remembered configs.
          */
          GList *remembered_configs = storage_provider_get_and_forget_remembered_configs
              (provider, g_dbus_object_get_object_path (G_DBUS_OBJECT (object)));
          for (GList *l = remembered_configs; l; l = l->next)
            {
              GVariant *config = l->data;
              storage_remove_config (provider, block, config);
            }
          g_list_free_full (remembered_configs, (GDestroyNotify)g_variant_unref);
        }
    }

  storage_remove_config (provider, block, udisks_block_get_configuration (block));

  return TRUE;
}
Пример #20
0
void
storage_remember_block_configs (StorageProvider *provider,
                                UDisksBlock *block)
{
  GVariant *config = udisks_block_get_configuration (block);
  if (g_variant_n_children (config) > 0)
    {
      UDisksClient *client = storage_provider_get_udisks_client (provider);
      GDBusObjectManager *objman = storage_provider_get_lvm_object_manager (provider);
      GDBusObject *object = g_dbus_interface_get_object (G_DBUS_INTERFACE (block));
      struct RememberData data;
      data.provider = provider;
      data.child_path = g_dbus_object_get_object_path (object);
      data.config = config;
      walk_block_parents (client, objman, block, remember_configs, &data, NULL);
    }
}
Пример #21
0
static gboolean hev_dbus_interface_test_set_property(GDBusConnection *connection,
			const gchar *sender, const gchar *object_path,
			const gchar *interface_name, const gchar *property_name,
			GVariant *value, GError **error, gpointer user_data)
{
	GDBusObject *obj = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	obj = g_dbus_interface_get_object(G_DBUS_INTERFACE(user_data));
	if(0 == g_strcmp0(property_name, "Value"))
	  g_object_set(G_OBJECT(obj), "value", g_variant_get_string(value, NULL), NULL);
	else
	  return FALSE;

	return TRUE;
}
Пример #22
0
void
setting_export (Setting *setting)
{
  g_return_if_fail (IS_SETTING (setting));

  GDBusObjectManagerServer *object_manager;
  object_manager = daemon_get_object_manager (setting->daemon);

  if (g_dbus_interface_get_object (G_DBUS_INTERFACE (setting)) == NULL)
    {
      LoomObjectSkeleton *object = NULL;

      object = loom_object_skeleton_new ("/org/blackox/Loom/Setting");
      loom_object_skeleton_set_setting (object, LOOM_SETTING (setting));
      g_dbus_object_manager_server_export_uniquely (object_manager,
                                               G_DBUS_OBJECT_SKELETON (object));
      g_object_unref (object);
    }
}
Пример #23
0
static GVariant * hev_dbus_interface_test_get_properties(GDBusInterfaceSkeleton *skeleton)
{
	GDBusObject *obj = NULL;
	GVariantBuilder *builder = NULL;
	GVariant *variant = NULL;
	gchar *p = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	obj = g_dbus_interface_get_object(G_DBUS_INTERFACE(skeleton));
	g_object_get(G_OBJECT(obj), "value", &p, NULL);
	builder = g_variant_builder_new(G_VARIANT_TYPE_VARDICT);
	g_variant_builder_add(builder, "{sv}", "Value", g_variant_new_string(p));
	variant = g_variant_builder_end(builder);
	g_variant_builder_unref(builder);
	g_free(p);

	return variant;
}
Пример #24
0
static GVariant * hev_dbus_interface_test_get_property(GDBusConnection *connection,
			const gchar *sender, const gchar *object_path,
			const gchar *interface_name, const gchar *property_name,
			GError **error, gpointer user_data)
{
	GDBusObject *obj = NULL;
	GVariant *variant = NULL;

	g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__);

	obj = g_dbus_interface_get_object(G_DBUS_INTERFACE(user_data));
	if(0 == g_strcmp0(property_name, "Value"))
	{
		gchar *p = NULL;
		
		g_object_get(G_OBJECT(obj), "value", &p, NULL);
		variant = g_variant_new_string(p);
		g_free(p);
	}

	return variant;
}
Пример #25
0
static gboolean
walk_block (UDisksClient *client,
            UDisksBlock *block,
            BlockWalker *walker,
            gpointer user_data,
            GError **error)
{
  gboolean is_leaf = TRUE;

  UDisksObject *object = (UDisksObject *)g_dbus_interface_get_object (G_DBUS_INTERFACE(block));
  if (object != NULL)
    {
      // Recurse for all primary and extended partitions if this is a
      // partition table, or for all logical partitions if this is a
      // extended partition.

      UDisksPartitionTable *table;
      gboolean is_container;

      UDisksPartition *partition = udisks_object_peek_partition (object);
      if (partition && udisks_partition_get_is_container (partition))
        {
          table = udisks_client_get_partition_table (client, partition);
          is_container = TRUE;
        }
      else
        {
          table = udisks_object_peek_partition_table (object);
          is_container = FALSE;
        }

      if (table)
        {
          GList *ps, *l;
          ps = udisks_client_get_partitions (client, table);
          for (l = ps; l != NULL; l = l->next)
            {
              UDisksPartition *p = UDISKS_PARTITION (l->data);
              UDisksObject *o = (UDisksObject *) g_dbus_interface_get_object (G_DBUS_INTERFACE (p));
              UDisksBlock *b = o ? udisks_object_peek_block (o) : NULL;
              if (b && !is_container == !udisks_partition_get_is_contained (p))
                {
                  is_leaf = FALSE;
                  if (!walk_block (client, b, walker, user_data, error))
                    {
                      g_list_free_full (ps, g_object_unref);
                      return FALSE;
                    }
                }
            }
          g_list_free_full (ps, g_object_unref);
        }
    }

  gs_unref_object UDisksBlock *cleartext = udisks_client_get_cleartext_block (client, block);
  if (cleartext)
    {
      is_leaf = FALSE;
      if (!walk_block (client, cleartext, walker, user_data, error))
        return FALSE;
    }

  return walker (client, block, is_leaf, user_data, error);
}
Пример #26
0
static void
udisks_client_get_object_info_for_drive (UDisksClient     *client,
                                         UDisksDrive      *drive,
                                         UDisksPartition  *partition,
                                         UDisksObjectInfo *info)
{
  const gchar *vendor;
  const gchar *model;
  const gchar *media;
  const gchar *const *media_compat;
  gboolean media_available;
  gboolean media_removable;
  gint rotation_rate;
  guint64 size;
  gchar *size_str;
  guint n;
  GString *desc_str;
  DriveType desc_type;
  gchar *hyphenated_connection_bus;
  const gchar *connection_bus;
  UDisksBlock *block = NULL;
  gchar *s;
  const gchar *cs;
  UDisksBlock *block_for_partition = NULL;

  g_return_if_fail (UDISKS_IS_DRIVE (drive));

  size_str = NULL;

  vendor = udisks_drive_get_vendor (drive);
  model = udisks_drive_get_model (drive);
  size = udisks_drive_get_size (drive);
  media_removable = udisks_drive_get_media_removable (drive);
  media_available = udisks_drive_get_media_available (drive);
  rotation_rate = udisks_drive_get_rotation_rate (drive);
  if (size > 0)
    size_str = udisks_client_get_size_for_display (client, size, FALSE, FALSE);
  media = udisks_drive_get_media (drive);
  media_compat = udisks_drive_get_media_compatibility (drive);
  connection_bus = udisks_drive_get_connection_bus (drive);
  if (strlen (connection_bus) > 0)
    hyphenated_connection_bus = g_strdup_printf ("-%s", connection_bus);
  else
    hyphenated_connection_bus = g_strdup ("");

  /* Name is easy - that's just "$vendor $model" */
  if (strlen (vendor) == 0)
    vendor = NULL;
  if (strlen (model) == 0)
    model = NULL;
  info->name = g_strdup_printf ("%s%s%s",
                                vendor != NULL ? vendor : "",
                                vendor != NULL ? " " : "",
                                model != NULL ? model : "");

  desc_type = DRIVE_TYPE_UNSET;
  desc_str = g_string_new (NULL);
  for (n = 0; n < G_N_ELEMENTS (media_data) - 1; n++)
    {
      /* media_compat */
      if (strv_has (media_compat, media_data[n].id))
        {
          if (info->icon == NULL)
            info->icon = g_themed_icon_new_with_default_fallbacks (media_data[n].drive_icon);
          if (info->icon_symbolic == NULL)
            info->icon_symbolic = g_themed_icon_new_with_default_fallbacks (media_data[n].drive_icon_symbolic);
          if (strstr (desc_str->str, media_data[n].media_family) == NULL)
            {
              if (desc_str->len > 0)
                g_string_append (desc_str, "/");
              g_string_append (desc_str, g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_family));
            }
          desc_type = media_data[n].media_type;
        }

      if (media_removable && media_available)
        {
          /* media */
          if (g_strcmp0 (media, media_data[n].id) == 0)
            {
              if (info->media_description == NULL)
                {
                  switch (media_data[n].media_type)
                    {
                    case DRIVE_TYPE_UNSET:
                      g_assert_not_reached ();
                      break;
                    case DRIVE_TYPE_DRIVE:
                      /* Translators: Used to describe drive without removable media. The %s is the type, e.g. 'Thumb' */
                      info->media_description = g_strdup_printf (C_("drive-with-fixed-media", "%s Drive"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
                      break;
                    case DRIVE_TYPE_DISK:
                      /* Translators: Used to describe generic media. The %s is the type, e.g. 'Zip' or 'Floppy' */
                      info->media_description = g_strdup_printf (C_("drive-with-generic-media", "%s Disk"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
                      break;
                    case DRIVE_TYPE_CARD:
                      /* Translators: Used to describe flash media. The %s is the type, e.g. 'SD' or 'CompactFlash' */
                      info->media_description = g_strdup_printf (C_("flash-media", "%s Card"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
                      break;
                    case DRIVE_TYPE_DISC:
                      /* Translators: Used to describe optical discs. The %s is the type, e.g. 'CD-R' or 'DVD-ROM' */
                      info->media_description = g_strdup_printf (C_("optical-media", "%s Disc"), g_dpgettext2 (GETTEXT_PACKAGE, "media-type", media_data[n].media_name));
                      break;
                    }
                }
              if (info->media_icon == NULL)
                info->media_icon = g_themed_icon_new_with_default_fallbacks (media_data[n].media_icon);
              if (info->media_icon_symbolic == NULL)
                info->media_icon_symbolic = g_themed_icon_new_with_default_fallbacks (media_data[n].media_icon_symbolic);
            }
        }
    }

  switch (desc_type)
    {
    case DRIVE_TYPE_UNSET:
      if (media_removable)
        {
          if (size_str != NULL)
            {
              /* Translators: Used to describe a drive. The %s is the size, e.g. '20 GB' */
              info->description = g_strdup_printf (C_("drive-with-size", "%s Drive"), size_str);
            }
          else
            {
              /* Translators: Used to describe a drive we know very little about (removable media or size not known) */
              info->description = g_strdup (C_("generic-drive", "Drive"));
            }
        }
      else
        {
          if (rotation_rate == 0)
            {
              if (size_str != NULL)
                {
                  /* Translators: Used to describe a non-rotating drive (rotation rate either unknown
                   * or it's a solid-state drive). The %s is the size, e.g. '20 GB'.  */
                  info->description = g_strdup_printf (C_("disk-non-rotational", "%s Disk"), size_str);
                }
              else
                {
                  /* Translators: Used to describe a non-rotating drive (rotation rate either unknown
                   * or it's a solid-state drive). The drive is either using removable media or its
                   * size not known. */
                  info->description = g_strdup (C_("disk-non-rotational", "Disk"));
                }
            }
          else
            {
              if (size_str != NULL)
                {
                  /* Translators: Used to describe a hard-disk drive (HDD). The %s is the size, e.g. '20 GB'.  */
                  info->description = g_strdup_printf (C_("disk-hdd", "%s Hard Disk"), size_str);
                }
              else
                {
                  /* Translators: Used to describe a hard-disk drive (HDD) (removable media or size not known) */
                  info->description = g_strdup (C_("disk-hdd", "Hard Disk"));
                }
            }
        }
      break;

    case DRIVE_TYPE_CARD:
      /* Translators: Used to describe a card reader. The %s is the card type e.g. 'CompactFlash'.  */
      info->description = g_strdup_printf (C_("drive-card-reader", "%s Card Reader"), desc_str->str);
      break;

    case DRIVE_TYPE_DRIVE: /* explicit fall-through */
    case DRIVE_TYPE_DISK: /* explicit fall-through */
    case DRIVE_TYPE_DISC:
      if (!media_removable && size_str != NULL)
        {
          /* Translators: Used to describe drive. The first %s is the size e.g. '20 GB' and the
           * second %s is the drive type e.g. 'Thumb'.
           */
          info->description = g_strdup_printf (C_("drive-with-size-and-type", "%s %s Drive"), size_str, desc_str->str);
        }
      else
        {
          /* Translators: Used to describe drive. The first %s is the drive type e.g. 'Thumb'.
           */
          info->description = g_strdup_printf (C_("drive-with-type", "%s Drive"), desc_str->str);
        }
      break;
    }
  g_string_free (desc_str, TRUE);

  /* fallback for icon */
  if (info->icon == NULL)
    {
      if (media_removable)
        {
          s = g_strdup_printf ("drive-removable-media%s", hyphenated_connection_bus);
        }
      else
        {
          if (rotation_rate == 0)
            s = g_strdup_printf ("drive-harddisk-solidstate%s", hyphenated_connection_bus);
          else
            s = g_strdup_printf ("drive-harddisk%s", hyphenated_connection_bus);
        }
      info->icon = g_themed_icon_new_with_default_fallbacks (s);
      g_free (s);
    }
  /* fallback for icon_symbolic */
  if (info->icon_symbolic == NULL)
    {
      if (media_removable)
        {
          s = g_strdup_printf ("drive-removable-media%s-symbolic", hyphenated_connection_bus);
        }
      else
        {
          if (rotation_rate == 0)
            s = g_strdup_printf ("drive-harddisk-solidstate%s-symbolic", hyphenated_connection_bus);
          else
            s = g_strdup_printf ("drive-harddisk%s-symbolic", hyphenated_connection_bus);
        }
      info->icon_symbolic = g_themed_icon_new_with_default_fallbacks (s);
      g_free (s);
    }
  /* fallback for media_icon */
  if (media_removable && media_available && info->media_icon == NULL)
    {
      if (media_removable)
        {
          s = g_strdup_printf ("drive-removable-media%s", hyphenated_connection_bus);
        }
      else
        {
          if (rotation_rate == 0)
            s = g_strdup_printf ("drive-harddisk-solidstate%s", hyphenated_connection_bus);
          else
            s = g_strdup_printf ("drive-harddisk%s", hyphenated_connection_bus);
        }
      info->media_icon = g_themed_icon_new_with_default_fallbacks (s);
      g_free (s);
    }
  /* fallback for media_icon_symbolic */
  if (media_removable && media_available && info->media_icon_symbolic == NULL)
    {
      if (media_removable)
        {
          s = g_strdup_printf ("drive-removable-media%s-symbolic", hyphenated_connection_bus);
        }
      else
        {
          if (rotation_rate == 0)
            s = g_strdup_printf ("drive-harddisk-solidstate%s-symbolic", hyphenated_connection_bus);
          else
            s = g_strdup_printf ("drive-harddisk%s-symbolic", hyphenated_connection_bus);
        }
      info->media_icon_symbolic = g_themed_icon_new_with_default_fallbacks (s);
      g_free (s);
    }

  /* prepend a qualifier to the media description, based on the disc state */
  if (udisks_drive_get_optical_blank (drive))
    {
      /* Translators: String used for a blank disc. The %s is the disc type e.g. "CD-RW Disc" */
      s = g_strdup_printf (C_("optical-media", "Blank %s"), info->media_description);
      g_free (info->media_description);
      info->media_description = s;
    }
  else if (udisks_drive_get_optical_num_audio_tracks (drive) > 0 &&
           udisks_drive_get_optical_num_data_tracks (drive) > 0)
    {
      /* Translators: String used for a mixed disc. The %s is the disc type e.g. "CD-ROM Disc" */
      s = g_strdup_printf (C_("optical-media", "Mixed %s"), info->media_description);
      g_free (info->media_description);
      info->media_description = s;
    }
  else if (udisks_drive_get_optical_num_audio_tracks (drive) > 0 &&
           udisks_drive_get_optical_num_data_tracks (drive) == 0)
    {
      /* Translators: String used for an audio disc. The %s is the disc type e.g. "CD-ROM Disc" */
      s = g_strdup_printf (C_("optical-media", "Audio %s"), info->media_description);
      g_free (info->media_description);
      info->media_description = s;
    }

  /* Apply UDISKS_NAME, UDISKS_ICON_NAME, UDISKS_SYMBOLIC_ICON_NAME hints, if available */
  block = udisks_client_get_block_for_drive (client, drive, TRUE);
  if (block != NULL)
    {
      cs = udisks_block_get_hint_name (block);
      if (cs != NULL && strlen (cs) > 0)
        {
          g_free (info->description);
          g_free (info->media_description);
          info->description = g_strdup (cs);
          info->media_description = g_strdup (cs);
        }

      cs = udisks_block_get_hint_icon_name (block);
      if (cs != NULL && strlen (cs) > 0)
        {
          g_clear_object (&info->icon);
          g_clear_object (&info->media_icon);
          info->icon = g_themed_icon_new_with_default_fallbacks (cs);
          info->media_icon = g_themed_icon_new_with_default_fallbacks (cs);
        }

      cs = udisks_block_get_hint_symbolic_icon_name (block);
      if (cs != NULL && strlen (cs) > 0)
        {
          g_clear_object (&info->icon_symbolic);
          g_clear_object (&info->media_icon_symbolic);
          info->icon_symbolic = g_themed_icon_new_with_default_fallbacks (cs);
          info->media_icon_symbolic = g_themed_icon_new_with_default_fallbacks (cs);
        }
    }

  if (partition != NULL)
    {
      GDBusObject *object_for_partition;
      object_for_partition = g_dbus_interface_get_object (G_DBUS_INTERFACE (partition));
      if (object_for_partition != NULL)
        block_for_partition = udisks_object_peek_block (UDISKS_OBJECT (object_for_partition));
    }
  if (block_for_partition == NULL)
    block_for_partition = block;

  if (partition != NULL)
    {
      /* Translators: Used to describe a partition of a drive.
       *              The %d is the partition number.
       *              The %s is the description for the drive (e.g. "2 GB Thumb Drive").
       */
      s = g_strdup_printf (C_("part-drive", "Partition %d of %s"),
                           udisks_partition_get_number (partition), info->description);
      g_free (info->description);
      info->description = s;
    }

  /* calculate and set one-liner */
  if (block != NULL)
    {
      const gchar *drive_revision = udisks_drive_get_revision (drive);
      if (strlen (drive_revision) > 0)
        {
          /* Translators: String used for one-liner description of drive.
           *              The first %s is the description of the object (e.g. "80 GB Disk" or "Partition 2 of 2 GB Thumb Drive").
           *              The second %s is the name of the object (e.g. "INTEL SSDSA2MH080G1GC").
           *              The third %s is the fw revision (e.g "45ABX21").
           *              The fourth %s is the special device file (e.g. "/dev/sda").
           */
          info->one_liner = g_strdup_printf (C_("one-liner-drive", "%s — %s [%s] (%s)"),
                                             info->description,
                                             info->name,
                                             drive_revision,
                                             udisks_block_get_preferred_device (block_for_partition));
        }
      else
        {
          /* Translators: String used for one-liner description of drive w/o known fw revision.
           *              The first %s is the description of the object (e.g. "80 GB Disk").
           *              The second %s is the name of the object (e.g. "INTEL SSDSA2MH080G1GC").
           *              The third %s is the special device file (e.g. "/dev/sda").
           */
          info->one_liner = g_strdup_printf (C_("one-liner-drive", "%s — %s (%s)"),
                                             info->description,
                                             info->name,
                                             udisks_block_get_preferred_device (block_for_partition));
        }
    }

  g_free (hyphenated_connection_bus);
  g_free (size_str);

  info->sort_key = g_strdup_printf ("00_drive_%s", udisks_drive_get_sort_key (drive));

  g_clear_object (&block);
}
Пример #27
0
void
storage_block_update (StorageBlock *block)
{
  CockpitStorageBlock *iface = COCKPIT_STORAGE_BLOCK (block);
  StorageProvider *provider;
  UDisksClient *udisks_client;
  UDisksObject *udisks_object;
  UDisksBlock *udisks_block;
  UDisksPartition *udisks_partition = NULL;
  UDisksPartitionTable *udisks_partition_table = NULL;
  UDisksFilesystem *udisks_filesystem = NULL;
  UDisksPhysicalVolume *udisks_physical_volume = NULL;

  provider = storage_object_get_provider (block->object);
  udisks_client = storage_provider_get_udisks_client (provider);
  udisks_block = block->udisks_block;
  udisks_object = (UDisksObject *)g_dbus_interface_get_object (G_DBUS_INTERFACE (udisks_block));
  if (udisks_object != NULL)
    {
      udisks_partition = udisks_object_peek_partition (udisks_object);
      udisks_partition_table = udisks_object_peek_partition_table (udisks_object);
      udisks_filesystem = udisks_object_peek_filesystem (udisks_object);
      udisks_physical_volume = udisks_object_peek_physical_volume (udisks_object);
    }

  {
    gs_free gchar *d =
      g_filename_display_name (udisks_block_get_preferred_device (udisks_block));
    cockpit_storage_block_set_device (iface, d);
  }

  cockpit_storage_block_set_size       (iface, udisks_block_get_size (udisks_block));
  cockpit_storage_block_set_id_usage   (iface, udisks_block_get_id_usage   (udisks_block));
  cockpit_storage_block_set_id_type    (iface, udisks_block_get_id_type    (udisks_block));
  cockpit_storage_block_set_id_version (iface, udisks_block_get_id_version (udisks_block));
  cockpit_storage_block_set_id_label   (iface, udisks_block_get_id_label   (udisks_block));
  cockpit_storage_block_set_id_uuid    (iface, udisks_block_get_id_uuid    (udisks_block));

  if (udisks_partition == NULL)
    {
      cockpit_storage_block_set_partition_number (iface, 0);
      cockpit_storage_block_set_partition_table (iface, "/");
    }
  else
    {
      UDisksPartitionTable *table_for_partition;
      const gchar *objpath = "/";
      GDBusObject *o;
      UDisksBlock *b;
      StorageObject *so;

      table_for_partition = udisks_client_get_partition_table (udisks_client, udisks_partition);
      if (table_for_partition != NULL)
        {
          o = g_dbus_interface_get_object (G_DBUS_INTERFACE (table_for_partition));
          if (o != NULL)
            {
              b = udisks_object_peek_block (UDISKS_OBJECT (o));
              if (b != NULL)
                {
                  so = storage_provider_lookup_for_udisks_block (provider, b);
                  if (so != NULL)
                    {
                      objpath = g_dbus_object_get_object_path (G_DBUS_OBJECT (so));
                    }
                }
            }
        }
      cockpit_storage_block_set_partition_table (iface, objpath);
      cockpit_storage_block_set_partition_number (iface, udisks_partition_get_number (udisks_partition));
    }

  GVariantBuilder partitions;
  g_variant_builder_init (&partitions, G_VARIANT_TYPE ("a(otts)"));

  if (udisks_partition_table != NULL)
    {
      GList *ps, *l;
      ps = udisks_client_get_partitions (udisks_client, udisks_partition_table);
      for (l = ps; l != NULL; l = l->next)
        {
          UDisksPartition *p = UDISKS_PARTITION (l->data);
          GDBusObject *o;
          UDisksBlock *b;
          StorageObject *so;

          o = g_dbus_interface_get_object (G_DBUS_INTERFACE (p));
          if (o != NULL)
            {
              b = udisks_object_peek_block (UDISKS_OBJECT (o));
              if (b != NULL)
                {
                  so = storage_provider_lookup_for_udisks_block (provider, b);
                  if (so != NULL)
                    {
                      const gchar *type = "p";
                      if (udisks_partition_get_is_container (p))
                        type = "x";
                      else if (udisks_partition_get_is_contained (p))
                        type = "l";
                      g_variant_builder_add (&partitions, "(otts)",
                                             g_dbus_object_get_object_path (G_DBUS_OBJECT (so)),
                                             udisks_partition_get_offset (p),
                                             udisks_partition_get_size (p),
                                             type);
                    }
                }
            }
        }
      g_list_free_full (ps, g_object_unref);
      const gchar *type = udisks_partition_table_get_type_ (udisks_partition_table);
      if (type == NULL || type[0] == '\0')
        type = "unknown";
      cockpit_storage_block_set_partition_table_type (iface, type);
    }
  else
    cockpit_storage_block_set_partition_table_type (iface, "");

  cockpit_storage_block_set_partitions (iface, g_variant_builder_end (&partitions));

  cockpit_storage_block_set_drive
    (iface, storage_provider_translate_path (provider, udisks_block_get_drive (udisks_block)));
  cockpit_storage_block_set_crypto_backing_device
    (iface, storage_provider_translate_path (provider, udisks_block_get_crypto_backing_device (udisks_block)));
  cockpit_storage_block_set_mdraid
    (iface, storage_provider_translate_path (provider, udisks_block_get_mdraid (udisks_block)));
  cockpit_storage_block_set_mdraid_member
    (iface, storage_provider_translate_path (provider, udisks_block_get_mdraid_member (udisks_block)));

  if (udisks_filesystem)
    {
      const gchar *const *p = udisks_filesystem_get_mount_points (udisks_filesystem);
      gchar *u[g_strv_length ((gchar **)p) + 1];
      int i;
      for (i = 0; p[i]; i++)
        u[i] = g_filename_display_name (p[i]);
      u[i] = NULL;
      cockpit_storage_block_set_mounted_at (iface, (const gchar *const *)u);
      for (i = 0; u[i]; i++)
        g_free (u[i]);
    }

  GVariantIter iter;
  g_variant_iter_init (&iter, udisks_block_get_configuration (udisks_block));
  const gchar *type;
  GVariant *details;
  gboolean got_fstab = FALSE, got_crypttab = FALSE;
  while (g_variant_iter_next (&iter, "(&s*)", &type, &details))
    {
      if (strcmp (type, "fstab") == 0 && !got_fstab)
        {
          got_fstab = TRUE;
          const gchar *dir = variant_lookup (details, "dir");
          if (dir)
            {
              gs_free gchar *dir_display = g_filename_display_name (dir);
              cockpit_storage_block_set_mount_point (iface, dir_display);
            }
          const gchar *opts = variant_lookup (details, "opts");
          if (opts)
            {
              gs_free gchar *opts_locale = g_locale_to_utf8 (opts, -1, NULL, NULL, NULL);
              if (opts_locale)
                cockpit_storage_block_set_mount_options (iface, opts_locale);
              else
                g_warning ("Can't convert fstab options into UTF8");
            }
        }
      else if (strcmp (type, "crypttab") == 0 && !got_crypttab)
        {
          got_crypttab = TRUE;
          const gchar *opts = variant_lookup (details, "options");
          if (opts)
            {
              gs_free gchar *opts_locale = g_locale_to_utf8 (opts, -1, NULL, NULL, NULL);
              if (opts_locale)
                cockpit_storage_block_set_crypto_options (iface, opts_locale);
              else
                g_warning ("Can't convert crypttab options into UTF8");
            }
        }
      g_variant_unref (details);
    }

  cockpit_storage_block_set_logical_volume (iface,
     storage_provider_translate_path (provider,
                                      udisks_block_get_logical_volume (udisks_block)));

  if (udisks_physical_volume)
    {
      cockpit_storage_block_set_pv_group (iface,
         storage_provider_translate_path (provider,
                                          udisks_physical_volume_get_volume_group (udisks_physical_volume)));
      cockpit_storage_block_set_pv_size (iface, udisks_physical_volume_get_size (udisks_physical_volume));
      cockpit_storage_block_set_pv_free_size (iface, udisks_physical_volume_get_free_size (udisks_physical_volume));
    }
  else
    cockpit_storage_block_set_pv_group (iface, "/");
}