On Wed, Oct 18, 2023 at 5:47 PM Kent Overstreet <[email protected]> wrote: > So, in that case, you just need a single bit reported via stat() or > statx(). > > Unfortunately, I don't see a flags field in struct statx...
A single bit from somewhere would do it. BTRFS's approach is pretty close to ideal. A BTRFS subvolume can be identified as follows: 1) Is the entry a directory? 2) Is the inode 256? 3) Is the filesystem type BTRFS? 1 and 2 are readily available in `ls`. They are provided by stat(), and `ls` already calls stat() for every entry. If a directory has an inode of 256, then a single call to statfs() can determine whether or not the filesystem is BTRFS, simultaneously determining whether or not the directory itself is a subvolume. `ls` does allow for one (or several?) additional function call(s) to assist with colorization in some cases. This is done to color files with capabilities, for example. ZFS is almost as good. A ZFS subvolume (actually called a "filesystem") has a low inode that is often 34. But it is not guaranteed to always be 34, unfortunately. Source: https://github.com/openzfs/zfs/discussions/15192 Cheers, Parke
