summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2011-08-01 13:04:10 -0400
committerDavid Zeuthen <davidz@redhat.com>2011-08-01 13:04:10 -0400
commit863ba00ed3935bdbd79db4d6d870a1a4a65fb524 (patch)
tree2b0508117575ddce9f91979b7a2d9fa1fb30c815
parentf7c4029ab1fc4a46e6bdfcd17e42166daeb84087 (diff)
Move Linux swapspace implementation into separate type
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--doc/udisks2-docs.xml1
-rw-r--r--doc/udisks2-sections.txt13
-rw-r--r--doc/udisks2.types1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/udisksdaemontypes.h3
-rw-r--r--src/udiskslinuxblock.c134
6 files changed, 22 insertions, 131 deletions
diff --git a/doc/udisks2-docs.xml b/doc/udisks2-docs.xml
index 6214b57..657d59e 100644
--- a/doc/udisks2-docs.xml
+++ b/doc/udisks2-docs.xml
@@ -177,6 +177,7 @@
<xi:include href="xml/udiskslinuxdrive.xml"/>
<xi:include href="xml/udiskslinuxfilesystem.xml"/>
<xi:include href="xml/udiskslinuxencrypted.xml"/>
+ <xi:include href="xml/udiskslinuxswapspace.xml"/>
<xi:include href="xml/udiskslinuxloop.xml"/>
<xi:include href="xml/udisksmount.xml"/>
<xi:include href="xml/udisksmountmonitor.xml"/>
diff --git a/doc/udisks2-sections.txt b/doc/udisks2-sections.txt
index 8d0171c..ac56ef7 100644
--- a/doc/udisks2-sections.txt
+++ b/doc/udisks2-sections.txt
@@ -281,6 +281,7 @@ udisks_cleanup_add_loop
udisks_cleanup_ignore_loop
udisks_cleanup_remove_loop
udisks_cleanup_unignore_loop
+udisks_cleanup_has_loop
<SUBSECTION Standard>
UDISKS_TYPE_CLEANUP
UDISKS_CLEANUP
@@ -326,6 +327,18 @@ udisks_linux_encrypted_get_type
</SECTION>
<SECTION>
+<FILE>udiskslinuxswapspace</FILE>
+UDisksLinuxSwapspace
+udisks_linux_swapspace_new
+<SUBSECTION Standard>
+UDISKS_LINUX_SWAPSPACE
+UDISKS_IS_LINUX_SWAPSPACE
+UDISKS_TYPE_LINUX_SWAPSPACE
+<SUBSECTION Private>
+udisks_linux_swapspace_get_type
+</SECTION>
+
+<SECTION>
<FILE>UDisksObject</FILE>
<TITLE>UDisksObject</TITLE>
UDisksObject
diff --git a/doc/udisks2.types b/doc/udisks2.types
index 44c5d02..2e023c3 100644
--- a/doc/udisks2.types
+++ b/doc/udisks2.types
@@ -14,6 +14,7 @@ udisks_linux_provider_get_type
udisks_persistent_store_get_type
udisks_linux_filesystem_get_type
udisks_linux_encrypted_get_type
+udisks_linux_swapspace_get_type
udisks_linux_loop_get_type
udisks_linux_manager_get_type
udisks_cleanup_get_type
diff --git a/src/Makefile.am b/src/Makefile.am
index a32269a..3f0e108 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,6 +50,7 @@ libudisks_daemon_la_SOURCES = \
udiskslinuxblock.h udiskslinuxblock.c \
udiskslinuxfilesystem.h udiskslinuxfilesystem.c \
udiskslinuxencrypted.h udiskslinuxencrypted.c \
+ udiskslinuxswapspace.h udiskslinuxswapspace.c \
udiskslinuxloop.h udiskslinuxloop.c \
udiskslinuxdrive.h udiskslinuxdrive.c \
udiskslinuxmanager.h udiskslinuxmanager.c \
diff --git a/src/udisksdaemontypes.h b/src/udisksdaemontypes.h
index 53182ba..526e078 100644
--- a/src/udisksdaemontypes.h
+++ b/src/udisksdaemontypes.h
@@ -73,6 +73,9 @@ typedef struct _UDisksLinuxLoop UDisksLinuxLoop;
struct _UDisksLinuxManager;
typedef struct _UDisksLinuxManager UDisksLinuxManager;
+struct _UDisksLinuxSwapspace;
+typedef struct _UDisksLinuxSwapspace UDisksLinuxSwapspace;
+
/**
* UDisksThreadedJobFunc:
* @job: A #UDisksThreadedJob.
diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c
index 71a12ec..845ead4 100644
--- a/src/udiskslinuxblock.c
+++ b/src/udiskslinuxblock.c
@@ -38,6 +38,7 @@
#include "udiskslinuxdrive.h"
#include "udiskslinuxfilesystem.h"
#include "udiskslinuxencrypted.h"
+#include "udiskslinuxswapspace.h"
#include "udiskslinuxloop.h"
#include "udiskspersistentstore.h"
#include "udiskslinuxprovider.h"
@@ -834,125 +835,6 @@ filesystem_update (UDisksLinuxBlock *block,
/* ---------------------------------------------------------------------------------------------------- */
/* org.freedesktop.UDisks.Swapspace */
-static void
-swapspace_start_on_job_completed (UDisksJob *job,
- gboolean success,
- const gchar *message,
- gpointer user_data)
-{
- GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
- UDisksSwapspace *swapspace;
- swapspace = UDISKS_SWAPSPACE (g_dbus_method_invocation_get_user_data (invocation));
- if (success)
- udisks_swapspace_complete_start (swapspace, invocation);
- else
- g_dbus_method_invocation_return_error (invocation,
- UDISKS_ERROR,
- UDISKS_ERROR_FAILED,
- "Error activating swap: %s",
- message);
-}
-
-static gboolean
-swapspace_handle_start (UDisksSwapspace *swapspace,
- GDBusMethodInvocation *invocation,
- GVariant *options,
- gpointer user_data)
-{
- UDisksObject *object;
- UDisksDaemon *daemon;
- UDisksBlockDevice *block;
- UDisksBaseJob *job;
-
- object = UDISKS_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (swapspace)));
- daemon = udisks_linux_block_get_daemon (UDISKS_LINUX_BLOCK (object));
- block = udisks_object_peek_block_device (object);
-
- if (!udisks_daemon_util_check_authorization_sync (daemon,
- object,
- "org.freedesktop.udisks2.manage-swapspace",
- options,
- N_("Authentication is required to activate swapspace on $(udisks2.device)"),
- invocation))
- goto out;
-
- job = udisks_daemon_launch_spawned_job (daemon,
- NULL, /* cancellable */
- NULL, /* input_string */
- "swapon %s",
- udisks_block_device_get_device (block));
- g_signal_connect (job,
- "completed",
- G_CALLBACK (swapspace_start_on_job_completed),
- invocation);
-
- out:
- return TRUE;
-}
-
-static void
-swapspace_stop_on_job_completed (UDisksJob *job,
- gboolean success,
- const gchar *message,
- gpointer user_data)
-{
- GDBusMethodInvocation *invocation = G_DBUS_METHOD_INVOCATION (user_data);
- UDisksSwapspace *swapspace;
- swapspace = UDISKS_SWAPSPACE (g_dbus_method_invocation_get_user_data (invocation));
- if (success)
- udisks_swapspace_complete_start (swapspace, invocation);
- else
- g_dbus_method_invocation_return_error (invocation,
- UDISKS_ERROR,
- UDISKS_ERROR_FAILED,
- "Error deactivating swap: %s",
- message);
-}
-
-static gboolean
-swapspace_handle_stop (UDisksSwapspace *swapspace,
- GDBusMethodInvocation *invocation,
- GVariant *options,
- gpointer user_data)
-{
- UDisksObject *object;
- UDisksDaemon *daemon;
- UDisksBlockDevice *block;
- UDisksBaseJob *job;
-
- object = UDISKS_OBJECT (g_dbus_interface_get_object (G_DBUS_INTERFACE (swapspace)));
- daemon = udisks_linux_block_get_daemon (UDISKS_LINUX_BLOCK (object));
- block = udisks_object_peek_block_device (object);
-
- /* Now, check that the user is actually authorized to stop the swap space.
- *
- * TODO: want nicer authentication message + special treatment if the
- * uid that locked the device (e.g. w/o -others).
- */
- if (!udisks_daemon_util_check_authorization_sync (daemon,
- object,
- "org.freedesktop.udisks2.manage-swapspace",
- options,
- N_("Authentication is required to deactivate swapspace on $(udisks2.device)"),
- invocation))
- goto out;
-
- job = udisks_daemon_launch_spawned_job (daemon,
- NULL, /* cancellable */
- NULL, /* input_string */
- "swapoff %s",
- udisks_block_device_get_device (block));
- g_signal_connect (job,
- "completed",
- G_CALLBACK (swapspace_stop_on_job_completed),
- invocation);
-
- out:
- return TRUE;
-}
-
-/* ---------------------------------------------------------------------------------------------------- */
-
static gboolean
swapspace_check (UDisksLinuxBlock *block)
{
@@ -974,17 +856,7 @@ swapspace_check (UDisksLinuxBlock *block)
static void
swapspace_connect (UDisksLinuxBlock *block)
{
- /* indicate that we want to handle the method invocations in a thread */
- g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (block->iface_swapspace),
- G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
- g_signal_connect (block->iface_swapspace,
- "handle-start",
- G_CALLBACK (swapspace_handle_start),
- NULL);
- g_signal_connect (block->iface_swapspace,
- "handle-stop",
- G_CALLBACK (swapspace_handle_stop),
- NULL);
+ /* do nothing */
}
static void
@@ -1132,7 +1004,7 @@ udisks_linux_block_uevent (UDisksLinuxBlock *block,
update_iface (block, action, filesystem_check, NULL, filesystem_update,
UDISKS_TYPE_LINUX_FILESYSTEM, &block->iface_filesystem);
update_iface (block, action, swapspace_check, swapspace_connect, swapspace_update,
- UDISKS_TYPE_SWAPSPACE_SKELETON, &block->iface_swapspace);
+ UDISKS_TYPE_LINUX_SWAPSPACE, &block->iface_swapspace);
update_iface (block, action, encrypted_check, encrypted_connect, encrypted_update,
UDISKS_TYPE_LINUX_ENCRYPTED, &block->iface_encrypted);
update_iface (block, action, loop_check, loop_connect, loop_update,