TRANS2_OPEN2: Create or Open File with Extended Attributes

This transaction is used to open or create a file having extended attributes.

Client Request
============================
Value
=======================================
WordCount 15
TotalDataCount Total size of extended attribute list
DataOffset Offset to extended attribute list in this request
SetupCount 1
Setup[0] TRANS2_OPEN2
Parameter Block Encoding
============================
Description
=======================================
USHORT Flags; Additional information: bit set-
0 - return additional info
1 - exclusive oplock requested
2 - batch oplock requested
3 - return total length of EAs
USHORT DesiredAccess; Requested file access
USHORT Reserved1; Ought to be zero. Ignored by the server.
USHORT FileAttributes; Attributes for file if create
SMB_TIME CreationTime; Creation time to apply to file if create
SMB_DATE CreationDate; Creation date to apply to file if create
USHORT OpenFunction; Open function
ULONG AllocationSize; Bytes to reserve on create or truncate
USHORT Reserved [5]; Must be zero
STRING FileName; Name of file to open or create
UCHAR Data[ TotalDataCount ] FEAList structure for file to be created

If secondary requests are required, they must contain 0 parameter bytes, and the fid in the secondary request is 0xFFFF.

desiredaccess is encoded as described in the "Access Mode Encoding" section elsewhere in this document.

fileattributes are encoded as described in the "File Attribute Encoding" section elsewhere in this document.

openfunction specifies the action to be taken depending on whether or not the file exists (see section 3.7) .

action in the response specifies the action as a result of this request (see section 3.8).

Response Parameter Block
==========================
Description
=========================================
USHORT Fid; File handle
USHORT FileAttributes; Attributes of file
SMB_TIME CreationTime; Last modification time
SMB_DATE CreationDate; Last modification date
ULONG DataSize; Current file size
USHORT GrantedAccess; Access permissions actually allowed
USHORT FileType; Type of file
USHORT DeviceState; State of IPC device (e.g. pipe)
USHORT Action; Action taken
ULONG Reserved;
USHORT EaErrorOffset; Offset into EA list if EA error
ULONG EaLength; Total EA length for opened file

filetype returns the kind of resource actually opened:

Name
=======================
Value
======
Description
=====================================
FileTypeDisk 0 Disk file or directory as defined in the attribute field
FileTypeByteModePipe 1 Named pipe in byte mode
FileTypeMessageModePipe 2 Named pipe in message mode
FileTypePrinter 3 Spooled printer
FileTypeUnknown 0xFFFF Unrecognized resource type

DeviceState is applicable only if the FileType is FileTypeByteModePipe or FileTypeMessageModePipe and is encoded as in section 3.9.

If an error was detected in the incoming EA list, the offset of the error is returned in EaErrorOffset.

If bit0 of flags in the request is clear, the FileAttributes, creationtime, creationdate, datasize, grantedaccess, filetype, and devicestate have indeterminate values in the response. Similarly, if bit3 of the request is clear, ealength in the response has an indeterminate value in the response.

This SMB can request an oplock on the opened file. Oplocks are fully described in the "Oplocks" section elsewhere in this document, and there is also discussion of oplocks in the SMB_COM_LOCKING_ANDX SMB description. bit1 and bit2 of the flags field are used to request oplocks during open.