fstat64 filesize problem

Vidar Hoel vhoel99 at grm.hia.no
Wed Feb 12 23:50:52 PST 2003


Hi,

To illustrate my problem, I have created a little program to open one
file:

#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

int main(int argc, char **argv) {
    int file;
    struct stat buf;
    if(argc<2) {
	printf("Usage: %s <filename>\n",argv[0]);
	return 1;
    }
    file = open(argv[1], O_RDONLY);
    fstat(file, &buf);
    printf("Filesize: %ld\n", %buf.st_size);
    return 0;
}

When I run this on several different boxes with strace (strace ./stat
stat.c), I get this output:

open("stat.c", O_RDONLY)                = 3
fstat64(3, {st_mode=S_IFREG|0600, st_size=362, ...}) = 0

And the value of st_size is correct, the file is 362 bytes long.

But, when I do the exact same on my LFS-box, this is the output:

open("stat.c", O_RDONLY)                = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=17592186044416, ...}) = 0

As you can see, the st_size is way off. But the output from my program
is correct. But some other programs (like metacity) will complain
(about empty XML-files), so this is a problem for me.

I have tried to recompile both gcc, glibc and strace. I have tried to
recompile reiserfsprogs without optimizations, to create a new
partition with both ext3 and reiserfs to see of that helped, but no.

Does anyone have an idea what is wrong, or what I might do to get this
fixed? Anything will be appreciated!

BTW: The only main difference between my test-machines: The LFS-box
uses DevFS, but I can hardly think that make a difference..

--
Vidar Hoel - vhoel99 at grm.hia.no
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list