Proposed new Unix POSIX_OPEN/POSIX_UNLINK calls.

Jeremy Allison jra at samba.org
Wed Feb 7 00:26:03 GMT 2007


Here's the (initially coded) spec for the POSIX open and
unlink calls.

Server specifies it can serve these by returning :

CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP        0x20

in the reply to a trans2 qfsinfo (TRANSACT2_QFSINFO 0x03)
info level SMB_QUERY_CIFS_UNIX_INFO (0x200) call.

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).
4 bytes           8            POSIX mode_t (see below).
2 bytes          12            reply info level requested (see below).

All values are little endian. Encodings are as follows :

POSIX open flags :
------------------

#define SMB_O_RDONLY                      0x1
#define SMB_O_WRONLY                      0x2
#define SMB_O_RDWR                        0x4

#define SMB_O_CREAT                      0x10
#define SMB_O_EXCL                       0x20
#define SMB_O_TRUNC                      0x40
#define SMB_O_APPEND                     0x80
#define SMB_O_SYNC                      0x100
#define SMB_O_DIRECTORY                 0x200
#define SMB_O_NOFOLLOW                  0x400
#define SMB_O_DIRECT                    0x800

POSIX mode_t :
--------------

#define UNIX_X_OTH                      0000001
#define UNIX_W_OTH                      0000002
#define UNIX_R_OTH                      0000004
#define UNIX_X_GRP                      0000010
#define UNIX_W_GRP                      0000020
#define UNIX_R_GRP                      0000040
#define UNIX_X_USR                      0000100
#define UNIX_W_USR                      0000200
#define UNIX_R_USR                      0000400
#define UNIX_STICKY                     0001000
#define UNIX_SET_GID                    0002000
#define UNIX_SET_UID                    0004000

The reply info level is an optimization for clients,
the server may not support this. The client requests
the TRANSACT2_QUERYPATHINFO (0x05) info level it
would like the server to return on the newly opened
file. If it doesn't wish a response set these 2 bytes
to zero. Currently the only valid info level requests
here are SMB_QUERY_FILE_UNIX_BASIC (0x200) and
SMB_SET_FILE_UNIX_INFO2 (0x20B, not yet defined).

MKDIR call :

To do the equivalent of a mkdir(path, mode) do the
following request :

flags: 0
open flags: SMB_O_DIRECTORY|SMB_O_CREAT
mode_t: Requested mode_t for the new directory.

The reply data block looks like the following

Size              Offset                  Value
-----------------------------------------------
1 byte           0                    oplock granted flags
                                      (as returned by NTCreateX)
1 byte           1                    Must be Zero.
2 bytes          2                    Returned fnum.
[2 - N bytes]    4                    Info level returned for the
                                      opened file, or 0xFFFF if no
                                      info level returned.

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

SMB_POSIX_PATH_UNLINK          0x20A

No extra data is needed or returned.


More information about the samba-technical mailing list