btrfs-progs icon indicating copy to clipboard operation
btrfs-progs copied to clipboard

allow to print flags of subvolumes

Open aschnell opened this issue 11 months ago • 2 comments

Allow to print flags, so far only readonly, of subvolumes when using the 'btrfs subvolume list' command.

The use case is to avoid multiple calls to 'btrfs subvolume show' to get the information which snbk (snapper backup tool) is doing right now.

aschnell avatar Jan 16 '25 13:01 aschnell

The readonly is the only flag settable by the ioctl. For the list command update I considered also the received status, is-snapshot. If there's something more in the future sticking to the full words (readonly) in the output would become unfeasible. When it's used win the line output it's among the words, in the tabular output it misalignes the colums, but this is a minor problem.

263     1137755 256             -       @/boot/grub2/i386-pc
264     1720129 256             -       @/.snapshots
265     1720128 264             -       @/.snapshots/1/snapshot
18124   1713353 264             readonly        @/.snapshots/17866/snapshot
18125   1713355 264             readonly        @/.snapshots/17867/snapshot

As this is behind the option it's expected that the applications using it will understand the output, so this should be OK.

The question I still have is how to format it, this is for the original list command where I don't want to touch the output formatting, but this kind of minor extension is probably safe regarding compatibility. Moreover the new list command is not ready yet. I'll give it another thought and merge this PR eventually.

kdave avatar Jan 28 '25 13:01 kdave

Yes, the alignment is broken. That is partly also the case for the some extra UUID options (e.g. -u) where the header is not aligned with the content. I would add a width entry in btrfs_list_columns to fix all that but I would fear breaking existing parsers.

aschnell avatar Jan 28 '25 14:01 aschnell