Bug 438378

Summary: RFE: support for FS_IOC_SETFSLABEL
Product: [Applications] partitionmanager Reporter: Chris Murphy <bugzilla>
Component: generalAssignee: Andrius Štikonas <andrius>
Status: RESOLVED WORKSFORME    
Severity: normal    
Priority: NOR    
Version First Reported In: Git   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Chris Murphy 2021-06-10 01:36:38 UTC
Partition Manager currently needs a file system umounted before it can change its label. Since umount isn't possible sometimes, e.g. sysroot, or any other in-use file system such as /home, the current implementation is limited.

This pair of ioctl's get and set labels on mounted filesystems. Currently f2fs, btrfs, xfs support it. I'm not sure if Partition Manager would use this via some other component, but I also file an RFE for udisks.

https://github.com/storaged-project/udisks/issues/895

https://man7.org/linux/man-pages/man2/ioctl_fslabel.2.html
Comment 1 Andrius Štikonas 2021-06-10 09:28:57 UTC
This has been supported for 4 years

https://invent.kde.org/system/kpmcore/-/commit/ff714f2f0ee650477b886f87507ccc5ee0c94247
Comment 2 Andrius Štikonas 2021-06-10 09:31:34 UTC
Note that Partition Manager does not use ioctl's directly. It runs command line tools (such as btrfs resize) that use these ioctls.
Partition Manager can't even use them directly because it runs as non-root user and only launches external tools as root.
Comment 3 Chris Murphy 2021-06-11 00:32:25 UTC
I did test it in Fedora and the file system was not renamed even though Partition Manager claims it was done. But that'd be a separate bug report; any tips on getting verbose information from partition manager to include in a bug report?

What I learned from both btrfs and xfs upstreams yesterday, is that both "xfs_io -c 'label'" and "btrfs filesystem label" commands use FS_IOC_SETFSLABEL. And testing each command on btrfs and xfs file systems, shows they work (interchangeable, there's no fs check so either command works on either file system). That's hilariously cool and confusing. I wonder if there might be a preference for a single util-linux command for this? There is fsadm, part of lvm tools, which supports file system resize for ext4 and xfs (not yet btrfs). In a way it'd be better suited for fsadm to gain btrfs resize; and gain label rename via FS_IOC_SETFSLABEL. And put fsadm into util-linux as a more generic tool for such tasks.
Comment 4 Andrius Štikonas 2021-06-11 09:06:55 UTC
(In reply to Chris Murphy from comment #3)
> I did test it in Fedora and the file system was not renamed even though
> Partition Manager claims it was done. But that'd be a separate bug report;
> any tips on getting verbose information from partition manager to include in
> a bug report?
> 
> What I learned from both btrfs and xfs upstreams yesterday, is that both
> "xfs_io -c 'label'" and "btrfs filesystem label" commands use
> FS_IOC_SETFSLABEL. And testing each command on btrfs and xfs file systems,
> shows they work (interchangeable, there's no fs check so either command
> works on either file system). That's hilariously cool and confusing. I
> wonder if there might be a preference for a single util-linux command for
> this? There is fsadm, part of lvm tools, which supports file system resize
> for ext4 and xfs (not yet btrfs). In a way it'd be better suited for fsadm
> to gain btrfs resize; and gain label rename via FS_IOC_SETFSLABEL. And put
> fsadm into util-linux as a more generic tool for such tasks.

you can run it with KPMCORE_DEBUG=1 and see which commands it ran. Then you can also see if those commands (e.g. btrfs rename) work from terminal rather than partition manager.
Comment 5 Andrius Štikonas 2021-06-11 09:08:10 UTC
> you can run it with KPMCORE_DEBUG=1 
sorry, I should have been clearer and mentioned that run it with that environmental variable, e.g. start it as

KPMCORE_DEBUG=1 partitionmanager