From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2a7e42db0b3166d28ea649564939c354.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199611071853.MAA10870@gloria.cord.edu> Date: Thu, 7 Nov 1996 19:58:14 +0100 (MET) From: Christian Hardmeier Subject: Re: 64 Bits from Larry McVoy In-Reply-To: <9611061220.AA06870@scooter> On Wed, 6 Nov 1996, Jim Nance wrote: > First I want to thank all the people who pointed out that I don't know how > to use open(). I have patched the program call it correctly, and have > included the errors I am seeing. Also, I am running on an Alpha, not an > intel machine. I would expect compleatly different behavior on an intel > since the longs are only 32 bits. Here is the program: > [code & output snipped] I tried the program on two Intel boxes. Both of them reacted similarly: Script started on Wed Nov 6 12:22:52 1996 bash$ gcc bigfile_.c bigfile_.c: In function `main': bigfile_.c:17: warning: integer overflow in expression bigfile_.c:17: warning: integer overflow in expression bigfile_.c:17: warning: integer overflow in expression bash$ a.out lseek:: Invalid argument bash$ ls -l big* -rw-r--r-- 1 ch user 1 Nov 6 12:23 bigfile -rw-r--r-- 1 ch user 311 Nov 6 12:23 bigfile.script -rw-rw-rw- 1 ch user 555 Nov 6 12:17 bigfile_.c bash$ exit exit Script done on Wed Nov 6 12:23:54 1996 Then, I tried it on an Alpha running NetBSD (unfortunately I have no access to a Linux Alpha). It worked perfectly. Then, I tried the one with _llseek: Script started on Thu Nov 7 19:55:36 1996 darkstar:~$ gcc bigfile.c darkstar:~$ a.out pos: 0x80000000; offset: 0x80000000 write:: File too large darkstar:~$ ls -l bigfile -rw-r--r-- 1 chrigi users 2147483648 Nov 7 19:55 bigfile darkstar:~$ exit Script done on Thu Nov 7 19:56:26 1996 The code follows below. Christian #include #include #include #include #include #include #include #define GB ((long long)(1024*1024*1024)) #define NG (2048L) _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh); int main() { loff_t offset, pos; int fd = open("bigfile", O_CREAT|O_TRUNC|O_WRONLY, 0666); if(fd<0) {perror("open:"); exit(1);} for(offset=0; offset<((long long)NG*(long long)GB); offset += GB) { int num; if(_llseek(fd, offset>>32, (unsigned long)offset, &pos, SEEK_SET) == -1) { printf("pos: 0x%LX; offset: 0x%LX\n", pos, offset); perror("lseek:"); exit(1);} num=write(fd,"x",1); if(num!=1) { printf("pos: 0x%LX; offset: 0x%LX\n", pos, offset); perror("write:"); exit(1);} } printf("Done!\n"); return 0; } -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com