statvfs returns invalid information
0
votes
0
answers
554
views
My eMMC partition is ext4 formatted and has about 100MB. When I issue statvfs() on that partition, I get huge return value for f_blocks field of struct statvfs.
struct statvfs {
unsigned long f_bsize; /* file system block size */
unsigned long f_frsize; /* fragment size */
fsblkcnt_t f_blocks; /* size of fs in f_frsize units */
fsblkcnt_t f_bfree; /* # free blocks */
fsblkcnt_t f_bavail; /* # free blocks for non-root */
fsfilcnt_t f_files; /* # inodes */
fsfilcnt_t f_ffree; /* # free inodes */
fsfilcnt_t f_favail; /* # free inodes for non-root */
unsigned long f_fsid; /* file system ID */
unsigned long f_flag; /* mount flags */
unsigned long f_namemax; /* maximum filename length */
};
For your reference, above is the struct statvfs.
The value printed for the field f_blocks is 18446744073659310077 which is a huge one considering my partition is 100MB. df command also returns used and size of 16Z!
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk2p4 16Z 16Z 79M 100% /data
Any idea what could be wrong? fsck on the partition succeeds. Not sure if there's a problem in the super block or what? Below is the code for your reference.
if (statvfs_works ())
{
struct statvfs vfsd;
if (statvfs (file, &vfsd) fsu_blocks = PROPAGATE_ALL_ONES (vfsd.f_blocks);
....
}
I am badly stuck and need to understand why the used and size field in df command returns value of 16Z. Any pointers would be greatly appreciated.
Update with more info======================================
Output from /proc/partitions is as follows:
179 3 102400 mmcblk2p4
strace reports the below output:
statfs64("/data", 88, {f_type="EXT2_SUPER_MAGIC", f_bsize=1024, f_blocks=18446744073659310077, f_bfree=87628, f_bavail=80460, f_files=25688, f_ffree=25189, f_fsid={-1446355608, 1063639410}, f_namelen=255, f_frsize=1024, f_flags=4128}) = 0
As can be seen f_blocks is a huge number. what could this mean? My kernel is 4.9.31. How do I get past this issue and make df report the correct output?
The output dumpe2fs returns the following
Block count: 102400
Reserved block count: 5120
Overhead blocks: 50343939
The overhead blocks is a huge number. What could this mean?
Regards
Asked by Embedded Enthusiast
(21 rep)
Mar 21, 2022, 03:45 PM
Last activity: Mar 22, 2022, 01:15 PM
Last activity: Mar 22, 2022, 01:15 PM