Difference between revisions of "UNIX Extensions"

Line 48: Line 48:
 
|| CIFS_UNIX_EXATTR_CAP || 0x08
 
|| CIFS_UNIX_EXATTR_CAP || 0x08
 
|-
 
|-
|| CIFSS_UNIX_POSIX_PATHNAMES_CAP || 0x10
+
|| CIFS_UNIX_POSIX_PATHNAMES_CAP || 0x10
 
|-
 
|-
 
|| CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP || 0x20
 
|| CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP || 0x20
Line 253: Line 253:
 
|| EXT_HIDDEN  ||  0x00000080 || User interface programs may ignore this file
 
|| EXT_HIDDEN  ||  0x00000080 || User interface programs may ignore this file
 
|}
 
|}
 +
 +
== DFS Sideeffects ==
 +
Although the

Revision as of 20:51, 9 March 2007

See http://samba.org/samba/CIFS_POSIX_extensions.html

Introduction

The Unix Extensions to the CIFS Protocol have been done in stages. An initial set which included various new infolevels to TRANSACT2 commands in the range from 0x200 to 0x2FF (inclusive), was available when:

CAP_UNIX (0x00800000)

included in the SMB negotiate protocol response.

Additional POSIX extensions have been added based on negotiating individual capabilities on the tree connection (via a Unix QueryFSInfo and SetFSInfo level). Following is a list of the previous levels that were available:

New File Info (and Path Info) levels

Capability Value
QUERY_FILE_UNIX_BASIC 0x200
QUERY_FILE_UNIX_LINUX 0x201
QUERY_POSIX_ACL 0x204
QUERY_XATTR 0x205
QUERY_ATTR_FLAGS 0x206
QUERY_POSIX_PERMISSION 0x207
QUERY_POSIX_LOCK 0x208

Negotiating per-share (tree connection) Capabilities

Capability Value
CIFS_UNIX_FCNTL_LOCKS_CAP 0x01
CIFS_UNIX_POSIX_ACLS_CAP 0x02
CIFS_UNIX_XATTR_CAP 0x04
CIFS_UNIX_EXATTR_CAP 0x08
CIFS_UNIX_POSIX_PATHNAMES_CAP 0x10
CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20

Posix Open

The server specifies it can serve these by returning CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP in the reply to a trans2 qfsinfo (TRANSACT2_QFSINFO 0x03) info level SMB_QUERY_CIFS_UNIX_INFO (0x200) call. All values are little endian.

For open, call TRANSACT2_SETPATHINFO (0x06) call info level :

SMB_POSIX_PATH_OPEN 0x209

The request data block should be 14 bytes consisting of the following :

Size Offset Value
4 bytes 0 Flags field (same as smb_ntcreate_flags in SMBNTCreateX to request oplocks)
4 bytes 4 POSIX open flags (see below)
8 bytes 8 POSIX Permissions (see below)
2 bytes 16 Reply info level requested (see below)

Encodings are as follows :

POSIX open flags Value
SMB_O_RDONLY 0x1
SMB_O_WRONLY 0x2
SMB_O_RDWR 0x4
SMB_O_CREAT 0x10
SMB_O_EXCL 0x20
SMB_O_TRUNC 0x40
SMB_O_APPEND 0x80
SMB_O_SYNC 0x100
SMB_O_DIRECTORY 0x200
SMB_O_NOFOLLOW 0x400
SMB_O_DIRECT 0x800
POSIX permissions Value Description
SMB_PERM_SUID 0004000 set UID bit
SMB_PERM_SGID 0002000 set-group-ID bit
SMB_PERM_SVTX 0001000 sticky bit
SMB_PERM_RUSR 00400 owner has read permission
SMB_PERM_WUSR 00200 owner has write permission
SMB_PERM_XUSR 00100 owner has execute permission
SMB_PERM_RGRP 00040 group has read permission
SMB_PERM_WGRP 00020 group has write permission
SMB_PERM_XGRP 00010 group has execute permission
SMB_PERM_ROTH 00004 others have read permission
SMB_PERM_WOTH 00002 others have write permission
SMB_PERM_XOTH 00001 others have execute permission

SMB WHOAMI

The SMBWhoami extension is intended to be a lightweight method for a Unix client to be able to display sensible file ownership information.

SMBWhoami is performed by requesting a TRANS2_QFSINFO with an info level of SMB_QUERY_POSIX_WHOAMI. There are no parameters passed. The vuid field is implicitly used.

Info Level Name Value
SMB_QUERY_POSIX_WHOAMI 0x202

The first two fields of the SMBWhoami response are a set of flags that further describe how the server has mapped the connected user. The mask is returned so that the client can distinguish which flag bits are meaningful.

Mapping Flag Value Interpretation
SMB_WHOAMI_GUEST 0x1 Logged in as (or squashed to) guest
Size Offset Value
4 bytes 0 Mapping flags
4 bytes 4 Mask of valid mapping flags
8 bytes 8 Primary user ID
8 bytes 16 Primary group ID
4 bytes 24 number of supplementary GIDs
4 bytes 28 number of SIDs
4 bytes 32 SID list byte count
4 bytes 36 Reserved (should be zero)
variable ... list of 8 byte group IDs (may be empty)
variable ... List of DOM_SID structures (may be empty)

Note that the list of group IDs and DOM_SIDs are both optional. A server may choose not to return these (eg. if the information is expensive to gather). If these are not returned the corresponding count fields must be zero.

UNIX_INFO2

The UNIX_INFO2 is an extension to the UNIX_BASIC info level. This info level can be used in FindFirst/FindNext, QueryPathInfo, QueryFileInfo and PosixOpen (but is not restricted to those calls).

Info Level Value
SMB_QUERY_FILE_UNIX_INFO2 0x20B
SMB_SET_FILE_UNIX_INFO2 0x20B
SMB_FIND_FILE_UNIX_INFO2 0x20B

The response block for the UNIX_INFO2 level is below. This is deliberately defined to be the same as UNIX_BASIC except for the last 3 fields.

Size Offset Type Name Description
8 0 LARGE_INTEGER EndOfFile File size
8 8 LARGE_INTEGER Blocks Number of blocks used on disk
8 16 LARGE_INTEGER ChangeTime Attribute change time
8 24 LARGE_INTEGER LastAccessTime Last access time
8 32 LARGE_INTEGER LastModificationTime Last modification time
8 40 LARGE_INTEGER Uid Numeric user id for the owner
8 48 LARGE_INTEGER Gid Numeric group id of owner
4 56 ULONG Type Enumeration specifying the file type
8 60 LARGE_INTEGER DevMajor Major device number if type is device
8 68 LARGE_INTEGER DevMinor Minor device number if type is device
8 76 LARGE_INTEGER UniqueId This is a server-assigned unique id
8 84 LARGE_INTEGER Permissions Standard UNIX permissions
8 92 LARGE_INTEGER NumLinks Number of hard links
8 100 LARGE_INTEGER CreationTime Create/birth time
4 108 ULONG FileFlags File flags enumeration
4 112 ULONG FileFlagsMask Mask of valid flags

If the client is doing a set with the UNIX_INFO2 level and it does not want to alter the FileFlags, it should provide a FileFlagsMask of 0.

The defined set of file flags is

File Flag Value Interpretation
EXT_SECURE_DELETE 0x00000001 File should be erased such that the data is not recoverable
EXT_ENABLE_UNDELETE 0x00000002 File should opt-in to a server-specific deletion recovery scheme
EXT_SYNCHRONOUS 0x00000004 I/O to this file should be performed synchronously
EXT_IMMUTABLE 0x00000008 NO changes can be made to this file
EXT_OPEN_APPEND_ONLY 0x00000010 Only appends can be made to this file
EXT_DO_NOT_BACKUP 0x00000020 Backup programs should ignore this file
EXT_NO_UPDATE_ATIME 0x00000040 The server is not required to update the last access time on this file
EXT_HIDDEN 0x00000080 User interface programs may ignore this file

DFS Sideeffects

Although the