Skip to content

Commit f802ca4

Browse files
committed
udiskslinuxblock: Avoid re-reading partition table on a partition
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.
1 parent 6c4354a commit f802ca4

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/udiskslinuxblock.c

+22-11
Original file line numberDiff line numberDiff line change
@@ -3576,22 +3576,33 @@ udisks_linux_block_handle_format (UDisksBlock *block,
35763576
/* The mkfs program may not generate all the uevents we need - so explicitly
35773577
* trigger an event here
35783578
*/
3579-
if (fs_features && (fs_features->features & BD_FS_FEATURE_PARTITION_TABLE) == BD_FS_FEATURE_PARTITION_TABLE &&
3580-
!udisks_linux_block_object_reread_partition_table (UDISKS_LINUX_BLOCK_OBJECT (object), &error))
3579+
if (fs_features && (fs_features->features & BD_FS_FEATURE_PARTITION_TABLE) == BD_FS_FEATURE_PARTITION_TABLE)
35813580
{
3582-
udisks_warning ("%s", error->message);
3583-
g_clear_error (&error);
3581+
UDisksObject *partition_table_object;
3582+
3583+
/* If formatting a partition, re-read partition table on a parent device */
3584+
if (partition != NULL)
3585+
partition_table_object = udisks_daemon_find_object (daemon, udisks_partition_get_table (partition));
3586+
else
3587+
partition_table_object = g_object_ref (object);
3588+
3589+
if (partition_table_object != NULL)
3590+
{
3591+
if (!udisks_linux_block_object_reread_partition_table (UDISKS_LINUX_BLOCK_OBJECT (partition_table_object), &error))
3592+
{
3593+
udisks_warning ("%s", error->message);
3594+
g_clear_error (&error);
3595+
}
3596+
if (partition_table_object != object)
3597+
udisks_linux_block_object_trigger_uevent_sync (UDISKS_LINUX_BLOCK_OBJECT (partition_table_object),
3598+
UDISKS_DEFAULT_WAIT_TIMEOUT);
3599+
trigger_uevent_on_nested_partitions (daemon, UDISKS_LINUX_BLOCK_OBJECT (partition_table_object));
3600+
g_object_unref (partition_table_object);
3601+
}
35843602
}
35853603
udisks_linux_block_object_trigger_uevent_sync (UDISKS_LINUX_BLOCK_OBJECT (object_to_mkfs),
35863604
UDISKS_DEFAULT_WAIT_TIMEOUT);
35873605

3588-
/* In case a protective partition table was potentially created, trigger uevents
3589-
* on all nested partitions. */
3590-
if (fs_features && (fs_features->features & BD_FS_FEATURE_PARTITION_TABLE) == BD_FS_FEATURE_PARTITION_TABLE)
3591-
{
3592-
trigger_uevent_on_nested_partitions (daemon, UDISKS_LINUX_BLOCK_OBJECT (object));
3593-
}
3594-
35953606
/* Wait for the desired filesystem interface */
35963607
wait_data.object = object_to_mkfs;
35973608
wait_data.type = type;

0 commit comments

Comments
 (0)