Skip to content

Commit

Permalink
udiskslinuxblock: Avoid re-reading partition table on a partition
Browse files Browse the repository at this point in the history
In case a protective partition table is created by a particular
mkfs tool, avoid issuing BLKRRPART on a partition block device
and find a parent device that is supposed to hold a partition table.
  • Loading branch information
tbzatek committed Feb 3, 2022
1 parent 96aa065 commit fd3045c
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/udiskslinuxblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -3435,22 +3435,33 @@ udisks_linux_block_handle_format (UDisksBlock *block,
/* The mkfs program may not generate all the uevents we need - so explicitly
* trigger an event here
*/
if (udisks_linux_fsinfo_creates_protective_parttable (type) &&
!udisks_linux_block_object_reread_partition_table (UDISKS_LINUX_BLOCK_OBJECT (object), &error))
if (udisks_linux_fsinfo_creates_protective_parttable (type))
{
udisks_warning ("%s", error->message);
g_clear_error (&error);
UDisksObject *partition_table_object;

/* If formatting a partition, re-read partition table on a parent device */
if (partition != NULL)
partition_table_object = udisks_daemon_find_object (daemon, udisks_partition_get_table (partition));
else
partition_table_object = g_object_ref (object);

if (partition_table_object != NULL)
{
if (!udisks_linux_block_object_reread_partition_table (UDISKS_LINUX_BLOCK_OBJECT (partition_table_object), &error))
{
udisks_warning ("%s", error->message);
g_clear_error (&error);
}
if (partition_table_object != object)
udisks_linux_block_object_trigger_uevent_sync (UDISKS_LINUX_BLOCK_OBJECT (partition_table_object),
UDISKS_DEFAULT_WAIT_TIMEOUT);
trigger_uevent_on_nested_partitions (daemon, UDISKS_LINUX_BLOCK_OBJECT (partition_table_object));
g_object_unref (partition_table_object);
}
}
udisks_linux_block_object_trigger_uevent_sync (UDISKS_LINUX_BLOCK_OBJECT (object_to_mkfs),
UDISKS_DEFAULT_WAIT_TIMEOUT);

/* In case a protective partition table was potentially created, trigger uevents
* on all nested partitions. */
if (udisks_linux_fsinfo_creates_protective_parttable (type))
{
trigger_uevent_on_nested_partitions (daemon, UDISKS_LINUX_BLOCK_OBJECT (object));
}

/* Wait for the desired filesystem interface */
wait_data->object = object_to_mkfs;
filesystem_object = udisks_daemon_wait_for_object_sync (daemon,
Expand Down

0 comments on commit fd3045c

Please sign in to comment.