|
|
1.1 ! root 1: .TH LSEEK 2 "7 July 1983" ! 2: .UC 4 ! 3: .SH NAME ! 4: lseek \- move read/write pointer ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .ft B ! 8: .ta 1.25i 1.6i ! 9: #define L_SET 0 /* set the seek pointer */ ! 10: #define L_INCR 1 /* increment the seek pointer */ ! 11: #define L_XTND 2 /* extend the file size */ ! 12: .PP ! 13: .ft B ! 14: pos = lseek(d, offset, whence) ! 15: int pos; ! 16: int d, offset, whence; ! 17: .fi ! 18: .ft R ! 19: .SH DESCRIPTION ! 20: The descriptor ! 21: .I d ! 22: refers to a file or device open for reading and/or writing. ! 23: .I Lseek ! 24: sets the file pointer of ! 25: .I d ! 26: as follows: ! 27: .IP ! 28: If ! 29: .I whence ! 30: is L_SET, the pointer is set to ! 31: .I offset ! 32: bytes. ! 33: .IP ! 34: If ! 35: .I whence ! 36: is L_INCR, the pointer is set to its current location plus ! 37: .IR offset . ! 38: .IP ! 39: If ! 40: .I whence ! 41: is L_XTND, the pointer is set to the size of the ! 42: file plus ! 43: .IR offset . ! 44: .PP ! 45: Upon successful completion, the resulting pointer location ! 46: as measured in bytes from beginning of the file is returned. ! 47: Some devices are incapable of seeking. The value of the pointer ! 48: associated with such a device is undefined. ! 49: .SH NOTES ! 50: Seeking far beyond the end of a file, then writing, ! 51: creates a gap or \*(lqhole\*(rq, which occupies no ! 52: physical space and reads as zeros. ! 53: .SH "RETURN VALUE ! 54: Upon successful completion, a non-negative integer, ! 55: the current file pointer value, is returned. Otherwise, ! 56: a value of \-1 is returned and \fIerrno\fP is set to indicate ! 57: the error. ! 58: .SH "ERRORS ! 59: .I Lseek ! 60: will fail and the file pointer will remain unchanged if: ! 61: .TP 15 ! 62: [EBADF] ! 63: .I Fildes ! 64: is not an open file descriptor. ! 65: .TP 15 ! 66: [ESPIPE] ! 67: .I Fildes ! 68: is associated with a pipe or a socket. ! 69: .TP 15 ! 70: [EINVAL] ! 71: .I Whence ! 72: is not a proper value. ! 73: .TP 15 ! 74: [EINVAL] ! 75: The resulting file pointer would be negative. ! 76: .SH "SEE ALSO" ! 77: dup(2), open(2) ! 78: .SH BUGS ! 79: This document's use of ! 80: .I whence ! 81: is incorrect English, but maintained for historical reasons.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.