Mail Archives: cygwin/2002/10/20/07:04:10
Hi,
Some times ago, when I used the command 'du' to get the size of a directory,
I got a value that was in accordance with the value given by Windows.
However, it isn't the case anymore now; 'du' returns a size less than the
files space usage.
So I had a glance to the source code and I saw that the field 'st_blksize'
from the system call 'stat' was initialized with 'S_BLKSIZE' (which is a
macro set to 1024). But my filesystem uses 4096 bytes blocks. I looked at
the winsup cvs to see why it worked before; but unless I did a mistake, it
seems 'S_BLKSIZE' has always been here.
Why is this field not set to a proper value? One moment, I thought Windows
was returning a wrong value. But I tried with 'statfs' and the value was
correct. So maybe 'st_blksize' should be computed the same way than
'f_bsize'.
Regards,
Guillaume
PS: Since I'm not suscribed to this mailing-list, please cc me if you expect
an answer that cleanly inserts in a thread. Otherwise, I will follow the
discussion through the archive.
PPS: Here is an exemple to show the behavior difference between 'stat' and
'statfs'.
$ cat test.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
struct stat buf1;
struct statfs buf2;
stat(argv[1], &buf1);
statfs(argv[1],&buf2);
printf("st_blksize:\t%d\nf_bsize:\t%d\n", buf1.st_blksize, buf2.f_bsize);
return 0;
}
$ gcc test.c -o test
$ ./test test.c
st_blksize: 1024
f_bsize: 4096
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -