Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Christian Hardmeier <chrigi@darkstar.chrigi.net>
Subject: Re: 64 Bits from Larry McVoy
Date: Thu, 7 Nov 1996 19:58:14 +0100 (MET)	[thread overview]
Message-ID: <2a7e42db0b3166d28ea649564939c354.axp-list@archive.invalid> (raw)
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 <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/unistd.h>

#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

  parent reply	other threads:[~1996-11-07 18:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.LNX.3.93.961105175237.464A-100000@darkstar.chrigi.net>
1996-11-06 12:20 ` 64 Bits from Larry McVoy Jim Nance
1996-11-06 12:34   ` Philip Blundell
1996-11-07 18:58   ` Christian Hardmeier [this message]
     [not found] <Pine.SOL.3.95.961106122811.7441C-100000@hammer.thor.cam.ac.uk>
1996-11-06 12:57 ` Jim Nance
     [not found] <9611041302.AA00548@scooter>
1996-11-04 23:10 ` Marc Singer
1996-11-05  0:23 ` Richard Henderson
1996-11-04 13:02 Jim Nance
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox