Skip to content

Commit

Permalink
udiskslinuxpartitiontable: Add state cleanup locking
Browse files Browse the repository at this point in the history
Rather advisory this alerts the state cleanup thread to avoid
touching this device.
  • Loading branch information
tbzatek committed Jan 9, 2022
1 parent 130aa8d commit 9c2263d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/udiskslinuxpartitiontable.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "udiskslinuxblock.h"
#include "udiskslinuxpartition.h"
#include "udiskssimplejob.h"
#include "udisksstate.h"

/**
* SECTION:udiskslinuxpartitiontable
Expand Down Expand Up @@ -261,6 +262,7 @@ create_partition (UDisksPartitionTable *table,
UDisksBlock *block = NULL;
UDisksObject *object = NULL;
UDisksDaemon *daemon = NULL;
UDisksState *state = NULL;
gchar *device_name = NULL;
WaitForPartitionData *wait_data = NULL;
UDisksObject *partition_object = NULL;
Expand All @@ -283,6 +285,10 @@ create_partition (UDisksPartitionTable *table,
}

daemon = udisks_linux_block_object_get_daemon (UDISKS_LINUX_BLOCK_OBJECT (object));
state = udisks_daemon_get_state (daemon);

udisks_linux_block_object_lock_for_cleanup (UDISKS_LINUX_BLOCK_OBJECT (object));
udisks_state_check_block (state, udisks_linux_block_object_get_device_number (UDISKS_LINUX_BLOCK_OBJECT (object)));

g_variant_lookup (options, "partition-type", "&s", &partition_type);

Expand Down Expand Up @@ -570,6 +576,10 @@ create_partition (UDisksPartitionTable *table,
out:
if (fd >= 0)
close (fd);
if (object != NULL)
udisks_linux_block_object_release_cleanup_lock (UDISKS_LINUX_BLOCK_OBJECT (object));
if (state != NULL)
udisks_state_check (state);
g_free (table_type);
g_free (wait_data);
g_clear_error (&error);
Expand Down

0 comments on commit 9c2263d

Please sign in to comment.