0

According to the book Advanced Programming in the Unix Environment :-

"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.)"

We know that there is a limit on the value of file descriptors.That value lies in the range 0-OPEN_MAX-1.So,if earlier versions use long integer for file descriptors ,then this could mean that the maximum number of files which can be opened per process must vary according to the system word format(32 bit or 64 bit),and this means that the number of available file descriptors could be of the order of 10^18.Am I right?

closed as unclear what you're asking by Kusalananda, Anthon, Rui F Ribeiro, Satō Katsura, Scott Aug 27 '17 at 7:03

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    What does the maximum number of open file descriptors have to do with the return type of lseek()? A filedescriptor is usually of the type int. – Kusalananda Aug 26 '17 at 16:12
  • I think you haven't read the reference i used in my question.It says that "Before the introduction of the off_t data type, the offset argument and the return value were long integers".The return value were long integers.And the return value was a file descriptor. – Shanif Ansari Aug 26 '17 at 16:31
  • Compare V7 lseek() with V6 seek(). The return value is an error code. A long error in V7, but still no file descriptor. – Kusalananda Aug 26 '17 at 16:48
  • You aren't understanding what I am trying to say.I quoted a reference from the book and that book says it so.That is not what I am saying.The book says that lseek returns file descriptor value. – Shanif Ansari Aug 26 '17 at 16:52
  • Your quote is from p. 67 (in the 3rd edition) of the book. Nowhere there does it say that lseek() or seek() returned a file descriptor. It says only that the return value was a long in V7. It doesn't even make sense that lseek() or seek() returned a file descriptor. What would the use of that be? – Kusalananda Aug 26 '17 at 17:00
4

lseek’s long parameter and return value are both offsets in the file; the addition of long didn’t have any impact on file descriptors.

Varying word size did have an impact on the size of usable offsets; see lseek64 for a workaround.

2

I believe this is a misunderstanding.

The complete quote from the book is

The three symbolic constants—SEEK_SET, SEEK_CUR, and SEEK_END—were introduced with System V. Prior to this, whence was specified as 0 (absolute), 1 (relative to the current offset), or 2 (relative to the end of file). Much software still exists with these numbers hard coded.

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.)

Nowhere in the text does it say anything about the return value being a file descriptor at any point in time.

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