off_t signed (was Re: unix question: files per directory)

Randal L. Schwartz @ Stonehenge merlyn at intelob.intel.com
Thu Apr 13 05:26:26 AEST 1989


In article <8420 at xanth.cs.odu.edu>, kremer at cs (Lloyd Kremer) writes:
| Why was it decided that off_t should be signed?  Why should it not be
| unsigned long where unsigned longs are supported, or unsigned int where int
| is a 32 bit quantity?  It seems that signed long imposes an unnecessary
| 2GB limit on file size.
[...]
| And it doesn't make sense to have a negative offset into a file.  The
| only exception that comes to mind is that of returning an error code from
| a function like lseek(), and this special case could be macro'd like
| 
| 	#define SEEK_ERR ((off_t)(-1))
| 
| in <sys/types.h> or <sys/stat.h>.

See lseek(2).  At least under Ultrix (the only UNIX I can get my hands
on at the moment, but I think this is true all the way back to V7),
the second argument of lseek() can take negative values for lseek(fd,
offset, 1) and lseek(fd, offset, 2), and the type of `offset' is
`off_t'.  Sure, `pos' will never be negative, but you might wanna move
backwards!

Trying to earn back my guru card,
-- 
/=====Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095========\
{        on contract to BiiN (for now :-) Hillsboro, Oregon, USA.             }
{<@intel-iwarp.arpa:merlyn at intelob.intel.com> ...!uunet!tektronix!biin!merlyn }
\=====Cute quote: "Welcome to Oregon... home of the California Raisins!"======/



More information about the Comp.unix.wizards mailing list