pub const BTRFS_ROOT_DIR: u64 = 256;
pub const FUSE_ROOT: u64 = 1;
#[must_use]
pub fn fuse_to_btrfs(ino: u64) -> u64 {
match ino {
FUSE_ROOT | BTRFS_ROOT_DIR => BTRFS_ROOT_DIR,
other => other,
}
}
#[must_use]
pub fn btrfs_to_fuse(objectid: u64) -> u64 {
if objectid == BTRFS_ROOT_DIR {
FUSE_ROOT
} else {
objectid
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn root_swap_round_trips() {
assert_eq!(fuse_to_btrfs(FUSE_ROOT), BTRFS_ROOT_DIR);
assert_eq!(btrfs_to_fuse(BTRFS_ROOT_DIR), FUSE_ROOT);
}
#[test]
fn other_inodes_pass_through() {
for ino in [257u64, 1024, 1 << 40] {
assert_eq!(fuse_to_btrfs(ino), ino);
assert_eq!(btrfs_to_fuse(ino), ino);
}
}
}