Re: lseek + read = ENOENT

2006-01-20 Thread Cliff Hones
Eric Blake wrote: >> [I wrote] >>This seems to be a bug in gcc. The off_t argument to lseek is a 64-bit >>type, but instead of being sign-extended to 64 bits, the value passed >>(-sizeof(data)) passed is only extended to 32-bits, so is actually >>+4294967292. [This is OT for Cygwin, and probabl

Re: lseek + read = ENOENT

2006-01-19 Thread Eric Blake
> This seems to be a bug in gcc. The off_t argument to lseek is a 64-bit > type, but instead of being sign-extended to 64 bits, the value passed > (-sizeof(data)) passed is only extended to 32-bits, so is actually > +4294967292. No, it is not a bug in gcc. Read a good book on C, please. > > I

Re: lseek + read = ENOENT

2006-01-19 Thread Eric Blake
> I cannot read the last 4-byte word in a file using lseek + read: > > /* file "foo" exists and is large enough - say, 4 MB */ > int fd = open("foo",O_RDONLY|O_BINARY); > uint32 data; > /* this succeeds and correctly returns the size of file "foo" minus 4 */ > lseek(fd,-sizeof(data),SEEK_EN

Re: lseek + read = ENOENT

2006-01-19 Thread Cliff Hones
Sam Steingold wrote: > I cannot read the last 4-byte word in a file using lseek + read: > > /* file "foo" exists and is large enough - say, 4 MB */ > int fd = open("foo",O_RDONLY|O_BINARY); > uint32 data; > /* this succeeds and correctly returns the size of file "foo" minus 4 */ > lseek(fd,-

lseek + read = ENOENT

2006-01-19 Thread Sam Steingold
I cannot read the last 4-byte word in a file using lseek + read: /* file "foo" exists and is large enough - say, 4 MB */ int fd = open("foo",O_RDONLY|O_BINARY); uint32 data; /* this succeeds and correctly returns the size of file "foo" minus 4 */ lseek(fd,-sizeof(data),SEEK_END); /* this ret