Bug#308072: kernel-image-2.6.8-2-386: statfs returns wrong values for FAT fs
Package: kernel-image-2.6.8-2-386
Version: 2.6.8-13
Severity: important
I have a 250Gb external USB 2.0 hard-drive formatted with FAT32 and "df"
always reports 64Kb of used space on it, although it contains a couple of
gigabytes.
At first I thought the problem might be in "df" itself, but the following
test code proves the statfs function is to blame. The values returned are
incorrect.
However, it does report correct values for another FAT32 partition I have
(70Gb).
----------- statfs.c -----------
#include <sys/vfs.h>
int main(int argc, char *argv[])
{
struct statfs stats;
long used;
int kib;
if (argc < 2) {
printf("USAGE: %s <mountpoint>\n", argv[0]);
return 1;
}
statfs(argv[1], &stats);
used = stats.f_blocks - stats.f_bfree;
printf("f_bsize = %ld blocks\nf_blocks = %ld blocks\nf_bfree = %ld blocks\nused = %ld blocks\n",
stats.f_bsize, stats.f_blocks, stats.f_bfree, used);
kib = stats.f_bsize / 1024;
printf("total = %ld KiB\nfree = %ld KiB\nused = %ld KiB\n",
kib * stats.f_blocks,
kib * stats.f_bfree,
kib * used);
return 0;
}
----------- eof - statfs.c -----------
-- System Information:
Debian Release: 3.1
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.8-2-386
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)
Versions of packages kernel-image-2.6.8-2-386 depends on:
ii coreutils [fileutils] 5.2.1-2 The GNU core utilities
ii initrd-tools 0.1.78 tools to create initrd image for p
ii module-init-tools 3.2-pre1-2 tools for managing Linux kernel mo
-- no debconf information
Reply to: