On 09/03/2026 1.48 pm, Pádraig Brady wrote:
On 09/03/2026 11:02, Mark Harmstone wrote:
Use the STATX_SUBVOL mask to request the stx_subvol field from
statx(), and detect subvolume roots by comparing a child directory's
subvolume ID with its parent's.  When the IDs differ, the directory
is a subvolume root and is coloured using the new 'sv' indicator
(default: cyan on blue, 36;34).

Thanks Padraig.

Thank you for taking the time to supply a patch.
I'm not 100% convinced of the need though because:

- why would one color subvolume points differently to say mount points

Well, FWIW, I think having mount points in a different colour *would* be a useful feature.

This is borne out of frustration about not being able to easily see which directories are normal directories and which are actually subvols. Only subvolumes are snapshottable, so it's easy to set things up and only realize when it comes to e.g. doing backups that you've done it the wrong way. And because snapshotting isn't recursive, it's also useful to be able to see that a particular directory won't be subject to your normal backup mechanism.

The only way to recognize a subvol at the moment is to either a) stat it, and know that "Inode: 256" means it's a subvol, or b) do `btrfs subvol list`, but that's not user-friendly and requires root.

- adding colors to ls isn't generally extendable. It quickly gets confusing

If you want to make it so that subvols are normally indistinguishable from normal directories but that this can be overridden by an environment variable, I'm happy with that.

- statx_subvol means something different on XFS
   (I think it just extends the inode space there)

You might be right, but I've not heard that before. Doing `git grep STATX_SUBVOL` in the kernel doesn't show any matches in fs/xfs.

- this is really only applicable to BTRFS right?

And bcachefs, for what it's worth. I don't know what ZFS does. But btrfs and its subvolumes have been around for nearly 20 years now, even if the statx functionality has been around for a lot less than that.

- Might a tool like findmnt be more appropriate for functionality like this

That sounds like a bit like the aforementioned `btrfs subvol list`. The difference is because subvolumes are very cheap to create, unlike mount points they can number in the hundreds or thousands, and having to search through that is no fun. And if a directory is getting missed in a backup because it's actually a subvol, this doesn't help unless you suspect that to begin with.

thanks,
Padraig


Reply via email to