Avoid using tune.exfat on a mounted exFAT file system

Using GParted to display a mounted exFAT file system results in this
partition warning:
    exfatprogs version : 1.2.4

    open failed : /dev/sdb1, Device or resource busy

This is because tune.exfat fails when attempting to query a mounted file
system.

When unmounted tune.exfat works:
    # mkfs.exfat -L test-label /dev/sdb1
    # tune.exfat -l /dev/sdb1
    exfatprogs version : 1.2.4
    label: test-label
    # tune.exfat -i /dev/sdb1
    exfatprogs version : 1.2.4
    volume serial : 0xefaf7e93

But when mounted tune.exfat fails:
    # mount /dev/sdb1 /mnt/1
    # tune.exfat -l /dev/sdb1
    exfatprogs version : 1.2.4
    open failed : /dev/sdb1, Device or resource busy
    # echo $?
    255
    # tune.exfat -i /dev/sdb1
    exfatprogs version : 1.2.4
    open failed : /dev/sdb1, Device or resource busy

Where as blkid succeeds:
    # blkid /dev/sdb1
    /dev/sdb1: LABEL="test-label" UUID="EFAF-7E93" BLOCK_SIZE="512" TYPE="exfat" PARTUUID="11a7a9eb-680b-4c90-982a-73f671e67e4f"

This failure case must have been missed when exFAT support was first
added [1][2] because re-testing it now back on Fedora 33 does show the
error.  Anyway fix this by just not attempting to read the file system
label or serial number in the file system specific methods while its
mounted.  GParted will fall back to reading the label from the blkid
populated FS_Info cache.  See
GParted_Core::set_partition_label_and_uuid() for details.  The serial
number is already read from the cache first, falling back to the file
system specific method second.

[1] bd386f445d
    Add exFAT support (!30)
[2] Add exFAT support
    https://gitlab.gnome.org/GNOME/gparted/-/merge_requests/30
This commit is contained in:
Mike Fleetwood 2024-08-04 12:34:06 +01:00
parent 344e03439e
commit 945cf70ff5
1 changed files with 8 additions and 0 deletions

View File

@ -171,6 +171,10 @@ bool exfat::create(const Partition& new_partition, OperationDetail& operationdet
void exfat::read_label(Partition& partition) void exfat::read_label(Partition& partition)
{ {
if (partition.busy)
// Running tune.exfat on a mounted file system fails so don't try.
return;
exit_status = Utils::execute_command("tune.exfat -l " + Glib::shell_quote(partition.get_path()), exit_status = Utils::execute_command("tune.exfat -l " + Glib::shell_quote(partition.get_path()),
output, error, true); output, error, true);
if (exit_status != 0) if (exit_status != 0)
@ -196,6 +200,10 @@ bool exfat::write_label(const Partition& partition, OperationDetail& operationde
void exfat::read_uuid(Partition& partition) void exfat::read_uuid(Partition& partition)
{ {
if (partition.busy)
// Running tune.exfat on a mounted file system fails so don't try.
return;
exit_status = Utils::execute_command("tune.exfat -i " + Glib::shell_quote(partition.get_path()), exit_status = Utils::execute_command("tune.exfat -i " + Glib::shell_quote(partition.get_path()),
output, error, true); output, error, true);
if (exit_status != 0) if (exit_status != 0)