SEEK: Seek in File

The seek message is sent to set the current file pointer for fid.

Client Request
==================================
Description
=================================
UCHAR WordCount; Count of parameter words = 4
USHORT Fid; File handle
USHORT Mode; Seek mode:
0 = from start of file
1 = from current position
2 = from end of file
LONG Offset; Relative offset
USHORT ByteCount; Count of data bytes = 0

The starting point of the seek is set by mode:

0 seek from start of file
1 seek from current file pointer
2 seek from end of file

The "current position" reflects the offset plus data length specified in the previous read, write or seek request, and the pointer set by this command will be replaced by the offset specified in the next read, write or seek command.

Server Response
==================================
Description
=================================
UCHAR WordCount; Count of parameter words = 2
ULONG Offset; Offset from start of file
USHORT ByteCount; Count of data bytes = 0

The response returns the new file pointer in offset which is expressed as the offset from the start of the file, and may be beyond the current end of file. An attempt to seek to before the start of file sets the current file pointer to start of the file.

This request should generally only be issued by clients wishing to find the size of a file, since all read and write requests include the read or write file position as part of the SMB. This request is inappropriate for very large files, as the offsets specified are only 32 bits. A seek which results in an Offset which can not be expressed in 32 bits returns the least significant.

Errors

ERRDOS/ERRbadfid
ERRDOS/ERRnoaccess
ERRSRV/ERRinvdevice
ERRSRV/ERRinvid
ERRSRV/ERRbaduid