3

I am reading APUE to explore the details of C and Unix, and encounter lseek

NAME
lseek - move the read/write file offset
SYNOPSIS
#include <unistd.h>

off_t lseek(int fildes, off_t offset, int whence);

What does l mean, is it length?

gsamaras
  • 71,951
  • 46
  • 188
  • 305
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138
  • 11
    https://softwareengineering.stackexchange.com/questions/244525/why-is-the-function-called-lseek-not-seek – bolov Nov 12 '18 at 09:03
  • 1
    `l` is for long, as @bolov suggests. However, I cannot mark that as a duplicate, since it's on another stack exchange site. Posting an answer with the same content doesn't feel right also.. Hmm.. – gsamaras Nov 12 '18 at 09:05
  • I feel sort of know nothing about C when start to read APUE. – AbstProcDo Nov 12 '18 at 09:07
  • According to [this](http://www.informit.com/articles/article.aspx?p=99706&seqNum=6): The character l in the name lseek means "long integer." – DaBler Nov 12 '18 at 09:10
  • 1
    @gsamaras: I agree. But posting the same answer and linking to the original answer on Software Engineering might still be appropriate. – Sani Huttunen Nov 12 '18 at 09:10
  • @gsamaras I however feel perfectly ok with reposting other answers ;p – Swordfish Nov 12 '18 at 09:17
  • The question isn't necessarily off-topic here just because it is on-topic elsewhere. I see nothing wrong with asking these kind of questions. – Lundin Nov 12 '18 at 09:19
  • 1
    @SaniSinghHuttunen you are right, I checked on [meta site](https://meta.stackexchange.com/a/4713/275467), and they say exactly this, so I went ahead and posted an answer! Swordfish, nice timing, but I posted an answer already. :) Lunding, of course it's not off-topic, I just didn't know what to do with cross-site duplicates. Now that I read the meta post, I know! :) – gsamaras Nov 12 '18 at 09:19
  • @gsamaras What now? call you slowfox? – Swordfish Nov 12 '18 at 09:20

1 Answers1

6

l is for long integer.

It is named like that to differentiate from the old seek() in version 2 of AT&T Unix. This is an anachronism before the off_t type was introduced.


References:

Infohost 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 lseek.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.

Note: Paraphrased from Why is the function called lseek(), not seek()?

gsamaras
  • 71,951
  • 46
  • 188
  • 305