This system API advances the file position pointer for the next I/O.  Position can be specified as follow:
SEEK_CUR = current position + offset
SEEK_END = end of file + offset
SEEK_SET = beginning of file + offset
Note that offset can be 0, positive or negative.
When seeking beyond the end of file, READ will return EOF.  Write at that position will create a hole between the previous EOF point to the new data.  The hole will be filled with zeros but they will not occupy any space on disk.  The file becomes a sparse file.
The max file poisiton that lseek can go is defined as off_t type.  This is typically implemented as C long type (i.e. word size = size of the general purpose register).  In kernel, the position is kept as long long.
No comments:
Post a Comment