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

  • 2
    What does it return? – andy256 Jun 10 '14 at 13:06
  • @andy256 off_t and if you want the 64 bit offset you use lseek64 – ratchet freak Jun 10 '14 at 13:12
  • 1
    @ratchetfreak er ... thanks. The question was for the OP's benefit, not mine :-) – andy256 Jun 10 '14 at 13:15
  • My guess is that it is an evolutionary thing, just remains from the past where was a distinction between long and int. – ysap Jun 10 '14 at 13:15
  • 3
    The extra character was added to make up for the missing one in creat(). (Actually, the L probably stands for logical.) – Blrfl Jun 10 '14 at 15:11

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.
| improve this answer | |
  • Intuition still works... :-) – ysap Jun 12 '14 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.