<!-- ************************************************************ -->
+ <method name="LinuxLvm2VGSetName">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="uuid" direction="in" type="s">
+ <doc:doc><doc:summary>The UUID of the volume group to set the name for.</doc:summary></doc:doc>
+ </arg>
+ <arg name="name" direction="in" type="s">
+ <doc:doc><doc:summary>The new name for the volume group.</doc:summary></doc:doc>
+ </arg>
+
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Sets the name for a volume group.
+ </doc:para>
+ </doc:description>
+ <doc:permission>
+ The caller will need the following PolicyKit authorization:
+ <doc:list>
+ <doc:item>
+ <doc:term>org.freedesktop.udisks.linux-lvm2</doc:term>
+ <doc:definition>
+ Needed to configured Linux LVM2 devices.
+ </doc:definition>
+ </doc:item>
+ </doc:list>
+ </doc:permission>
+ <doc:errors>
+ <doc:error name="&ERROR_NOT_AUTHORIZED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
+ <doc:error name="&ERROR_BUSY;">if one of the given components are busy</doc:error>
+ <doc:error name="&ERROR_FAILED;">if the operation failed</doc:error>
+ <doc:error name="&ERROR_CANCELLED;">if the job was cancelled</doc:error>
+ </doc:errors>
+ </doc:doc>
+ </method>
+
+ <!-- ************************************************************ -->
+
+ <method name="LinuxLvm2LVSetName">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="group_uuid" direction="in" type="s">
+ <doc:doc><doc:summary>The UUID of the volume group for the logical volume.</doc:summary></doc:doc>
+ </arg>
+ <arg name="uuid" direction="in" type="s">
+ <doc:doc><doc:summary>The UUID of the logical volume to set the name for.</doc:summary></doc:doc>
+ </arg>
+ <arg name="name" direction="in" type="s">
+ <doc:doc><doc:summary>The new name for the logical volume.</doc:summary></doc:doc>
+ </arg>
+
+ <doc:doc>
+ <doc:description>
+ <doc:para>
+ Sets the name for a logical volume.
+ </doc:para>
+ </doc:description>
+ <doc:permission>
+ The caller will need the following PolicyKit authorization:
+ <doc:list>
+ <doc:item>
+ <doc:term>org.freedesktop.udisks.linux-lvm2</doc:term>
+ <doc:definition>
+ Needed to configured Linux LVM2 devices.
+ </doc:definition>
+ </doc:item>
+ </doc:list>
+ </doc:permission>
+ <doc:errors>
+ <doc:error name="&ERROR_NOT_AUTHORIZED;">if the caller lacks the appropriate PolicyKit authorization</doc:error>
+ <doc:error name="&ERROR_BUSY;">if one of the given components are busy</doc:error>
+ <doc:error name="&ERROR_FAILED;">if the operation failed</doc:error>
+ <doc:error name="&ERROR_CANCELLED;">if the job was cancelled</doc:error>
+ </doc:errors>
+ </doc:doc>
+ </method>
+
+ <!-- ************************************************************ -->
+
<method name="LinuxLvm2LVStart">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg name="group_uuid" direction="in" type="s">
{
const gchar *group_uuid = user_data_elements[0];
const gchar *uuid = user_data_elements[1];
- const gchar *lv_name;
+ gchar *lv_name;
/* TODO: use options */
//gchar **options = user_data_elements[2];
guint n;
n = 0;
argv[n++] = "lvchange";
argv[n++] = "-ay";
- argv[n++] = (gchar *) lv_name;
+ argv[n++] = lv_name;
argv[n++] = NULL;
if (!job_new (context, "LinuxLvm2LVStart", TRUE, NULL, argv, NULL, linux_lvm2_lv_start_completed_cb, FALSE, NULL, NULL))
}
out:
- ;
+ g_free (lv_name);
}
gboolean
/*--------------------------------------------------------------------------------------------------------------*/
+
+static void
+linux_lvm2_vg_set_name_completed_cb (DBusGMethodInvocation *context,
+ Device *device,
+ gboolean job_was_cancelled,
+ int status,
+ const char *stderr,
+ const char *stdout,
+ gpointer user_data)
+{
+ if (WEXITSTATUS (status) == 0 && !job_was_cancelled)
+ {
+ dbus_g_method_return (context);
+ }
+ else
+ {
+ if (job_was_cancelled)
+ {
+ throw_error (context, ERROR_CANCELLED, "Job was cancelled");
+ }
+ else
+ {
+ throw_error (context,
+ ERROR_FAILED,
+ "Error setting name for LVM2 Volume Group: vgrename exited with exit code %d: %s",
+ WEXITSTATUS (status),
+ stderr);
+ }
+ }
+}
+
+static void
+daemon_linux_lvm2_vg_set_name_authorized_cb (Daemon *daemon,
+ Device *device,
+ DBusGMethodInvocation *context,
+ const gchar *action_id,
+ guint num_user_data,
+ gpointer *user_data_elements)
+{
+ const gchar *uuid = user_data_elements[0];
+ const gchar *new_name = user_data_elements[1];
+ const gchar *vg_name;
+ guint n;
+ gchar *argv[10];
+
+ /* Unfortunately vgchange does not (yet - file a bug) accept UUIDs - so find the VG name for this
+ * UUID by looking at PVs
+ */
+
+ vg_name = find_lvm2_vg_name_for_uuid (daemon, uuid);
+ if (vg_name == NULL)
+ {
+ throw_error (context, ERROR_FAILED, "Cannot find VG with UUID `%s'", uuid);
+ goto out;
+ }
+
+ n = 0;
+ argv[n++] = "vgrename";
+ argv[n++] = (gchar *) vg_name;
+ argv[n++] = (gchar *) new_name;
+ argv[n++] = NULL;
+
+ if (!job_new (context, "LinuxLvm2VGSetName", TRUE, NULL, argv, NULL, linux_lvm2_vg_set_name_completed_cb, FALSE, NULL, NULL))
+ {
+ goto out;
+ }
+
+ out:
+ ;
+}
+
+gboolean
+daemon_linux_lvm2_vg_set_name (Daemon *daemon,
+ const gchar *uuid,
+ const gchar *new_name,
+ DBusGMethodInvocation *context)
+{
+ daemon_local_check_auth (daemon,
+ NULL,
+ "org.freedesktop.udisks.linux-lvm2",
+ "LinuxLvm2VGSetName",
+ TRUE,
+ daemon_linux_lvm2_vg_set_name_authorized_cb,
+ context,
+ 2,
+ g_strdup (uuid),
+ g_free,
+ g_strdup (new_name),
+ g_free);
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static void
+linux_lvm2_lv_set_name_completed_cb (DBusGMethodInvocation *context,
+ Device *device,
+ gboolean job_was_cancelled,
+ int status,
+ const char *stderr,
+ const char *stdout,
+ gpointer user_data)
+{
+ if (WEXITSTATUS (status) == 0 && !job_was_cancelled)
+ {
+ dbus_g_method_return (context);
+ }
+ else
+ {
+ if (job_was_cancelled)
+ {
+ throw_error (context, ERROR_CANCELLED, "Job was cancelled");
+ }
+ else
+ {
+ throw_error (context,
+ ERROR_FAILED,
+ "Error setting name for LVM2 Volume Group: lvrename exited with exit code %d: %s",
+ WEXITSTATUS (status),
+ stderr);
+ }
+ }
+}
+
+static void
+daemon_linux_lvm2_lv_set_name_authorized_cb (Daemon *daemon,
+ Device *device,
+ DBusGMethodInvocation *context,
+ const gchar *action_id,
+ guint num_user_data,
+ gpointer *user_data_elements)
+{
+ const gchar *group_uuid = user_data_elements[0];
+ const gchar *uuid = user_data_elements[1];
+ const gchar *new_name = user_data_elements[2];
+ const gchar *vg_name;
+ gchar *lv_name;
+ guint n;
+ gchar *argv[10];
+
+ /* Unfortunately lvchange does not (yet - file a bug) accept UUIDs - so find the LV name for this
+ * UUID by looking at PVs
+ */
+
+ lv_name = NULL;
+
+ vg_name = find_lvm2_vg_name_for_uuid (daemon, group_uuid);
+ if (vg_name == NULL)
+ {
+ throw_error (context, ERROR_FAILED, "Cannot find VG with UUID `%s'", group_uuid);
+ goto out;
+ }
+
+ lv_name = find_lvm2_lv_name_for_uuids (daemon, group_uuid, uuid);
+ if (lv_name == NULL)
+ {
+ throw_error (context, ERROR_FAILED, "Cannot find LV with UUID `%s'", uuid);
+ goto out;
+ }
+
+ n = 0;
+ argv[n++] = "lvrename";
+ argv[n++] = (gchar *) vg_name;
+ argv[n++] = lv_name;
+ argv[n++] = (gchar *) new_name;
+ argv[n++] = NULL;
+
+ if (!job_new (context, "LinuxLvm2LVSetName", TRUE, NULL, argv, NULL, linux_lvm2_lv_set_name_completed_cb, FALSE, NULL, NULL))
+ {
+ goto out;
+ }
+
+ out:
+ g_free (lv_name);
+}
+
+gboolean
+daemon_linux_lvm2_lv_set_name (Daemon *daemon,
+ const gchar *group_uuid,
+ const gchar *uuid,
+ const gchar *new_name,
+ DBusGMethodInvocation *context)
+{
+ daemon_local_check_auth (daemon,
+ NULL,
+ "org.freedesktop.udisks.linux-lvm2",
+ "LinuxLvm2LVSetName",
+ TRUE,
+ daemon_linux_lvm2_lv_set_name_authorized_cb,
+ context,
+ 3,
+ g_strdup (group_uuid),
+ g_free,
+ g_strdup (uuid),
+ g_free,
+ g_strdup (new_name),
+ g_free);
+
+ return TRUE;
+}