00001 /* 00002 Unix SMB/CIFS implementation. 00003 SMB transaction2 handling 00004 00005 Copyright (C) James Peach 2007 00006 Copyright (C) Jeremy Allison 1994-2002. 00007 00008 Extensively modified by Andrew Tridgell, 1995 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 2 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 */ 00024 00025 #ifndef _TRANS2_H_ 00026 #define _TRANS2_H_ 00027 00028 /* Define the structures needed for the trans2 calls. */ 00029 00030 /******************************************************* 00031 For DosFindFirst/DosFindNext - level 1 00032 00033 MAXFILENAMELEN = 255; 00034 FDATE == uint16 00035 FTIME == uint16 00036 ULONG == uint32 00037 USHORT == uint16 00038 00039 typedef struct _FILEFINDBUF { 00040 Byte offset Type name description 00041 -------------+-------+-------------------+-------------- 00042 0 FDATE fdateCreation; 00043 2 FTIME ftimeCreation; 00044 4 FDATE fdateLastAccess; 00045 6 FTIME ftimeLastAccess; 00046 8 FDATE fdateLastWrite; 00047 10 FTIME ftimeLastWrite; 00048 12 ULONG cbFile file length in bytes 00049 16 ULONG cbFileAlloc size of file allocation unit 00050 20 USHORT attrFile 00051 22 UCHAR cchName length of name to follow (not including zero) 00052 23 UCHAR achName[MAXFILENAMELEN]; Null terminated name 00053 } FILEFINDBUF; 00054 *********************************************************/ 00055 00056 #define l1_fdateCreation 0 00057 #define l1_fdateLastAccess 4 00058 #define l1_fdateLastWrite 8 00059 #define l1_cbFile 12 00060 #define l1_cbFileAlloc 16 00061 #define l1_attrFile 20 00062 #define l1_cchName 22 00063 #define l1_achName 23 00064 00065 /********************************************************** 00066 For DosFindFirst/DosFindNext - level 2 00067 00068 typedef struct _FILEFINDBUF2 { 00069 Byte offset Type name description 00070 -------------+-------+-------------------+-------------- 00071 0 FDATE fdateCreation; 00072 2 FTIME ftimeCreation; 00073 4 FDATE fdateLastAccess; 00074 6 FTIME ftimeLastAccess; 00075 8 FDATE fdateLastWrite; 00076 10 FTIME ftimeLastWrite; 00077 12 ULONG cbFile file length in bytes 00078 16 ULONG cbFileAlloc size of file allocation unit 00079 20 USHORT attrFile 00080 22 ULONG cbList Extended attribute list (always 0) 00081 26 UCHAR cchName length of name to follow (not including zero) 00082 27 UCHAR achName[MAXFILENAMELEN]; Null terminated name 00083 } FILEFINDBUF2; 00084 *************************************************************/ 00085 00086 #define l2_fdateCreation 0 00087 #define l2_fdateLastAccess 4 00088 #define l2_fdateLastWrite 8 00089 #define l2_cbFile 12 00090 #define l2_cbFileAlloc 16 00091 #define l2_attrFile 20 00092 #define l2_cbList 22 00093 #define l2_cchName 26 00094 #define l2_achName 27 00095 00096 00097 /********************************************************** 00098 For DosFindFirst/DosFindNext - level 260 00099 00100 typedef struct _FILEFINDBUF260 { 00101 Byte offset Type name description 00102 -------------+-------+-------------------+-------------- 00103 0 ULONG NextEntryOffset; 00104 4 ULONG FileIndex; 00105 8 LARGE_INTEGER CreationTime; 00106 16 LARGE_INTEGER LastAccessTime; 00107 24 LARGE_INTEGER LastWriteTime; 00108 32 LARGE_INTEGER ChangeTime; 00109 40 LARGE_INTEGER EndOfFile; 00110 48 LARGE_INTEGER AllocationSize; 00111 56 ULONG FileAttributes; 00112 60 ULONG FileNameLength; 00113 64 ULONG EaSize; 00114 68 CHAR ShortNameLength; 00115 70 UNICODE ShortName[12]; 00116 94 UNICODE FileName[]; 00117 *************************************************************/ 00118 00119 #define l260_achName 94 00120 00121 00122 /********************************************************** 00123 For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/ 00124 DosSetFileInfo - level 1 00125 00126 typedef struct _FILESTATUS { 00127 Byte offset Type name description 00128 -------------+-------+-------------------+-------------- 00129 0 FDATE fdateCreation; 00130 2 FTIME ftimeCreation; 00131 4 FDATE fdateLastAccess; 00132 6 FTIME ftimeLastAccess; 00133 8 FDATE fdateLastWrite; 00134 10 FTIME ftimeLastWrite; 00135 12 ULONG cbFile file length in bytes 00136 16 ULONG cbFileAlloc size of file allocation unit 00137 20 USHORT attrFile 00138 } FILESTATUS; 00139 *************************************************************/ 00140 00141 /* Use the l1_ defines from DosFindFirst */ 00142 00143 /********************************************************** 00144 For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/ 00145 DosSetFileInfo - level 2 00146 00147 typedef struct _FILESTATUS2 { 00148 Byte offset Type name description 00149 -------------+-------+-------------------+-------------- 00150 0 FDATE fdateCreation; 00151 2 FTIME ftimeCreation; 00152 4 FDATE fdateLastAccess; 00153 6 FTIME ftimeLastAccess; 00154 8 FDATE fdateLastWrite; 00155 10 FTIME ftimeLastWrite; 00156 12 ULONG cbFile file length in bytes 00157 16 ULONG cbFileAlloc size of file allocation unit 00158 20 USHORT attrFile 00159 22 ULONG cbList Length of EA's (0) 00160 } FILESTATUS2; 00161 *************************************************************/ 00162 00163 /* Use the l2_ #defines from DosFindFirst */ 00164 00165 /********************************************************** 00166 For DosQFSInfo/DosSetFSInfo - level 1 00167 00168 typedef struct _FSALLOCATE { 00169 Byte offset Type name description 00170 -------------+-------+-------------------+-------------- 00171 0 ULONG idFileSystem id of file system 00172 4 ULONG cSectorUnit number of sectors per allocation unit 00173 8 ULONG cUnit number of allocation units 00174 12 ULONG cUnitAvail Available allocation units 00175 16 USHORT cbSector bytes per sector 00176 } FSALLOCATE; 00177 *************************************************************/ 00178 00179 #define l1_idFileSystem 0 00180 #define l1_cSectorUnit 4 00181 #define l1_cUnit 8 00182 #define l1_cUnitAvail 12 00183 #define l1_cbSector 16 00184 00185 /********************************************************** 00186 For DosQFSInfo/DosSetFSInfo - level 2 00187 00188 typedef struct _FSINFO { 00189 Byte offset Type name description 00190 -------------+-------+-------------------+-------------- 00191 0 FDATE vol_fdateCreation 00192 2 FTIME vol_ftimeCreation 00193 4 UCHAR vol_cch length of volume name (excluding NULL) 00194 5 UCHAR vol_szVolLabel[12] volume name 00195 } FSINFO; 00196 *************************************************************/ 00197 00198 #define SMB_INFO_STANDARD 1 /* FILESTATUS3 struct */ 00199 #define SMB_INFO_SET_EA 2 /* EAOP2 struct, only valid on set not query */ 00200 #define SMB_INFO_QUERY_EA_SIZE 2 /* FILESTATUS4 struct, only valid on query not set */ 00201 #define SMB_INFO_QUERY_EAS_FROM_LIST 3 /* only valid on query not set */ 00202 #define SMB_INFO_QUERY_ALL_EAS 4 /* only valid on query not set */ 00203 #define SMB_INFO_IS_NAME_VALID 6 00204 #define SMB_INFO_STANDARD_LONG 11 /* similar to level 1, ie struct FileStatus3 */ 00205 #define SMB_QUERY_EA_SIZE_LONG 12 /* similar to level 2, ie struct FileStatus4 */ 00206 #define SMB_QUERY_FS_LABEL_INFO 0x101 00207 #define SMB_QUERY_FS_VOLUME_INFO 0x102 00208 #define SMB_QUERY_FS_SIZE_INFO 0x103 00209 #define SMB_QUERY_FS_DEVICE_INFO 0x104 00210 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105 00211 #if 0 00212 #define SMB_QUERY_FS_QUOTA_INFO 00213 #endif 00214 00215 #define l2_vol_fdateCreation 0 00216 #define l2_vol_cch 4 00217 #define l2_vol_szVolLabel 5 00218 00219 00220 #define SMB_QUERY_FILE_BASIC_INFO 0x101 00221 #define SMB_QUERY_FILE_STANDARD_INFO 0x102 00222 #define SMB_QUERY_FILE_EA_INFO 0x103 00223 #define SMB_QUERY_FILE_NAME_INFO 0x104 00224 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105 00225 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106 00226 #define SMB_QUERY_FILE_ALL_INFO 0x107 00227 #define SMB_QUERY_FILE_ALT_NAME_INFO 0x108 00228 #define SMB_QUERY_FILE_STREAM_INFO 0x109 00229 #define SMB_QUERY_COMPRESSION_INFO 0x10b 00230 00231 #define SMB_FIND_INFO_STANDARD 1 00232 #define SMB_FIND_EA_SIZE 2 00233 #define SMB_FIND_EA_LIST 3 00234 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101 00235 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102 00236 #define SMB_FIND_FILE_NAMES_INFO 0x103 00237 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104 00238 #define SMB_FIND_ID_FULL_DIRECTORY_INFO 0x105 00239 #define SMB_FIND_ID_BOTH_DIRECTORY_INFO 0x106 00240 00241 #define SMB_SET_FILE_BASIC_INFO 0x101 00242 #define SMB_SET_FILE_DISPOSITION_INFO 0x102 00243 #define SMB_SET_FILE_ALLOCATION_INFO 0x103 00244 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104 00245 00246 /* Query FS info. */ 00247 #define SMB_INFO_ALLOCATION 1 00248 #define SMB_INFO_VOLUME 2 00249 00250 /* 00251 * Thursby MAC extensions.... 00252 */ 00253 00254 /* 00255 * MAC CIFS Extensions have the range 0x300 - 0x2FF reserved. 00256 * Supposedly Microsoft have agreed to this. 00257 */ 00258 00259 #define MIN_MAC_INFO_LEVEL 0x300 00260 #define MAX_MAC_INFO_LEVEL 0x3FF 00261 00262 #define SMB_MAC_QUERY_FS_INFO 0x301 00263 00264 #define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName)) 00265 00266 /* 00267 * DeviceType and Characteristics returned in a 00268 * SMB_QUERY_FS_DEVICE_INFO call. 00269 */ 00270 00271 #define DEVICETYPE_CD_ROM 0x2 00272 #define DEVICETYPE_CD_ROM_FILE_SYSTEM 0x3 00273 #define DEVICETYPE_DISK 0x7 00274 #define DEVICETYPE_DISK_FILE_SYSTEM 0x8 00275 #define DEVICETYPE_FILE_SYSTEM 0x9 00276 00277 /* Characteristics. */ 00278 #define TYPE_REMOVABLE_MEDIA 0x1 00279 #define TYPE_READ_ONLY_DEVICE 0x2 00280 #define TYPE_FLOPPY 0x4 00281 #define TYPE_WORM 0x8 00282 #define TYPE_REMOTE 0x10 00283 #define TYPE_MOUNTED 0x20 00284 #define TYPE_VIRTUAL 0x40 00285 00286 /* NT passthrough levels... */ 00287 00288 #define SMB_FILE_DIRECTORY_INFORMATION 1001 00289 #define SMB_FILE_FULL_DIRECTORY_INFORMATION 1002 00290 #define SMB_FILE_BOTH_DIRECTORY_INFORMATION 1003 00291 #define SMB_FILE_BASIC_INFORMATION 1004 00292 #define SMB_FILE_STANDARD_INFORMATION 1005 00293 #define SMB_FILE_INTERNAL_INFORMATION 1006 00294 #define SMB_FILE_EA_INFORMATION 1007 00295 #define SMB_FILE_ACCESS_INFORMATION 1008 00296 #define SMB_FILE_NAME_INFORMATION 1009 00297 #define SMB_FILE_RENAME_INFORMATION 1010 00298 #define SMB_FILE_LINK_INFORMATION 1011 00299 #define SMB_FILE_NAMES_INFORMATION 1012 00300 #define SMB_FILE_DISPOSITION_INFORMATION 1013 00301 #define SMB_FILE_POSITION_INFORMATION 1014 00302 #define SMB_FILE_FULL_EA_INFORMATION 1015 00303 #define SMB_FILE_MODE_INFORMATION 1016 00304 #define SMB_FILE_ALIGNMENT_INFORMATION 1017 00305 #define SMB_FILE_ALL_INFORMATION 1018 00306 #define SMB_FILE_ALLOCATION_INFORMATION 1019 00307 #define SMB_FILE_END_OF_FILE_INFORMATION 1020 00308 #define SMB_FILE_ALTERNATE_NAME_INFORMATION 1021 00309 #define SMB_FILE_STREAM_INFORMATION 1022 00310 #define SMB_FILE_PIPE_INFORMATION 1023 00311 #define SMB_FILE_PIPE_LOCAL_INFORMATION 1024 00312 #define SMB_FILE_PIPE_REMOTE_INFORMATION 1025 00313 #define SMB_FILE_MAILSLOT_QUERY_INFORMATION 1026 00314 #define SMB_FILE_MAILSLOT_SET_INFORMATION 1027 00315 #define SMB_FILE_COMPRESSION_INFORMATION 1028 00316 #define SMB_FILE_OBJECTID_INFORMATION 1029 00317 #define SMB_FILE_COMPLETION_INFORMATION 1030 00318 #define SMB_FILE_MOVE_CLUSTER_INFORMATION 1031 00319 #define SMB_FILE_QUOTA_INFORMATION 1032 00320 #define SMB_FILE_REPARSEPOINT_INFORMATION 1033 00321 #define SMB_FILE_NETWORK_OPEN_INFORMATION 1034 00322 #define SMB_FILE_ATTRIBUTE_TAG_INFORMATION 1035 00323 #define SMB_FILE_TRACKING_INFORMATION 1036 00324 #define SMB_FILE_MAXIMUM_INFORMATION 1037 00325 00326 /* NT passthough levels for qfsinfo. */ 00327 00328 #define SMB_FS_VOLUME_INFORMATION 1001 00329 #define SMB_FS_LABEL_INFORMATION 1002 00330 #define SMB_FS_SIZE_INFORMATION 1003 00331 #define SMB_FS_DEVICE_INFORMATION 1004 00332 #define SMB_FS_ATTRIBUTE_INFORMATION 1005 00333 #define SMB_FS_QUOTA_INFORMATION 1006 00334 #define SMB_FS_FULL_SIZE_INFORMATION 1007 00335 #define SMB_FS_OBJECTID_INFORMATION 1008 00336 00337 /* flags on trans2 findfirst/findnext that control search */ 00338 #define FLAG_TRANS2_FIND_CLOSE 0x1 00339 #define FLAG_TRANS2_FIND_CLOSE_IF_END 0x2 00340 #define FLAG_TRANS2_FIND_REQUIRE_RESUME 0x4 00341 #define FLAG_TRANS2_FIND_CONTINUE 0x8 00342 #define FLAG_TRANS2_FIND_BACKUP_INTENT 0x10 00343 00344 /* UNIX CIFS Extensions - created by HP */ 00345 /* 00346 * UNIX CIFS Extensions have the range 0x200 - 0x2FF reserved. 00347 * Supposedly Microsoft have agreed to this. 00348 */ 00349 00350 #define MIN_UNIX_INFO_LEVEL 0x200 00351 #define MAX_UNIX_INFO_LEVEL 0x2FF 00352 00353 #define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL)) 00354 00355 #define SMB_QUERY_FILE_UNIX_BASIC 0x200 /* UNIX File Info*/ 00356 #define SMB_SET_FILE_UNIX_BASIC 0x200 00357 #define SMB_SET_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */ 00358 00359 #define SMB_MODE_NO_CHANGE 0xFFFFFFFF /* file mode value which */ 00360 /* means "don't change it" */ 00361 #define SMB_UID_NO_CHANGE 0xFFFFFFFF 00362 #define SMB_GID_NO_CHANGE 0xFFFFFFFF 00363 00364 #define SMB_SIZE_NO_CHANGE_LO 0xFFFFFFFF 00365 #define SMB_SIZE_NO_CHANGE_HI 0xFFFFFFFF 00366 00367 #define SMB_TIME_NO_CHANGE_LO 0xFFFFFFFF 00368 #define SMB_TIME_NO_CHANGE_HI 0xFFFFFFFF 00369 00370 /* 00371 Offset Size Name 00372 0 LARGE_INTEGER EndOfFile File size 00373 8 LARGE_INTEGER Blocks Number of bytes used on disk (st_blocks). 00374 16 LARGE_INTEGER CreationTime Creation time 00375 24 LARGE_INTEGER LastAccessTime Last access time 00376 32 LARGE_INTEGER LastModificationTime Last modification time 00377 40 LARGE_INTEGER Uid Numeric user id for the owner 00378 48 LARGE_INTEGER Gid Numeric group id of owner 00379 56 ULONG Type Enumeration specifying the pathname type: 00380 0 -- File 00381 1 -- Directory 00382 2 -- Symbolic link 00383 3 -- Character device 00384 4 -- Block device 00385 5 -- FIFO (named pipe) 00386 6 -- Unix domain socket 00387 00388 60 LARGE_INTEGER devmajor Major device number if type is device 00389 68 LARGE_INTEGER devminor Minor device number if type is device 00390 76 LARGE_INTEGER uniqueid This is a server-assigned unique id for the file. The client 00391 will typically map this onto an inode number. The scope of 00392 uniqueness is the share. 00393 84 LARGE_INTEGER permissions Standard UNIX file permissions - see below. 00394 92 LARGE_INTEGER nlinks The number of directory entries that map to this entry 00395 (number of hard links) 00396 00397 100 - end. 00398 */ 00399 00400 #define SMB_FILE_UNIX_BASIC_SIZE 100 00401 00402 /* UNIX filetype mappings. */ 00403 00404 #define UNIX_TYPE_FILE 0 00405 #define UNIX_TYPE_DIR 1 00406 #define UNIX_TYPE_SYMLINK 2 00407 #define UNIX_TYPE_CHARDEV 3 00408 #define UNIX_TYPE_BLKDEV 4 00409 #define UNIX_TYPE_FIFO 5 00410 #define UNIX_TYPE_SOCKET 6 00411 #define UNIX_TYPE_UNKNOWN 0xFFFFFFFF 00412 00413 /* 00414 * Oh this is fun. "Standard UNIX permissions" has no 00415 * meaning in POSIX. We need to define the mapping onto 00416 * and off the wire as this was not done in the original HP 00417 * spec. JRA. 00418 */ 00419 00420 #define UNIX_X_OTH 0000001 00421 #define UNIX_W_OTH 0000002 00422 #define UNIX_R_OTH 0000004 00423 #define UNIX_X_GRP 0000010 00424 #define UNIX_W_GRP 0000020 00425 #define UNIX_R_GRP 0000040 00426 #define UNIX_X_USR 0000100 00427 #define UNIX_W_USR 0000200 00428 #define UNIX_R_USR 0000400 00429 #define UNIX_STICKY 0001000 00430 #define UNIX_SET_GID 0002000 00431 #define UNIX_SET_UID 0004000 00432 00433 /* Masks for the above */ 00434 #define UNIX_OTH_MASK 0000007 00435 #define UNIX_GRP_MASK 0000070 00436 #define UNIX_USR_MASK 0000700 00437 #define UNIX_PERM_MASK 0000777 00438 #define UNIX_EXTRA_MASK 0007000 00439 #define UNIX_ALL_MASK 0007777 00440 00441 /* Flags for chflags (CIFS_UNIX_EXTATTR_CAP capability) and 00442 * SMB_QUERY_FILE_UNIX_INFO2. 00443 */ 00444 #define EXT_SECURE_DELETE 0x00000001 00445 #define EXT_ENABLE_UNDELETE 0x00000002 00446 #define EXT_SYNCHRONOUS 0x00000004 00447 #define EXT_IMMUTABLE 0x00000008 00448 #define EXT_OPEN_APPEND_ONLY 0x00000010 00449 #define EXT_DO_NOT_BACKUP 0x00000020 00450 #define EXT_NO_UPDATE_ATIME 0x00000040 00451 #define EXT_HIDDEN 0x00000080 00452 00453 #define SMB_QUERY_FILE_UNIX_LINK 0x201 00454 #define SMB_SET_FILE_UNIX_LINK 0x201 00455 #define SMB_SET_FILE_UNIX_HLINK 0x203 00456 /* SMB_QUERY_POSIX_ACL 0x204 see below */ 00457 #define SMB_QUERY_XATTR 0x205 /* need for non-user XATTRs */ 00458 #define SMB_QUERY_ATTR_FLAGS 0x206 /* chflags, chattr */ 00459 #define SMB_SET_ATTR_FLAGS 0x206 00460 #define SMB_QUERY_POSIX_PERMISSION 0x207 00461 /* Only valid for qfileinfo */ 00462 #define SMB_QUERY_POSIX_LOCK 0x208 00463 /* Only valid for setfileinfo */ 00464 #define SMB_SET_POSIX_LOCK 0x208 00465 00466 /* The set info levels for POSIX path operations. */ 00467 #define SMB_POSIX_PATH_OPEN 0x209 00468 #define SMB_POSIX_PATH_UNLINK 0x20A 00469 00470 #define SMB_QUERY_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */ 00471 #define SMB_SET_FILE_UNIX_INFO2 0x20B 00472 00473 /* 00474 SMB_QUERY_FILE_UNIX_INFO2 is SMB_QUERY_FILE_UNIX_BASIC with create 00475 time and file flags appended. The corresponding info level for 00476 findfirst/findnext is SMB_FIND_FILE_UNIX_INFO2. 00477 Size Offset Value 00478 --------------------- 00479 0 LARGE_INTEGER EndOfFile File size 00480 8 LARGE_INTEGER Blocks Number of blocks used on disk 00481 16 LARGE_INTEGER ChangeTime Attribute change time 00482 24 LARGE_INTEGER LastAccessTime Last access time 00483 32 LARGE_INTEGER LastModificationTime Last modification time 00484 40 LARGE_INTEGER Uid Numeric user id for the owner 00485 48 LARGE_INTEGER Gid Numeric group id of owner 00486 56 ULONG Type Enumeration specifying the file type 00487 60 LARGE_INTEGER devmajor Major device number if type is device 00488 68 LARGE_INTEGER devminor Minor device number if type is device 00489 76 LARGE_INTEGER uniqueid This is a server-assigned unique id 00490 84 LARGE_INTEGER permissions Standard UNIX permissions 00491 92 LARGE_INTEGER nlinks Number of hard links 00492 100 LARGE_INTEGER CreationTime Create/birth time 00493 108 ULONG FileFlags File flags enumeration 00494 112 ULONG FileFlagsMask Mask of valid flags 00495 */ 00496 00497 /* Transact 2 Find First levels */ 00498 #define SMB_FIND_FILE_UNIX 0x202 00499 #define SMB_FIND_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */ 00500 00501 #define SMB_FILE_UNIX_INFO2_SIZE 116 00502 00503 /* 00504 Info level for TRANS2_QFSINFO - returns version of CIFS UNIX extensions, plus 00505 64-bits worth of capability fun :-). 00506 Use the same info level for TRANS2_SETFSINFO 00507 */ 00508 00509 #define SMB_QUERY_CIFS_UNIX_INFO 0x200 00510 #define SMB_SET_CIFS_UNIX_INFO 0x200 00511 00512 /* Returns or sets the following. 00513 00514 UINT16 major version number 00515 UINT16 minor version number 00516 LARGE_INTEGER capability bitfield 00517 00518 */ 00519 00520 #define CIFS_UNIX_MAJOR_VERSION 1 00521 #define CIFS_UNIX_MINOR_VERSION 0 00522 00523 #define CIFS_UNIX_FCNTL_LOCKS_CAP 0x1 00524 #define CIFS_UNIX_POSIX_ACLS_CAP 0x2 00525 #define CIFS_UNIX_XATTTR_CAP 0x4 /* for support of other xattr 00526 namespaces such as system, 00527 security and trusted */ 00528 #define CIFS_UNIX_EXTATTR_CAP 0x8 /* for support of chattr 00529 (chflags) and lsattr */ 00530 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x10 /* Use POSIX pathnames on the wire. */ 00531 #define CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20 /* We can cope with POSIX open/mkdir/unlink etc. */ 00532 00533 00534 #define SMB_QUERY_POSIX_FS_INFO 0x201 00535 00536 /* Returns FILE_SYSTEM_POSIX_INFO struct as follows 00537 (NB For undefined values return -1 in that field) 00538 le32 OptimalTransferSize; bsize on some os, iosize on other os, This 00539 is a hint to the client about best size. Server 00540 can return -1 if no preference, ie if SMB 00541 negotiated size is adequate for optimal 00542 read/write performance 00543 le32 BlockSize; (often 512 bytes) NB: BlockSize * TotalBlocks = disk space 00544 le64 TotalBlocks; redundant with other infolevels but easy to ret here 00545 le64 BlocksAvail; although redundant, easy to return 00546 le64 UserBlocksAvail; bavail 00547 le64 TotalFileNodes; 00548 le64 FreeFileNodes; 00549 le64 FileSysIdentifier; fsid 00550 (NB statfs field Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call) 00551 (NB statfs field flags can come from FILE_SYSTEM_DEVICE_INFO call) 00552 */ 00553 00554 /* ... more as we think of them :-). */ 00555 00556 /* SMB POSIX ACL definitions. */ 00557 /* Wire format is (all little endian) : 00558 00559 [2 bytes] - Version number. 00560 [2 bytes] - Number of ACE entries to follow. 00561 [2 bytes] - Number of default ACE entries to follow. 00562 ------------------------------------- 00563 ^ 00564 | 00565 ACE entries 00566 | 00567 v 00568 ------------------------------------- 00569 ^ 00570 | 00571 Default ACE entries 00572 | 00573 v 00574 ------------------------------------- 00575 00576 Where an ACE entry looks like : 00577 00578 [1 byte] - Entry type. 00579 00580 Entry types are : 00581 00582 ACL_USER_OBJ 0x01 00583 ACL_USER 0x02 00584 ACL_GROUP_OBJ 0x04 00585 ACL_GROUP 0x08 00586 ACL_MASK 0x10 00587 ACL_OTHER 0x20 00588 00589 [1 byte] - permissions (perm_t) 00590 00591 perm_t types are : 00592 00593 ACL_READ 0x04 00594 ACL_WRITE 0x02 00595 ACL_EXECUTE 0x01 00596 00597 [8 bytes] - uid/gid to apply this permission to. 00598 00599 In the same format as the uid/gid fields in the other 00600 UNIX extensions definitions. Use 0xFFFFFFFFFFFFFFFF for 00601 the MASK and OTHER entry types. 00602 00603 If the Number of ACE entries for either file or default ACE's 00604 is set to 0xFFFF this means ignore this kind of ACE (and the 00605 number of entries sent will be zero. 00606 00607 */ 00608 00609 #define SMB_QUERY_POSIX_WHOAMI 0x202 00610 00611 enum smb_whoami_flags { 00612 SMB_WHOAMI_GUEST = 0x1 /* Logged in as (or squashed to) guest */ 00613 }; 00614 00615 /* Mask of which WHOAMI bits are valid. This should make it easier for clients 00616 * to cope with servers that have different sets of WHOAMI flags (as more get 00617 * added). 00618 */ 00619 #define SMB_WHOAMI_MASK 0x00000001 00620 00621 /* 00622 SMBWhoami - Query the user mapping performed by the server for the 00623 connected tree. This is a subcommand of the TRANS2_QFSINFO. 00624 00625 Returns: 00626 4 bytes unsigned - mapping flags (smb_whoami_flags) 00627 4 bytes unsigned - flags mask 00628 00629 8 bytes unsigned - primary UID 00630 8 bytes unsigned - primary GID 00631 4 bytes unsigned - number of supplementary GIDs 00632 4 bytes unsigned - number of SIDs 00633 4 bytes unsigned - SID list byte count 00634 4 bytes - pad / reserved (must be zero) 00635 00636 8 bytes unsigned[] - list of GIDs (may be empty) 00637 DOM_SID[] - list of SIDs (may be empty) 00638 */ 00639 00640 /* The query/set info levels for POSIX ACLs. */ 00641 #define SMB_QUERY_POSIX_ACL 0x204 00642 #define SMB_SET_POSIX_ACL 0x204 00643 00644 /* Current on the wire ACL version. */ 00645 #define SMB_POSIX_ACL_VERSION 1 00646 00647 /* ACE entry type. */ 00648 #define SMB_POSIX_ACL_USER_OBJ 0x01 00649 #define SMB_POSIX_ACL_USER 0x02 00650 #define SMB_POSIX_ACL_GROUP_OBJ 0x04 00651 #define SMB_POSIX_ACL_GROUP 0x08 00652 #define SMB_POSIX_ACL_MASK 0x10 00653 #define SMB_POSIX_ACL_OTHER 0x20 00654 00655 /* perm_t types. */ 00656 #define SMB_POSIX_ACL_READ 0x04 00657 #define SMB_POSIX_ACL_WRITE 0x02 00658 #define SMB_POSIX_ACL_EXECUTE 0x01 00659 00660 #define SMB_POSIX_ACL_HEADER_SIZE 6 00661 #define SMB_POSIX_ACL_ENTRY_SIZE 10 00662 00663 #define SMB_POSIX_IGNORE_ACE_ENTRIES 0xFFFF 00664 00665 /* Definition of data block of SMB_SET_POSIX_LOCK */ 00666 /* 00667 [2 bytes] lock_type - 0 = Read, 1 = Write, 2 = Unlock 00668 [2 bytes] lock_flags - 1 = Wait (only valid for setlock) 00669 [4 bytes] pid = locking context. 00670 [8 bytes] start = unsigned 64 bits. 00671 [8 bytes] length = unsigned 64 bits. 00672 */ 00673 00674 #define POSIX_LOCK_TYPE_OFFSET 0 00675 #define POSIX_LOCK_FLAGS_OFFSET 2 00676 #define POSIX_LOCK_PID_OFFSET 4 00677 #define POSIX_LOCK_START_OFFSET 8 00678 #define POSIX_LOCK_LEN_OFFSET 16 00679 #define POSIX_LOCK_DATA_SIZE 24 00680 00681 #define POSIX_LOCK_FLAG_NOWAIT 0 00682 #define POSIX_LOCK_FLAG_WAIT 1 00683 00684 #define POSIX_LOCK_TYPE_READ 0 00685 #define POSIX_LOCK_TYPE_WRITE 1 00686 #define POSIX_LOCK_TYPE_UNLOCK 2 00687 00688 /* SMB_POSIX_PATH_OPEN "open_mode" definitions. */ 00689 #define SMB_O_RDONLY 0x1 00690 #define SMB_O_WRONLY 0x2 00691 #define SMB_O_RDWR 0x4 00692 00693 #define SMB_ACCMODE 0x7 00694 00695 #define SMB_O_CREAT 0x10 00696 #define SMB_O_EXCL 0x20 00697 #define SMB_O_TRUNC 0x40 00698 #define SMB_O_APPEND 0x80 00699 #define SMB_O_SYNC 0x100 00700 #define SMB_O_DIRECTORY 0x200 00701 #define SMB_O_NOFOLLOW 0x400 00702 #define SMB_O_DIRECT 0x800 00703 00704 /* Definition of request data block for SMB_POSIX_PATH_OPEN */ 00705 /* 00706 [4 bytes] flags (as smb_ntcreate_Flags). 00707 [4 bytes] open_mode - SMB_O_xxx flags above. 00708 [8 bytes] mode_t (permissions) - same encoding as "Standard UNIX permissions" above in SMB_SET_FILE_UNIX_BASIC. 00709 [2 bytes] ret_info_level - optimization. Info level to be returned. 00710 */ 00711 00712 /* Definition of reply data block for SMB_POSIX_PATH_OPEN */ 00713 00714 #define SMB_NO_INFO_LEVEL_RETURNED 0xFFFF 00715 00716 /* 00717 [2 bytes] - flags field. Identical to flags reply for oplock response field in SMBNTCreateX) 00718 [2 bytes] - FID returned. 00719 [4 bytes] - CreateAction (same as in NTCreateX response). 00720 [2 bytes] - reply info level - as requested or 0xFFFF if not available. 00721 [2 bytes] - padding (must be zero) 00722 [n bytes] - info level reply - if available. 00723 */ 00724 00725 /* Definition of request data block for SMB_POSIX_UNLINK */ 00726 /* 00727 [2 bytes] flags (defined below). 00728 */ 00729 00730 #define SMB_POSIX_UNLINK_FILE_TARGET 0 00731 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1 00732 00733 #endif
1.4.7