cezarmathe / btrfsutil-rs

Safe wrappers for libbtrfsutil.
https://crates.io/crates/btrfsutil
MIT License
6 stars 5 forks source link

Subvolume::get() works if given a path not at the root of a subvolume, contrary to comment #16

Open agrover opened 4 years ago

agrover commented 4 years ago
    /// Get a subvolume.
    ///
    /// The path must point to the root of a subvolume.

I tried calling Subvolume::get() with the path to a normal directory on a btrfs filesystem and it worked, contrary to what the above comment says. I'm not sure if the code, or the comment, needs to be changed.

cezarmathe commented 4 years ago

then it seems like btrfs_util_is_subvolume is returning true even if the path is not the root of a subvolume. I think one way to solve this issue is to cannonicalize the path and then check if stripping the last path component yields the same subvolume id, a different id, or returns either the NOT_SUBVOLUME or the NOT_BTRFS subvolume.