Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: implements counting hardlinks for directories in spfs' fuse #1021

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions crates/spfs-vfs/src/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ impl Filesystem {
} else {
entry.size
};
let nlink: u32 = if entry.is_dir() {
// Directory has 2 hardlinks, one for . and one for the
// entry in its parent (..), plus one for each
// subdirectory. Symlinks do not count.
(entry.entries.iter().filter(|(_n, e)| e.is_dir()).count() + 2) as u32
} else {
// Everything else just has itself
1
};

FileAttr {
ino: entry.user_data,
size,
Expand All @@ -183,9 +193,7 @@ impl Filesystem {
ctime: self.fs_creation_time,
crtime: self.fs_creation_time,
kind,
// TODO: possibly return directory link count
// for all dirs below it (because of .. entries)
nlink: if entry.is_dir() { 2 } else { 1 },
nlink,
rdev: 0,
blksize: Self::BLOCK_SIZE,
flags: 0,
Expand Down
Loading