Q: lseek returns long or int? (BSD 4.2)
Donn Seeley
donn at utah-cs.UUCP
Sun Sep 23 21:40:02 AEST 1984
From henry at utzoo.UUCP (Henry Spencer):
This is yet another piece of gratuitous brain-damage brought to
you by the morons at Berkeley. ...
This is yet another gratuitous insult from someone who should have
better things to do. I have no illusions that a lecture on the joys of
being constructive would be other than wasted breath (or keystrokes),
so I will merely point out that if there weren't any constructive
people, we wouldn't have Unix at all.
It IS a bit ironic that this latest flap involves typing, since the
Berkeley kernel is fairly obsessive in using typedefs to make types
system-independent. For instance, the lseek() call has its own
typedef, 'off_t', for representing the type of a file offset; this is
surely a greater nod to portability than merely stamping the value as
'long'. At any rate the manual page chooses not to use this typedef,
which is probably a mistake. It is easily corrected if one spends a
minute or two looking at the situation (in man2/lseek.2):
------------------------------------------------------------------------
*** /tmp/,RCSt1023012 Sun Sep 23 05:17:09 1984
--- lseek.2 Sun Sep 23 04:56:28 1984
***************
*** 5,11
.SH SYNOPSIS
.nf
.ft B
! .ta 1.25i 1.6i
#define L_SET 0 /* set the seek pointer */
#define L_INCR 1 /* increment the seek pointer */
#define L_XTND 2 /* extend the file size */
--- 5,16 -----
.SH SYNOPSIS
.nf
.ft B
! #include <sys/types.h>
! #include <sys/file.h>
! .PP
! .nf
! .ft B
! .ta 1.25i 1.6i 1.8i
#define L_SET 0 /* set the seek pointer */
#define L_INCR 1 /* increment the seek pointer */
#define L_XTND 2 /* extend the file size */
***************
*** 12,19
.PP
.ft B
pos = lseek(d, offset, whence)
! int pos;
! int d, offset, whence;
.fi
.ft R
.SH DESCRIPTION
--- 17,26 -----
.PP
.ft B
pos = lseek(d, offset, whence)
! off_t pos;
! int d;
! off_t offset;
! int whence;
.fi
.ft R
.SH DESCRIPTION
------------------------------------------------------------------------
Despite this trivial problem, lseek.2 and the 4.2 manual entries in
general are definitely a vast improvement over the earlier Berkeley
versions, which usually failed to enumerate the errors which a call
could return and sometimes even omitted the return values. Many things
which used to be magic cookies in previous versions of the system, such
as lseek()'s 'whence', are now clearly parameterized (perhaps
influenced by USG Unixes). Efforts at improvement such as this should
be commended, not sneered at.
Waiting for a return to civility (but not holding my breath),
Donn Seeley University of Utah CS Dept donn at utah-cs.arpa
40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn
More information about the Comp.unix.wizards
mailing list