home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!decwrl!bu.edu!Shiva.COM!world!bzs
- From: bzs@ussr.std.com (Barry Shein)
- Newsgroups: comp.unix.wizards
- Subject: Re: A few UNIX questions
- Message-ID: <BZS.92Sep7015040@ussr.std.com>
- Date: 7 Sep 92 06:50:40 GMT
- References: <32176@adm.brl.mil>
- Sender: usenet@world.std.com (Mr USENET himself)
- Organization: The World
- Lines: 29
- In-Reply-To: mike@BRL.MIL's message of 24 Aug 92 19:27:42 GMT
- Nntp-Posting-Host: ussr.std.com
-
-
- >> Can *anyone* tell me why the file size is a signed integer. Surely there
- >> is no need for negative sized files!!
- >
- >Because lseek() needs to be able to return -1 on error, and not have it
- >look like a valid file offset.
-
- That assumes that you need to test (lseek() < 0), one probably should
- test (lseek() == -1) which steals only one value from the entire
- address space. Granted that has to be casted if it were unsigned to
- something more like (lseek() == ((unsigned long)-1)) but no great
- problem.
-
- This situation already exists with the brk() system call and shmget()
- (probably others) which can both return the same bit patterns as
- appear to be negative values on most machines Unix runs on, but
- exactly -1 on return is magic.
-
- If there's any concern one can of course set errno = 0 and then check
- it after the call so still, with some care, distinguish the peculiar
- legal -1 case (as these are all system calls.)
-
- Sort of a botch, but there ya have it.
-
- --
- -Barry Shein
-
- Software Tool & Die | bzs@world.std.com | uunet!world!bzs
- Purveyors to the Trade | Voice: 617-739-0202 | Login: 617-739-WRLD
-