I have a intel box running redhat 8.I am trying to use large file support in ext3 but have hit the following snag. I have a file that was created using lfs : rw-r--r-- 1 amitm amitm 2147491330 Nov 13 10:16 /home/amitm/storage/cam_n2_q1/atvdatacam_n2_q1.dat I write a simple program to do the basic file I/O but I hit a snag doing the seek. int main(void) { int fd; int result; fd = open("/home/amitm/storage/cam_n2_q1/atvdatacam_n2_q1.dat",O_RDONLY); if (fd < 0) { printf("error opening file errno = %d\n",errno); exit(-1); } result = lseek64(fd,2147483650,SEEK_SET); if (result < 0) { printf("error seeking file errno = %d\n",errno); exit(-1); } return 0; } I build the code like this: gcc -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -c -o seektest.o seektest.c seektest.c: In function `main': seektest.c:21: warning: decimal constant is so large that it is unsigned gcc -o seektest seektest.o Now running seektest I get the following error: -bash-2.05b$ ./seektest error seeking file errno = 0 Any ideas what is going on ? Best Wishes Amit
On Nov 13, 2003 16:29 -0800, amitm@atvideo.com wrote:> I have a intel box running redhat 8.I am trying to use large file > support in ext3 but have hit the following snag. > I have a file that was created using lfs : > > rw-r--r-- 1 amitm amitm 2147491330 Nov 13 10:16 > /home/amitm/storage/cam_n2_q1/atvdatacam_n2_q1.dat > > I write a simple program to do the basic file I/O but I hit a snag doing > the seek. > > int main(void) > { > int fd; > int result; > > fd = > open("/home/amitm/storage/cam_n2_q1/atvdatacam_n2_q1.dat",O_RDONLY);O_LARGEFILE Cheers, Andreas -- Andreas Dilger http://sourceforge.net/projects/ext2resize/ http://www-mddsp.enel.ucalgary.ca/People/adilger/
Hi, On Fri, 2003-11-14 at 00:29, amitm@atvideo.com wrote:> rw-r--r-- 1 amitm amitm 2147491330 Nov 13 10:16 > /home/amitm/storage/cam_n2_q1/atvdatacam_n2_q1.dat > > I write a simple program to do the basic file I/O but I hit a snag doing > the seek. > > int main(void) > { > int fd; > int result;...> result = lseek64(fd,2147483650,SEEK_SET);Umm, lseek64 returns a 64-bit result. "result" is a 32-bit variable. This is *precisely* the sort of programming error which resulted in the LFS spec disabling the opening of >2GB files in the first place. Any applications assuming that an off_t fits in an int will break if off_t for the file is larger than 2GB. Try off_t or loff_t as the type for "result" and see if that works any better! --Stephen
Hi Stephen, I found the bug in the code yesterday and made it into a 64bit type. The program works fine with the change. Thanks for your input. Best Wishes Amit Stephen C. Tweedie wrote:>Hi, > >On Fri, 2003-11-14 at 00:29, amitm@atvideo.com wrote: > > > >>rw-r--r-- 1 amitm amitm 2147491330 Nov 13 10:16 >>/home/amitm/storage/cam_n2_q1/atvdatacam_n2_q1.dat >> >>I write a simple program to do the basic file I/O but I hit a snag doing >>the seek. >> >>int main(void) >>{ >> int fd; >> int result; >> >> >... > > >> result = lseek64(fd,2147483650,SEEK_SET); >> >> > >Umm, lseek64 returns a 64-bit result. "result" is a 32-bit variable. > >This is *precisely* the sort of programming error which resulted in the >LFS spec disabling the opening of >2GB files in the first place. Any >applications assuming that an off_t fits in an int will break if off_t >for the file is larger than 2GB. > >Try off_t or loff_t as the type for "result" and see if that works any >better! > >--Stephen > >. > > >