C Standards – Why is the Function Called lseek() Instead of seek()?

cstandards

The C function for seeking in a file is called lseek(). Why ins't it called just seek()?

Best Answer

It appears that the 'l' in lseek means 'long', to differentiate from an old seek function in version 2 of AT&T Unix. This is an anachronism before the off_t type was introduced.

Supporting references:

http://infohost.nmt.edu/~eweiss/222_book/222_book/0201433079/ch03lev1sec6.html indicates:

The character l in the name lseek means "long integer." Before the introduction of the off_t data type, the offset argument and the return value were long integers. lseek was introduced with Version 7 when long integers were added to C. (Similar functionality was provided in Version 6 by the functions seek and tell.)

As noted at the foot of http://www.daemon-systems.org/man/lseek.2.html

 A seek() function appeared in Version 2 AT&T UNIX, later renamed into
 lseek() for ``long seek'' due to a larger offset argument type.