Skip to content

Commit b6e52e6

Browse files
committed
Fix file count with statfs
The 'f_files' member was incorrectly set to the count of inodes in use. It should be set to the maximum number of files that the file system can support. This incorrect calculation leads to unexpected behavior in programs that use statfs(2), such as 'df'. These programs may print negative values for the inodes used field, which is counterintuitive.
1 parent 0828258 commit b6e52e6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ static int simplefs_statfs(struct dentry *dentry, struct kstatfs *stat)
175175
stat->f_blocks = sbi->nr_blocks;
176176
stat->f_bfree = sbi->nr_free_blocks;
177177
stat->f_bavail = sbi->nr_free_blocks;
178-
stat->f_files = sbi->nr_inodes - sbi->nr_free_inodes;
178+
stat->f_files = sbi->nr_inodes;
179179
stat->f_ffree = sbi->nr_free_inodes;
180180
stat->f_namelen = SIMPLEFS_FILENAME_LEN;
181181

0 commit comments

Comments
 (0)