<arg name="options" direction="in" type="a{sv}"/>
</method>
+ <!--
+ OpenForBackup:
+ @options: Options (currently unused except for <link linkend="udisks-std-options">standard options</link>).
+ @fd: An index for the returned file descriptor.
+
+ Gets a read-only file descriptor for the device intended for a
+ byte-by-byte imaging of the device. This can only be done if
+ the device is not already in use.
+ -->
+ <method name="OpenForBackup">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="1"/>
+ <arg name="options" direction="in" type="a{sv}"/>
+ <arg name="fd" direction="out" type="h"/>
+ </method>
+
</interface>
<!-- ********************************************************************** -->
udisks_block_call_format_finish
udisks_block_call_format_sync
udisks_block_complete_format
+udisks_block_call_open_for_backup
+udisks_block_call_open_for_backup_finish
+udisks_block_call_open_for_backup_sync
+udisks_block_complete_open
udisks_block_get_configuration
udisks_block_get_crypto_backing_device
udisks_block_get_device
</defaults>
</action>
+ <!-- Open a device for reading (for creating disk images) -->
+ <action id="org.freedesktop.udisks2.open-device">
+ <_description>Open a device</_description>
+ <_message>Authentication is required to open a device</_message>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
+ <action id="org.freedesktop.udisks2.open-device-system">
+ <_description>Open a system device</_description>
+ <_message>Authentication is required to open a device</_message>
+ <defaults>
+ <allow_any>auth_admin</allow_any>
+ <allow_inactive>auth_admin</allow_inactive>
+ <allow_active>auth_admin_keep</allow_active>
+ </defaults>
+ </action>
+
<!-- Manage system-wide configuration files such as /etc/fstab or
/etc/crypttab ... including files referenced by these files.
#include <mntent.h>
#include <glib/gstdio.h>
+#include <gio/gunixfdlist.h>
#include "udiskslogging.h"
#include "udiskslinuxblock.h"
/* ---------------------------------------------------------------------------------------------------- */
+static gboolean
+handle_open_for_backup (UDisksBlock *block,
+ GDBusMethodInvocation *invocation,
+ GUnixFDList *fd_list,
+ GVariant *options)
+{
+ UDisksObject *object;
+ UDisksDaemon *daemon;
+ const gchar *action_id;
+ const gchar *device;
+ GUnixFDList *out_fd_list = NULL;
+ gint fd;
+
+ object = UDISKS_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (block)));
+ daemon = udisks_linux_block_object_get_daemon (UDISKS_LINUX_BLOCK_OBJECT (object));
+
+ action_id = "org.freedesktop.udisks2.open-device";
+ if (udisks_block_get_hint_system (block))
+ action_id = "org.freedesktop.udisks2.open-device-system";
+
+ if (!udisks_daemon_util_check_authorization_sync (daemon,
+ object,
+ action_id,
+ options,
+ N_("Authentication is required to open $(udisks2.device) for backup"),
+ invocation))
+ goto out;
+
+
+ device = udisks_block_get_device (UDISKS_BLOCK (block));
+
+ fd = open (device, O_RDONLY | O_CLOEXEC | O_EXCL);
+ if (fd == -1)
+ {
+ g_dbus_method_invocation_return_error (invocation, UDISKS_ERROR, UDISKS_ERROR_FAILED,
+ "Error opening %s: %m", device);
+ goto out;
+ }
+
+ out_fd_list = g_unix_fd_list_new_from_array (&fd, 1);
+ udisks_block_complete_open_for_backup (block, invocation, out_fd_list, g_variant_new_handle (0));
+
+ out:
+ g_clear_object (&out_fd_list);
+ return TRUE; /* returning true means that we handled the method invocation */
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
static void
block_iface_init (UDisksBlockIface *iface)
{
iface->handle_remove_configuration_item = handle_remove_configuration_item;
iface->handle_update_configuration_item = handle_update_configuration_item;
iface->handle_format = handle_format;
+ iface->handle_open_for_backup = handle_open_for_backup;
}