Opened 11 years ago

Last modified 11 years ago

#351 new defect

linux/x8632 %stat lossage

Reported by: rme Owned by: gb
Priority: minor Milestone:
Component: Runtime (threads, GC) Version:
Keywords: linux Cc:

Description

Create a big sparse file, e.g., with

    int fd = open("sparse", O_CREAT|O_RDWR, 0666);
    pos = lseek(fd, 4294967296LL, SEEK_END);
    write(fd, "a", 1);
    close(fd);

(%stat "/path/to/sparse") returns NIL.

It looks like we try to do something funky in %%stat to deal with Linux, but maybe we need to turn up the funk a little more.

Change History (1)

comment:2 Changed 11 years ago by gb

I stepped through the C library code. It looks like it did some sort of internal syscall, then crapped out in something called xstat32_conv() (having noticed that it couldn't represent the file's size correctly.)

I think that this means that we have to use stat64 structs (and call fstat6/stat64/lstat64) on Linux.

I don't know whether the PPC Linux version is also broken in this regard; it'd be a little surprising if it wasn't (though maybe that didn't show up when we did the syscall ourselves.)

From what I can tell, on all other platforms the 'size' field in whatever stat structure we're using is always 64 bits wide, though some platforms offer a stat64 structure with a wider inode field.

I tend to think that we should just use the "most 64-bit versions available" on all platforms. The code's already unreadable, and it can't get much less readable just by changing this.

Note: See TracTickets for help on using tickets.