1 /* SPDX-License-Identifier: LGPL-2.1 */ 2 /* 3 * 4 * Copyright (c) International Business Machines Corp., 2002,2009 5 * Author(s): Steve French (sfrench@us.ibm.com) 6 * 7 */ 8 9 #ifndef _CIFSPDU_H 10 #define _CIFSPDU_H 11 12 #include <net/sock.h> 13 #include <linux/unaligned.h> 14 #include "../common/smbfsctl.h" 15 #include "../common/smb2pdu.h" 16 17 #define CIFS_PROT 0 18 #define POSIX_PROT (CIFS_PROT+1) 19 #define BAD_PROT 0xFFFF 20 21 /* SMB command codes: 22 * See MS-CIFS 2.2.2.1 23 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses 24 * (ie which include no useful data other than the SMB error code itself). 25 * This can allow us to avoid response buffer allocations and copy in some cases 26 */ 27 #define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */ 28 #define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */ 29 #define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */ 30 #define SMB_COM_FLUSH 0x05 /* triv req/rsp */ 31 #define SMB_COM_DELETE 0x06 /* trivial response */ 32 #define SMB_COM_RENAME 0x07 /* trivial response */ 33 #define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */ 34 #define SMB_COM_SETATTR 0x09 /* trivial response */ 35 #define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */ 36 #define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/ 37 #define SMB_COM_ECHO 0x2B /* echo request */ 38 #define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */ 39 #define SMB_COM_READ_ANDX 0x2E 40 #define SMB_COM_WRITE_ANDX 0x2F 41 #define SMB_COM_TRANSACTION2 0x32 42 #define SMB_COM_TRANSACTION2_SECONDARY 0x33 43 #define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */ 44 #define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */ 45 #define SMB_COM_NEGOTIATE 0x72 46 #define SMB_COM_SESSION_SETUP_ANDX 0x73 47 #define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */ 48 #define SMB_COM_TREE_CONNECT_ANDX 0x75 49 #define SMB_COM_NT_TRANSACT 0xA0 50 #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1 51 #define SMB_COM_NT_CREATE_ANDX 0xA2 52 #define SMB_COM_NT_CANCEL 0xA4 /* no response */ 53 #define SMB_COM_NT_RENAME 0xA5 /* trivial response */ 54 55 /* Transact2 subcommand codes */ 56 #define TRANS2_OPEN 0x00 57 #define TRANS2_FIND_FIRST 0x01 58 #define TRANS2_FIND_NEXT 0x02 59 #define TRANS2_QUERY_FS_INFORMATION 0x03 60 #define TRANS2_SET_FS_INFORMATION 0x04 61 #define TRANS2_QUERY_PATH_INFORMATION 0x05 62 #define TRANS2_SET_PATH_INFORMATION 0x06 63 #define TRANS2_QUERY_FILE_INFORMATION 0x07 64 #define TRANS2_SET_FILE_INFORMATION 0x08 65 #define TRANS2_GET_DFS_REFERRAL 0x10 66 #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11 67 68 /* SMB Transact (Named Pipe) subcommand codes */ 69 #define TRANS_SET_NMPIPE_STATE 0x0001 70 #define TRANS_RAW_READ_NMPIPE 0x0011 71 #define TRANS_QUERY_NMPIPE_STATE 0x0021 72 #define TRANS_QUERY_NMPIPE_INFO 0x0022 73 #define TRANS_PEEK_NMPIPE 0x0023 74 #define TRANS_TRANSACT_NMPIPE 0x0026 75 #define TRANS_RAW_WRITE_NMPIPE 0x0031 76 #define TRANS_READ_NMPIPE 0x0036 77 #define TRANS_WRITE_NMPIPE 0x0037 78 #define TRANS_WAIT_NMPIPE 0x0053 79 #define TRANS_CALL_NMPIPE 0x0054 80 81 /* NT Transact subcommand codes */ 82 #define NT_TRANSACT_CREATE 0x01 83 #define NT_TRANSACT_IOCTL 0x02 84 #define NT_TRANSACT_SET_SECURITY_DESC 0x03 85 #define NT_TRANSACT_NOTIFY_CHANGE 0x04 86 #define NT_TRANSACT_RENAME 0x05 87 #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06 88 #define NT_TRANSACT_GET_USER_QUOTA 0x07 89 #define NT_TRANSACT_SET_USER_QUOTA 0x08 90 91 /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */ 92 /* among the requests (NTCreateX response is bigger with wct of 34) */ 93 #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */ 94 #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */ 95 96 /* internal cifs vfs structures */ 97 /***************************************************************** 98 * All constants go here 99 ***************************************************************** 100 */ 101 102 /* 103 * Starting value for maximum SMB size negotiation 104 */ 105 #define CIFS_MAX_MSGSIZE (4*4096) 106 107 /* 108 * Size of encrypted user password in bytes 109 */ 110 #define CIFS_ENCPWD_SIZE (16) 111 112 /* 113 * Size of the crypto key returned on the negotiate SMB in bytes 114 */ 115 #define CIFS_CRYPTO_KEY_SIZE (8) 116 117 /* 118 * Size of the ntlm client response 119 */ 120 #define CIFS_AUTH_RESP_SIZE (24) 121 122 /* 123 * Size of the session key (crypto key encrypted with the password 124 */ 125 #define CIFS_SESS_KEY_SIZE (16) 126 127 #define CIFS_SERVER_CHALLENGE_SIZE (8) 128 #define CIFS_HMAC_MD5_HASH_SIZE (16) 129 #define CIFS_CPHTXT_SIZE (16) 130 #define CIFS_NTHASH_SIZE (16) 131 132 /* 133 * Maximum user name length 134 */ 135 #define CIFS_UNLEN (20) 136 137 /* 138 * Flags on SMB open 139 */ 140 #define SMBOPEN_WRITE_THROUGH 0x4000 141 #define SMBOPEN_DENY_ALL 0x0010 142 #define SMBOPEN_DENY_WRITE 0x0020 143 #define SMBOPEN_DENY_READ 0x0030 144 #define SMBOPEN_DENY_NONE 0x0040 145 #define SMBOPEN_READ 0x0000 146 #define SMBOPEN_WRITE 0x0001 147 #define SMBOPEN_READWRITE 0x0002 148 #define SMBOPEN_EXECUTE 0x0003 149 150 #define SMBOPEN_OCREATE 0x0010 151 #define SMBOPEN_OTRUNC 0x0002 152 #define SMBOPEN_OAPPEND 0x0001 153 154 /* 155 * SMB flag definitions 156 * See MS-CIFS 2.2.3.1 157 */ 158 #define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */ 159 #define SMBFLG_RCV_POSTED 0x02 /* obsolete */ 160 #define SMBFLG_RSVD 0x04 161 #define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off 162 implies case sensitive file handling request) */ 163 #define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */ 164 #define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */ 165 #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */ 166 #define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */ 167 168 /* 169 * SMB flag2 definitions 170 * See MS-CIFS 2.2.3.1 171 * MS-SMB 2.2.3.1 172 */ 173 #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3) 174 path names in response */ 175 #define SMBFLG2_KNOWS_EAS cpu_to_le16(2) 176 #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4) 177 #define SMBFLG2_COMPRESSED (8) 178 #define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10) 179 #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40) 180 #define SMBFLG2_REPARSE_PATH (0x400) 181 #define SMBFLG2_EXT_SEC cpu_to_le16(0x800) 182 #define SMBFLG2_DFS cpu_to_le16(0x1000) 183 #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000) 184 #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000) 185 #define SMBFLG2_UNICODE cpu_to_le16(0x8000) 186 187 /* Combinations of file access permission bits */ 188 #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \ 189 | FILE_READ_ATTRIBUTES \ 190 | FILE_WRITE_ATTRIBUTES \ 191 | DELETE | READ_CONTROL | WRITE_DAC \ 192 | WRITE_OWNER | SYNCHRONIZE) 193 #define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \ 194 | FILE_READ_EA | FILE_WRITE_EA \ 195 | FILE_READ_ATTRIBUTES \ 196 | FILE_WRITE_ATTRIBUTES \ 197 | DELETE | READ_CONTROL | WRITE_DAC \ 198 | WRITE_OWNER | SYNCHRONIZE) 199 200 /* 201 * Invalid readdir handle 202 */ 203 #define CIFS_NO_HANDLE 0xFFFF 204 205 #define NO_CHANGE_64 0xFFFFFFFFFFFFFFFFULL 206 207 /* IPC$ in ASCII */ 208 #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24" 209 210 /* IPC$ in Unicode */ 211 #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00" 212 213 /* Unicode Null terminate 2 bytes of 0 */ 214 #define UNICODE_NULL "\x00\x00" 215 #define ASCII_NULL 0x00 216 217 /* 218 * Server type values (returned on EnumServer API 219 */ 220 #define CIFS_SV_TYPE_DC 0x00000008 221 #define CIFS_SV_TYPE_BACKDC 0x00000010 222 223 /* 224 * Alias type flags (From EnumAlias API call 225 */ 226 #define CIFS_ALIAS_TYPE_FILE 0x0001 227 #define CIFS_SHARE_TYPE_FILE 0x0000 228 229 /* 230 * File Attribute flags 231 */ 232 #define ATTR_READONLY 0x0001 /* See MS-CIFS 2.2.1.2.3 */ 233 #define ATTR_HIDDEN 0x0002 /* See MS-CIFS 2.2.1.2.3 */ 234 #define ATTR_SYSTEM 0x0004 /* See MS-CIFS 2.2.1.2.3 */ 235 #define ATTR_VOLUME 0x0008 236 #define ATTR_DIRECTORY 0x0010 /* See MS-CIFS 2.2.1.2.3 */ 237 #define ATTR_ARCHIVE 0x0020 /* See MS-CIFS 2.2.1.2.3 */ 238 #define ATTR_DEVICE 0x0040 239 #define ATTR_NORMAL 0x0080 /* See MS-CIFS 2.2.1.2.3 */ 240 #define ATTR_TEMPORARY 0x0100 /* See MS-CIFS 2.2.1.2.3 */ 241 #define ATTR_SPARSE 0x0200 /* See MS-SMB 2.2.1.2.1 */ 242 #define ATTR_REPARSE_POINT 0x0400 /* See MS-SMB 2.2.1.2.1 */ 243 #define ATTR_COMPRESSED 0x0800 /* See MS-CIFS 2.2.1.2.3 */ 244 #define ATTR_OFFLINE 0x1000 /* See MS-SMB 2.2.1.2.1 245 ie file not immediately available - 246 on offline storage */ 247 #define ATTR_NOT_CONTENT_INDEXED 0x2000 /* See MS-SMB 2.2.1.2.1 */ 248 #define ATTR_ENCRYPTED 0x4000 /* See MS-SMB 2.2.1.2.1 */ 249 #define ATTR_POSIX_SEMANTICS 0x0100000 /* See MS-CIFS 2.2.1.2.3 */ 250 #define ATTR_BACKUP_SEMANTICS 0x0200000 /* See MS-CIFS 2.2.1.2.3 */ 251 #define ATTR_DELETE_ON_CLOSE 0x0400000 /* See MS-CIFS 2.2.1.2.3 */ 252 #define ATTR_SEQUENTIAL_SCAN 0x0800000 /* See MS-CIFS 2.2.1.2.3 */ 253 #define ATTR_RANDOM_ACCESS 0x1000000 /* See MS-CIFS 2.2.1.2.3 */ 254 #define ATTR_NO_BUFFERING 0x2000000 /* See MS-CIFS 2.2.1.2.3 */ 255 #define ATTR_WRITE_THROUGH 0x8000000 /* See MS-CIFS 2.2.1.2.3 */ 256 257 /* ShareAccess flags */ 258 #define FILE_NO_SHARE 0x00000000 259 #define FILE_SHARE_READ 0x00000001 260 #define FILE_SHARE_WRITE 0x00000002 261 #define FILE_SHARE_DELETE 0x00000004 262 #define FILE_SHARE_ALL 0x00000007 263 264 /* CreateDisposition flags, similar to CreateAction as well */ 265 #define FILE_SUPERSEDE 0x00000000 266 #define FILE_OPEN 0x00000001 267 #define FILE_CREATE 0x00000002 268 #define FILE_OPEN_IF 0x00000003 269 #define FILE_OVERWRITE 0x00000004 270 #define FILE_OVERWRITE_IF 0x00000005 271 272 /* CreateOptions */ 273 #define CREATE_NOT_FILE 0x00000001 /* if set must not be file */ 274 #define CREATE_WRITE_THROUGH 0x00000002 275 #define CREATE_SEQUENTIAL 0x00000004 276 #define CREATE_NO_BUFFER 0x00000008 /* should not buffer on srv */ 277 #define CREATE_SYNC_ALERT 0x00000010 /* MBZ */ 278 #define CREATE_ASYNC_ALERT 0x00000020 /* MBZ */ 279 #define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */ 280 #define CREATE_TREE_CONNECTION 0x00000080 /* should be zero */ 281 #define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */ 282 #define CREATE_NO_EA_KNOWLEDGE 0x00000200 283 #define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete 284 "open for recovery" flag should 285 be zero in any case */ 286 #define CREATE_OPEN_FOR_RECOVERY 0x00000400 287 #define CREATE_RANDOM_ACCESS 0x00000800 288 #define CREATE_DELETE_ON_CLOSE 0x00001000 289 #define CREATE_OPEN_BY_ID 0x00002000 290 #define CREATE_OPEN_BACKUP_INTENT 0x00004000 291 #define CREATE_NO_COMPRESSION 0x00008000 292 #define CREATE_RESERVE_OPFILTER 0x00100000 /* should be zero */ 293 #define OPEN_REPARSE_POINT 0x00200000 294 #define OPEN_NO_RECALL 0x00400000 295 #define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */ 296 #define CREATE_OPTIONS_MASK 0x007FFFFF 297 #define CREATE_OPTION_READONLY 0x10000000 298 #define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */ 299 300 /* ImpersonationLevel flags */ 301 #define SECURITY_ANONYMOUS 0 302 #define SECURITY_IDENTIFICATION 1 303 #define SECURITY_IMPERSONATION 2 304 #define SECURITY_DELEGATION 3 305 306 /* SecurityFlags */ 307 #define SECURITY_CONTEXT_TRACKING 0x01 308 #define SECURITY_EFFECTIVE_ONLY 0x02 309 310 /* 311 * Default PID value, used in all SMBs where the PID is not important 312 */ 313 #define CIFS_DFT_PID 0x1234 314 315 /* 316 * We use the same routine for Copy and Move SMBs. This flag is used to 317 * distinguish 318 */ 319 #define CIFS_COPY_OP 1 320 #define CIFS_RENAME_OP 2 321 322 #define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */ 323 #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */ 324 325 /* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */ 326 static inline void * 327 BCC(struct smb_hdr *smb) 328 { 329 return (void *)smb + sizeof(*smb) + 2 * smb->WordCount; 330 } 331 332 /* given a pointer to an smb_hdr retrieve the pointer to the byte area */ 333 #define pByteArea(smb_var) (BCC(smb_var) + 2) 334 335 /* get the unconverted ByteCount for a SMB packet and return it */ 336 static inline __u16 337 get_bcc(struct smb_hdr *hdr) 338 { 339 __le16 *bc_ptr = (__le16 *)BCC(hdr); 340 341 return get_unaligned_le16(bc_ptr); 342 } 343 344 /* set the ByteCount for a SMB packet in little-endian */ 345 static inline void 346 put_bcc(__u16 count, struct smb_hdr *hdr) 347 { 348 __le16 *bc_ptr = (__le16 *)BCC(hdr); 349 350 put_unaligned_le16(count, bc_ptr); 351 } 352 353 /* 354 * Computer Name Length (since Netbios name was length 16 with last byte 0x20) 355 * No longer as important, now that TCP names are more commonly used to 356 * resolve hosts. 357 */ 358 #define CNLEN 15 359 360 /* 361 * Share Name Length (SNLEN) 362 * Note: This length was limited by the SMB used to get 363 * the Share info. NetShareEnum only returned 13 364 * chars, including the null termination. 365 * This was removed because it no longer is limiting. 366 */ 367 368 /* 369 * Comment Length 370 */ 371 #define MAXCOMMENTLEN 40 372 373 /* 374 * The OS/2 maximum path name 375 */ 376 #define MAX_PATHCONF 256 377 378 /* 379 * SMB frame definitions (following must be packed structs) 380 * See the SNIA CIFS Specification for details. 381 * 382 * The Naming convention is the lower case version of the 383 * smb command code name for the struct and this is typedef to the 384 * uppercase version of the same name with the prefix SMB_ removed 385 * for brevity. Although typedefs are not commonly used for 386 * structure definitions in the Linux kernel, their use in the 387 * CIFS standards document, which this code is based on, may 388 * make this one of the cases where typedefs for structures make 389 * sense to improve readability for readers of the standards doc. 390 * Typedefs can always be removed later if they are too distracting 391 * and they are only used for the CIFSs PDUs themselves, not 392 * internal cifs vfs structures 393 * 394 */ 395 396 #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */ 397 398 #define READ_RAW_ENABLE 1 399 #define WRITE_RAW_ENABLE 2 400 #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE) 401 #define SMB1_CLIENT_GUID_SIZE (16) 402 403 /* See MS-CIFS 2.2.4.52.2 */ 404 typedef struct smb_negotiate_rsp { 405 struct smb_hdr hdr; /* wct = 17 */ 406 __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */ 407 __u8 SecurityMode; 408 __le16 MaxMpxCount; 409 __le16 MaxNumberVcs; 410 __le32 MaxBufferSize; 411 __le32 MaxRawSize; 412 __le32 SessionKey; 413 __le32 Capabilities; /* see below */ 414 __le32 SystemTimeLow; 415 __le32 SystemTimeHigh; 416 __le16 ServerTimeZone; 417 __u8 EncryptionKeyLength; 418 __u16 ByteCount; 419 union { 420 /* cap extended security off */ 421 DECLARE_FLEX_ARRAY(unsigned char, EncryptionKey); 422 /* followed by Domain name - if extended security is off */ 423 /* followed by 16 bytes of server GUID */ 424 /* then security blob if cap_extended_security negotiated */ 425 struct { 426 unsigned char GUID[SMB1_CLIENT_GUID_SIZE]; 427 unsigned char SecurityBlob[]; 428 } __packed extended_response; 429 } __packed u; 430 } __packed SMB_NEGOTIATE_RSP; 431 432 /* SecurityMode bits */ 433 #define SECMODE_USER 0x01 /* off indicates share level security */ 434 #define SECMODE_PW_ENCRYPT 0x02 435 #define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */ 436 #define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */ 437 438 /* Negotiate response Capabilities */ 439 #define CAP_RAW_MODE 0x00000001 440 #define CAP_MPX_MODE 0x00000002 441 #define CAP_UNICODE 0x00000004 442 #define CAP_LARGE_FILES 0x00000008 443 #define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */ 444 #define CAP_RPC_REMOTE_APIS 0x00000020 445 #define CAP_STATUS32 0x00000040 446 #define CAP_LEVEL_II_OPLOCKS 0x00000080 447 #define CAP_LOCK_AND_READ 0x00000100 448 #define CAP_NT_FIND 0x00000200 449 #define CAP_DFS 0x00001000 450 #define CAP_INFOLEVEL_PASSTHRU 0x00002000 451 #define CAP_LARGE_READ_X 0x00004000 452 #define CAP_LARGE_WRITE_X 0x00008000 453 #define CAP_LWIO 0x00010000 /* support fctl_srv_req_resume_key */ 454 #define CAP_UNIX 0x00800000 455 #define CAP_COMPRESSED_DATA 0x02000000 456 #define CAP_DYNAMIC_REAUTH 0x20000000 457 #define CAP_PERSISTENT_HANDLES 0x40000000 458 #define CAP_EXTENDED_SECURITY 0x80000000 459 460 typedef union smb_com_session_setup_andx { 461 struct { /* request format */ 462 struct smb_hdr hdr; /* wct = 12 */ 463 __u8 AndXCommand; 464 __u8 AndXReserved; 465 __le16 AndXOffset; 466 __le16 MaxBufferSize; 467 __le16 MaxMpxCount; 468 __le16 VcNumber; 469 __le32 SessionKey; 470 __le16 SecurityBlobLength; 471 __u32 Reserved; 472 __le32 Capabilities; /* see below */ 473 __le16 ByteCount; 474 unsigned char SecurityBlob[]; /* followed by */ 475 /* STRING NativeOS */ 476 /* STRING NativeLanMan */ 477 } __packed req; /* NTLM request format (with 478 extended security */ 479 480 struct { /* request format */ 481 struct smb_hdr hdr; /* wct = 13 */ 482 __u8 AndXCommand; 483 __u8 AndXReserved; 484 __le16 AndXOffset; 485 __le16 MaxBufferSize; 486 __le16 MaxMpxCount; 487 __le16 VcNumber; 488 __le32 SessionKey; 489 __le16 CaseInsensitivePasswordLength; /* ASCII password len */ 490 __le16 CaseSensitivePasswordLength; /* Unicode password length*/ 491 __u32 Reserved; /* see below */ 492 __le32 Capabilities; 493 __le16 ByteCount; 494 unsigned char CaseInsensitivePassword[]; /* followed by: */ 495 /* unsigned char * CaseSensitivePassword; */ 496 /* STRING AccountName */ 497 /* STRING PrimaryDomain */ 498 /* STRING NativeOS */ 499 /* STRING NativeLanMan */ 500 } __packed req_no_secext; /* NTLM request format (without 501 extended security */ 502 503 struct { /* default (NTLM) response format */ 504 struct smb_hdr hdr; /* wct = 4 */ 505 __u8 AndXCommand; 506 __u8 AndXReserved; 507 __le16 AndXOffset; 508 __le16 Action; /* see below */ 509 __le16 SecurityBlobLength; 510 __u16 ByteCount; 511 unsigned char SecurityBlob[]; /* followed by */ 512 /* unsigned char * NativeOS; */ 513 /* unsigned char * NativeLanMan; */ 514 /* unsigned char * PrimaryDomain; */ 515 } __packed resp; /* NTLM response 516 (with or without extended sec) */ 517 518 struct { /* request format */ 519 struct smb_hdr hdr; /* wct = 10 */ 520 __u8 AndXCommand; 521 __u8 AndXReserved; 522 __le16 AndXOffset; 523 __le16 MaxBufferSize; 524 __le16 MaxMpxCount; 525 __le16 VcNumber; 526 __le32 SessionKey; 527 __le16 PasswordLength; 528 __u32 Reserved; /* encrypt key len and offset */ 529 __le16 ByteCount; 530 unsigned char AccountPassword[]; /* followed by */ 531 /* STRING AccountName */ 532 /* STRING PrimaryDomain */ 533 /* STRING NativeOS */ 534 /* STRING NativeLanMan */ 535 } __packed old_req; /* pre-NTLM (LANMAN2.1) req format */ 536 537 struct { /* default (NTLM) response format */ 538 struct smb_hdr hdr; /* wct = 3 */ 539 __u8 AndXCommand; 540 __u8 AndXReserved; 541 __le16 AndXOffset; 542 __le16 Action; /* see below */ 543 __u16 ByteCount; 544 unsigned char NativeOS[]; /* followed by */ 545 /* unsigned char * NativeLanMan; */ 546 /* unsigned char * PrimaryDomain; */ 547 } __packed old_resp; /* pre-NTLM (LANMAN2.1) response */ 548 } __packed SESSION_SETUP_ANDX; 549 550 /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */ 551 552 #define NTLMSSP_SERVER_TYPE 1 553 #define NTLMSSP_DOMAIN_TYPE 2 554 #define NTLMSSP_FQ_DOMAIN_TYPE 3 555 #define NTLMSSP_DNS_DOMAIN_TYPE 4 556 #define NTLMSSP_DNS_PARENT_TYPE 5 557 558 struct ntlmssp2_name { 559 __le16 type; 560 __le16 length; 561 __u8 data[]; 562 } __packed; 563 564 struct ntlmv2_resp { 565 union { 566 char ntlmv2_hash[CIFS_ENCPWD_SIZE]; 567 struct { 568 __u8 reserved[8]; 569 __u8 key[CIFS_SERVER_CHALLENGE_SIZE]; 570 } __packed challenge; 571 } __packed; 572 __le32 blob_signature; 573 __u32 reserved; 574 __le64 time; 575 __u64 client_chal; /* random */ 576 __u32 reserved2; 577 /* array of name entries could follow ending in minimum 4 byte struct */ 578 } __packed; 579 580 581 #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux" 582 583 584 /* 585 * Capabilities bits (for NTLM SessSetup request) 586 * See MS-CIFS 2.2.4.52.2 587 * MS-SMB 2.2.4.5.2.1 588 */ 589 #define CAP_UNICODE 0x00000004 590 #define CAP_LARGE_FILES 0x00000008 591 #define CAP_NT_SMBS 0x00000010 592 #define CAP_STATUS32 0x00000040 593 #define CAP_LEVEL_II_OPLOCKS 0x00000080 594 #define CAP_NT_FIND 0x00000200 /* reserved should be zero 595 (because NT_SMBs implies the same thing?) */ 596 #define CAP_BULK_TRANSFER 0x00000400 597 #define CAP_EXTENDED_SECURITY 0x80000000 598 599 /* Action bits */ 600 #define GUEST_LOGIN 1 601 602 typedef struct smb_com_tconx_req { 603 struct smb_hdr hdr; /* wct = 4 */ 604 __u8 AndXCommand; 605 __u8 AndXReserved; 606 __le16 AndXOffset; 607 __le16 Flags; /* see below */ 608 __le16 PasswordLength; 609 __le16 ByteCount; 610 unsigned char Password[]; /* followed by */ 611 /* STRING Path *//* \\server\share name */ 612 /* STRING Service */ 613 } __packed TCONX_REQ; 614 615 typedef struct smb_com_tconx_rsp { 616 struct smb_hdr hdr; /* wct = 3 , not extended response */ 617 __u8 AndXCommand; 618 __u8 AndXReserved; 619 __le16 AndXOffset; 620 __le16 OptionalSupport; /* see below */ 621 __u16 ByteCount; 622 unsigned char Service[]; /* always ASCII, not Unicode */ 623 /* STRING NativeFileSystem */ 624 } __packed TCONX_RSP; 625 626 typedef struct smb_com_tconx_rsp_ext { 627 struct smb_hdr hdr; /* wct = 7, extended response */ 628 __u8 AndXCommand; 629 __u8 AndXReserved; 630 __le16 AndXOffset; 631 __le16 OptionalSupport; /* see below */ 632 __le32 MaximalShareAccessRights; 633 __le32 GuestMaximalShareAccessRights; 634 __u16 ByteCount; 635 unsigned char Service[]; /* always ASCII, not Unicode */ 636 /* STRING NativeFileSystem */ 637 } __packed TCONX_RSP_EXT; 638 639 640 /* tree connect Flags */ 641 #define DISCONNECT_TID 0x0001 642 #define TCON_EXTENDED_SIGNATURES 0x0004 643 #define TCON_EXTENDED_SECINFO 0x0008 644 645 /* OptionalSupport bits */ 646 #define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits 647 (exclusive searches supported) */ 648 #define SMB_SHARE_IS_IN_DFS 0x0002 649 #define SMB_CSC_MASK 0x000C 650 /* CSC flags defined as follows */ 651 #define SMB_CSC_CACHE_MANUAL_REINT 0x0000 652 #define SMB_CSC_CACHE_AUTO_REINT 0x0004 653 #define SMB_CSC_CACHE_VDO 0x0008 654 #define SMB_CSC_NO_CACHING 0x000C 655 #define SMB_UNIQUE_FILE_NAME 0x0010 656 #define SMB_EXTENDED_SIGNATURES 0x0020 657 658 /* services 659 * 660 * A: ie disk 661 * LPT1: ie printer 662 * IPC ie named pipe 663 * COMM 664 * ????? ie any type 665 * 666 */ 667 668 typedef struct smb_com_echo_req { 669 struct smb_hdr hdr; 670 __le16 EchoCount; 671 __le16 ByteCount; 672 char Data[]; 673 } __packed ECHO_REQ; 674 675 typedef struct smb_com_echo_rsp { 676 struct smb_hdr hdr; 677 __le16 SequenceNumber; 678 __le16 ByteCount; 679 char Data[]; 680 } __packed ECHO_RSP; 681 682 typedef struct smb_com_logoff_andx_req { 683 struct smb_hdr hdr; /* wct = 2 */ 684 __u8 AndXCommand; 685 __u8 AndXReserved; 686 __u16 AndXOffset; 687 __u16 ByteCount; 688 } __packed LOGOFF_ANDX_REQ; 689 690 typedef struct smb_com_logoff_andx_rsp { 691 struct smb_hdr hdr; /* wct = 2 */ 692 __u8 AndXCommand; 693 __u8 AndXReserved; 694 __u16 AndXOffset; 695 __u16 ByteCount; 696 } __packed LOGOFF_ANDX_RSP; 697 698 typedef union smb_com_tree_disconnect { /* as an alternative can use flag on 699 tree_connect PDU to effect disconnect */ 700 /* tdis is probably simplest SMB PDU */ 701 struct { 702 struct smb_hdr hdr; /* wct = 0 */ 703 __u16 ByteCount; /* bcc = 0 */ 704 } __packed req; 705 struct { 706 struct smb_hdr hdr; /* wct = 0 */ 707 __u16 ByteCount; /* bcc = 0 */ 708 } __packed resp; 709 } __packed TREE_DISCONNECT; 710 711 typedef struct smb_com_close_req { 712 struct smb_hdr hdr; /* wct = 3 */ 713 __u16 FileID; 714 __u32 LastWriteTime; /* should be zero or -1 */ 715 __u16 ByteCount; /* 0 */ 716 } __packed CLOSE_REQ; 717 718 typedef struct smb_com_close_rsp { 719 struct smb_hdr hdr; /* wct = 0 */ 720 __u16 ByteCount; /* bct = 0 */ 721 } __packed CLOSE_RSP; 722 723 typedef struct smb_com_flush_req { 724 struct smb_hdr hdr; /* wct = 1 */ 725 __u16 FileID; 726 __u16 ByteCount; /* 0 */ 727 } __packed FLUSH_REQ; 728 729 typedef struct smb_com_findclose_req { 730 struct smb_hdr hdr; /* wct = 1 */ 731 __u16 FileID; 732 __u16 ByteCount; /* 0 */ 733 } __packed FINDCLOSE_REQ; 734 735 /* OpenFlags */ 736 #define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */ 737 #define REQ_OPLOCK 0x00000002 738 #define REQ_BATCHOPLOCK 0x00000004 739 #define REQ_OPENDIRONLY 0x00000008 740 #define REQ_EXTENDED_INFO 0x00000010 741 742 /* File type */ 743 #define DISK_TYPE 0x0000 744 #define BYTE_PIPE_TYPE 0x0001 745 #define MESSAGE_PIPE_TYPE 0x0002 746 #define PRINTER_TYPE 0x0003 747 #define COMM_DEV_TYPE 0x0004 748 #define UNKNOWN_TYPE 0xFFFF 749 750 /* Device Type or File Status Flags */ 751 #define NO_EAS 0x0001 752 #define NO_SUBSTREAMS 0x0002 753 #define NO_REPARSETAG 0x0004 754 /* following flags can apply if pipe */ 755 #define ICOUNT_MASK 0x00FF 756 #define PIPE_READ_MODE 0x0100 757 #define NAMED_PIPE_TYPE 0x0400 758 #define PIPE_END_POINT 0x4000 759 #define BLOCKING_NAMED_PIPE 0x8000 760 761 typedef struct smb_com_open_req { /* also handles create */ 762 struct smb_hdr hdr; /* wct = 24 */ 763 __u8 AndXCommand; 764 __u8 AndXReserved; 765 __le16 AndXOffset; 766 __u8 Reserved; /* Must Be Zero */ 767 __le16 NameLength; 768 __le32 OpenFlags; 769 __u32 RootDirectoryFid; 770 __le32 DesiredAccess; 771 __le64 AllocationSize; 772 __le32 FileAttributes; 773 __le32 ShareAccess; 774 __le32 CreateDisposition; 775 __le32 CreateOptions; 776 __le32 ImpersonationLevel; 777 __u8 SecurityFlags; 778 __le16 ByteCount; 779 char fileName[]; 780 } __packed OPEN_REQ; 781 782 /* open response: oplock levels */ 783 #define OPLOCK_NONE 0 784 #define OPLOCK_EXCLUSIVE 1 785 #define OPLOCK_BATCH 2 786 #define OPLOCK_READ 3 /* level 2 oplock */ 787 788 /* open response for CreateAction shifted left */ 789 #define CIFS_CREATE_ACTION 0x20000 /* file created */ 790 791 typedef struct smb_com_open_rsp { 792 struct smb_hdr hdr; /* wct = 34 BB */ 793 __u8 AndXCommand; 794 __u8 AndXReserved; 795 __le16 AndXOffset; 796 __u8 OplockLevel; 797 __u16 Fid; 798 __le32 CreateAction; 799 struct_group_attr(common_attributes, __packed, 800 __le64 CreationTime; 801 __le64 LastAccessTime; 802 __le64 LastWriteTime; 803 __le64 ChangeTime; 804 __le32 FileAttributes; 805 ); 806 __le64 AllocationSize; 807 __le64 EndOfFile; 808 __le16 FileType; 809 __le16 DeviceState; 810 __u8 DirectoryFlag; 811 __u16 ByteCount; /* bct = 0 */ 812 } __packed OPEN_RSP; 813 814 typedef struct smb_com_open_rsp_ext { 815 struct smb_hdr hdr; /* wct = 42 but meaningless due to MS bug? */ 816 __u8 AndXCommand; 817 __u8 AndXReserved; 818 __le16 AndXOffset; 819 __u8 OplockLevel; 820 __u16 Fid; 821 __le32 CreateAction; 822 __le64 CreationTime; 823 __le64 LastAccessTime; 824 __le64 LastWriteTime; 825 __le64 ChangeTime; 826 __le32 FileAttributes; 827 __le64 AllocationSize; 828 __le64 EndOfFile; 829 __le16 FileType; 830 __le16 DeviceState; 831 __u8 DirectoryFlag; 832 __u8 VolumeGUID[16]; 833 __u64 FileId; /* note no endian conversion - is opaque UniqueID */ 834 __le32 MaximalAccessRights; 835 __le32 GuestMaximalAccessRights; 836 __u16 ByteCount; /* bct = 0 */ 837 } __packed OPEN_RSP_EXT; 838 839 840 /* format of legacy open request */ 841 typedef struct smb_com_openx_req { 842 struct smb_hdr hdr; /* wct = 15 */ 843 __u8 AndXCommand; 844 __u8 AndXReserved; 845 __le16 AndXOffset; 846 __le16 OpenFlags; 847 __le16 Mode; 848 __le16 Sattr; /* search attributes */ 849 __le16 FileAttributes; /* dos attrs */ 850 __le32 CreateTime; /* os2 format */ 851 __le16 OpenFunction; 852 __le32 EndOfFile; 853 __le32 Timeout; 854 __le32 Reserved; 855 __le16 ByteCount; /* file name follows */ 856 char fileName[]; 857 } __packed OPENX_REQ; 858 859 typedef struct smb_com_openx_rsp { 860 struct smb_hdr hdr; /* wct = 15 */ 861 __u8 AndXCommand; 862 __u8 AndXReserved; 863 __le16 AndXOffset; 864 __u16 Fid; 865 __le16 FileAttributes; 866 __le32 LastWriteTime; /* os2 format */ 867 __le32 EndOfFile; 868 __le16 Access; 869 __le16 FileType; 870 __le16 IPCState; 871 __le16 Action; 872 __u32 FileId; 873 __u16 Reserved; 874 __u16 ByteCount; 875 } __packed OPENX_RSP; 876 877 /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */ 878 879 /* Legacy write request for older servers */ 880 typedef struct smb_com_writex_req { 881 struct smb_hdr hdr; /* wct = 12 */ 882 __u8 AndXCommand; 883 __u8 AndXReserved; 884 __le16 AndXOffset; 885 __u16 Fid; 886 __le32 OffsetLow; 887 __u32 Reserved; /* Timeout */ 888 __le16 WriteMode; /* 1 = write through */ 889 __le16 Remaining; 890 __le16 Reserved2; 891 __le16 DataLengthLow; 892 __le16 DataOffset; 893 __le16 ByteCount; 894 __u8 Pad; /* BB check for whether padded to DWORD 895 boundary and optimum performance here */ 896 char Data[]; 897 } __packed WRITEX_REQ; 898 899 typedef struct smb_com_write_req { 900 struct smb_hdr hdr; /* wct = 14 */ 901 __u8 AndXCommand; 902 __u8 AndXReserved; 903 __le16 AndXOffset; 904 __u16 Fid; 905 __le32 OffsetLow; 906 __u32 Reserved; 907 __le16 WriteMode; 908 __le16 Remaining; 909 __le16 DataLengthHigh; 910 __le16 DataLengthLow; 911 __le16 DataOffset; 912 __le32 OffsetHigh; 913 __le16 ByteCount; 914 __u8 Pad; /* BB check for whether padded to DWORD 915 boundary and optimum performance here */ 916 char Data[]; 917 } __packed WRITE_REQ; 918 919 typedef struct smb_com_write_rsp { 920 struct smb_hdr hdr; /* wct = 6 */ 921 __u8 AndXCommand; 922 __u8 AndXReserved; 923 __le16 AndXOffset; 924 __le16 Count; 925 __le16 Remaining; 926 __le16 CountHigh; 927 __u16 Reserved; 928 __u16 ByteCount; 929 } __packed WRITE_RSP; 930 931 /* legacy read request for older servers */ 932 typedef struct smb_com_readx_req { 933 struct smb_hdr hdr; /* wct = 10 */ 934 __u8 AndXCommand; 935 __u8 AndXReserved; 936 __le16 AndXOffset; 937 __u16 Fid; 938 __le32 OffsetLow; 939 __le16 MaxCount; 940 __le16 MinCount; /* obsolete */ 941 __le32 Reserved; 942 __le16 Remaining; 943 __le16 ByteCount; 944 } __packed READX_REQ; 945 946 typedef struct smb_com_read_req { 947 struct smb_hdr hdr; /* wct = 12 */ 948 __u8 AndXCommand; 949 __u8 AndXReserved; 950 __le16 AndXOffset; 951 __u16 Fid; 952 __le32 OffsetLow; 953 __le16 MaxCount; 954 __le16 MinCount; /* obsolete */ 955 __le32 MaxCountHigh; 956 __le16 Remaining; 957 __le32 OffsetHigh; 958 __le16 ByteCount; 959 } __packed READ_REQ; 960 961 typedef struct smb_com_read_rsp { 962 struct smb_hdr hdr; /* wct = 12 */ 963 __u8 AndXCommand; 964 __u8 AndXReserved; 965 __le16 AndXOffset; 966 __le16 Remaining; 967 __le16 DataCompactionMode; 968 __le16 Reserved; 969 __le16 DataLength; 970 __le16 DataOffset; 971 __le16 DataLengthHigh; 972 __u64 Reserved2; 973 __u16 ByteCount; 974 /* read response data immediately follows */ 975 } __packed READ_RSP; 976 977 typedef struct locking_andx_range { 978 __le16 Pid; 979 __le16 Pad; 980 __le32 OffsetHigh; 981 __le32 OffsetLow; 982 __le32 LengthHigh; 983 __le32 LengthLow; 984 } __packed LOCKING_ANDX_RANGE; 985 986 #define LOCKING_ANDX_SHARED_LOCK 0x01 987 #define LOCKING_ANDX_OPLOCK_RELEASE 0x02 988 #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04 989 #define LOCKING_ANDX_CANCEL_LOCK 0x08 990 #define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */ 991 992 typedef struct smb_com_lock_req { 993 struct smb_hdr hdr; /* wct = 8 */ 994 __u8 AndXCommand; 995 __u8 AndXReserved; 996 __le16 AndXOffset; 997 __u16 Fid; 998 __u8 LockType; 999 __u8 OplockLevel; 1000 __le32 Timeout; 1001 __le16 NumberOfUnlocks; 1002 __le16 NumberOfLocks; 1003 __le16 ByteCount; 1004 LOCKING_ANDX_RANGE Locks[]; 1005 } __packed LOCK_REQ; 1006 1007 /* lock type */ 1008 #define CIFS_RDLCK 0 1009 #define CIFS_WRLCK 1 1010 #define CIFS_UNLCK 2 1011 typedef struct cifs_posix_lock { 1012 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */ 1013 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */ 1014 __le32 pid; 1015 __le64 start; 1016 __le64 length; 1017 /* BB what about additional owner info to identify network client */ 1018 } __packed CIFS_POSIX_LOCK; 1019 1020 typedef struct smb_com_lock_rsp { 1021 struct smb_hdr hdr; /* wct = 2 */ 1022 __u8 AndXCommand; 1023 __u8 AndXReserved; 1024 __le16 AndXOffset; 1025 __u16 ByteCount; 1026 } __packed LOCK_RSP; 1027 1028 typedef struct smb_com_rename_req { 1029 struct smb_hdr hdr; /* wct = 1 */ 1030 __le16 SearchAttributes; /* target file attributes */ 1031 __le16 ByteCount; 1032 __u8 BufferFormat; /* 4 = ASCII or Unicode */ 1033 unsigned char OldFileName[]; 1034 /* followed by __u8 BufferFormat2 */ 1035 /* followed by NewFileName */ 1036 } __packed RENAME_REQ; 1037 1038 /* copy request flags */ 1039 #define COPY_MUST_BE_FILE 0x0001 1040 #define COPY_MUST_BE_DIR 0x0002 1041 #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */ 1042 #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */ 1043 #define COPY_VERIFY_WRITES 0x0010 1044 #define COPY_TREE 0x0020 1045 1046 typedef struct smb_com_copy_req { 1047 struct smb_hdr hdr; /* wct = 3 */ 1048 __u16 Tid2; 1049 __le16 OpenFunction; 1050 __le16 Flags; 1051 __le16 ByteCount; 1052 __u8 BufferFormat; /* 4 = ASCII or Unicode */ 1053 unsigned char OldFileName[]; 1054 /* followed by __u8 BufferFormat2 */ 1055 /* followed by NewFileName string */ 1056 } __packed COPY_REQ; 1057 1058 typedef struct smb_com_copy_rsp { 1059 struct smb_hdr hdr; /* wct = 1 */ 1060 __le16 CopyCount; /* number of files copied */ 1061 __u16 ByteCount; /* may be zero */ 1062 __u8 BufferFormat; /* 0x04 - only present if errored file follows */ 1063 unsigned char ErrorFileName[]; /* only present if error in copy */ 1064 } __packed COPY_RSP; 1065 1066 #define CREATE_HARD_LINK 0x103 1067 #define MOVEFILE_COPY_ALLOWED 0x0002 1068 #define MOVEFILE_REPLACE_EXISTING 0x0001 1069 1070 typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */ 1071 struct smb_hdr hdr; /* wct = 4 */ 1072 __le16 SearchAttributes; /* target file attributes */ 1073 __le16 Flags; /* spec says Information Level */ 1074 __le32 ClusterCount; 1075 __le16 ByteCount; 1076 __u8 BufferFormat; /* 4 = ASCII or Unicode */ 1077 unsigned char OldFileName[]; 1078 /* followed by __u8 BufferFormat2 */ 1079 /* followed by NewFileName */ 1080 } __packed NT_RENAME_REQ; 1081 1082 typedef struct smb_com_rename_rsp { 1083 struct smb_hdr hdr; /* wct = 0 */ 1084 __u16 ByteCount; /* bct = 0 */ 1085 } __packed RENAME_RSP; 1086 1087 typedef struct smb_com_delete_file_req { 1088 struct smb_hdr hdr; /* wct = 1 */ 1089 __le16 SearchAttributes; 1090 __le16 ByteCount; 1091 __u8 BufferFormat; /* 4 = ASCII */ 1092 unsigned char fileName[]; 1093 } __packed DELETE_FILE_REQ; 1094 1095 typedef struct smb_com_delete_file_rsp { 1096 struct smb_hdr hdr; /* wct = 0 */ 1097 __u16 ByteCount; /* bct = 0 */ 1098 } __packed DELETE_FILE_RSP; 1099 1100 typedef struct smb_com_delete_directory_req { 1101 struct smb_hdr hdr; /* wct = 0 */ 1102 __le16 ByteCount; 1103 __u8 BufferFormat; /* 4 = ASCII */ 1104 unsigned char DirName[]; 1105 } __packed DELETE_DIRECTORY_REQ; 1106 1107 typedef struct smb_com_delete_directory_rsp { 1108 struct smb_hdr hdr; /* wct = 0 */ 1109 __u16 ByteCount; /* bct = 0 */ 1110 } __packed DELETE_DIRECTORY_RSP; 1111 1112 typedef struct smb_com_create_directory_req { 1113 struct smb_hdr hdr; /* wct = 0 */ 1114 __le16 ByteCount; 1115 __u8 BufferFormat; /* 4 = ASCII */ 1116 unsigned char DirName[]; 1117 } __packed CREATE_DIRECTORY_REQ; 1118 1119 typedef struct smb_com_create_directory_rsp { 1120 struct smb_hdr hdr; /* wct = 0 */ 1121 __u16 ByteCount; /* bct = 0 */ 1122 } __packed CREATE_DIRECTORY_RSP; 1123 1124 typedef struct smb_com_query_information_req { 1125 struct smb_hdr hdr; /* wct = 0 */ 1126 __le16 ByteCount; /* 1 + namelen + 1 */ 1127 __u8 BufferFormat; /* 4 = ASCII */ 1128 unsigned char FileName[]; 1129 } __packed QUERY_INFORMATION_REQ; 1130 1131 typedef struct smb_com_query_information_rsp { 1132 struct smb_hdr hdr; /* wct = 10 */ 1133 __le16 attr; 1134 __le32 last_write_time; 1135 __le32 size; 1136 __u16 reserved[5]; 1137 __le16 ByteCount; /* bcc = 0 */ 1138 } __packed QUERY_INFORMATION_RSP; 1139 1140 typedef struct smb_com_setattr_req { 1141 struct smb_hdr hdr; /* wct = 8 */ 1142 __le16 attr; 1143 __le32 last_write_time; 1144 __le16 reserved[5]; /* must be zero */ 1145 __le16 ByteCount; 1146 __u8 BufferFormat; /* 4 = ASCII */ 1147 unsigned char fileName[]; 1148 } __packed SETATTR_REQ; 1149 1150 typedef struct smb_com_setattr_rsp { 1151 struct smb_hdr hdr; /* wct = 0 */ 1152 __u16 ByteCount; /* bct = 0 */ 1153 } __packed SETATTR_RSP; 1154 1155 /* empty wct response to setattr */ 1156 1157 /*******************************************************/ 1158 /* NT Transact structure definitions follow */ 1159 /* Currently only ioctl, acl (get security descriptor) */ 1160 /* and notify are implemented */ 1161 /*******************************************************/ 1162 typedef struct smb_com_ntransact_req { 1163 struct smb_hdr hdr; /* wct >= 19 */ 1164 __u8 MaxSetupCount; 1165 __u16 Reserved; 1166 __le32 TotalParameterCount; 1167 __le32 TotalDataCount; 1168 __le32 MaxParameterCount; 1169 __le32 MaxDataCount; 1170 __le32 ParameterCount; 1171 __le32 ParameterOffset; 1172 __le32 DataCount; 1173 __le32 DataOffset; 1174 __u8 SetupCount; /* four setup words follow subcommand */ 1175 /* SNIA spec incorrectly included spurious pad here */ 1176 __le16 SubCommand; /* 2 = IOCTL/FSCTL */ 1177 /* SetupCount words follow then */ 1178 __le16 ByteCount; 1179 __u8 Pad[3]; 1180 __u8 Parms[]; 1181 } __packed NTRANSACT_REQ; 1182 1183 typedef struct smb_com_ntransact_rsp { 1184 struct smb_hdr hdr; /* wct = 18 */ 1185 __u8 Reserved[3]; 1186 __le32 TotalParameterCount; 1187 __le32 TotalDataCount; 1188 __le32 ParameterCount; 1189 __le32 ParameterOffset; 1190 __le32 ParameterDisplacement; 1191 __le32 DataCount; 1192 __le32 DataOffset; 1193 __le32 DataDisplacement; 1194 __u8 SetupCount; /* 0 */ 1195 __u16 ByteCount; 1196 /* __u8 Pad[3]; */ 1197 /* parms and data follow */ 1198 } __packed NTRANSACT_RSP; 1199 1200 typedef struct smb_com_transaction_ioctl_req { 1201 struct smb_hdr hdr; /* wct = 23 */ 1202 __u8 MaxSetupCount; 1203 __u16 Reserved; 1204 __le32 TotalParameterCount; 1205 __le32 TotalDataCount; 1206 __le32 MaxParameterCount; 1207 __le32 MaxDataCount; 1208 __le32 ParameterCount; 1209 __le32 ParameterOffset; 1210 __le32 DataCount; 1211 __le32 DataOffset; 1212 __u8 SetupCount; /* four setup words follow subcommand */ 1213 /* SNIA spec incorrectly included spurious pad here */ 1214 __le16 SubCommand; /* 2 = IOCTL/FSCTL */ 1215 __le32 FunctionCode; 1216 __u16 Fid; 1217 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */ 1218 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */ 1219 __le16 ByteCount; 1220 __u8 Pad[3]; 1221 __u8 Data[]; 1222 } __packed TRANSACT_IOCTL_REQ; 1223 1224 typedef struct smb_com_transaction_compr_ioctl_req { 1225 struct smb_hdr hdr; /* wct = 23 */ 1226 __u8 MaxSetupCount; 1227 __u16 Reserved; 1228 __le32 TotalParameterCount; 1229 __le32 TotalDataCount; 1230 __le32 MaxParameterCount; 1231 __le32 MaxDataCount; 1232 __le32 ParameterCount; 1233 __le32 ParameterOffset; 1234 __le32 DataCount; 1235 __le32 DataOffset; 1236 __u8 SetupCount; /* four setup words follow subcommand */ 1237 /* SNIA spec incorrectly included spurious pad here */ 1238 __le16 SubCommand; /* 2 = IOCTL/FSCTL */ 1239 __le32 FunctionCode; 1240 __u16 Fid; 1241 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */ 1242 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */ 1243 __le16 ByteCount; 1244 __u8 Pad[3]; 1245 __le16 compression_state; /* See below for valid flags */ 1246 } __packed TRANSACT_COMPR_IOCTL_REQ; 1247 1248 /* compression state flags */ 1249 #define COMPRESSION_FORMAT_NONE 0x0000 1250 #define COMPRESSION_FORMAT_DEFAULT 0x0001 1251 #define COMPRESSION_FORMAT_LZNT1 0x0002 1252 1253 typedef struct smb_com_transaction_ioctl_rsp { 1254 struct smb_hdr hdr; /* wct = 19 */ 1255 __u8 Reserved[3]; 1256 __le32 TotalParameterCount; 1257 __le32 TotalDataCount; 1258 __le32 ParameterCount; 1259 __le32 ParameterOffset; 1260 __le32 ParameterDisplacement; 1261 __le32 DataCount; 1262 __le32 DataOffset; 1263 __le32 DataDisplacement; 1264 __u8 SetupCount; /* 1 */ 1265 __le16 ReturnedDataLen; 1266 __le16 ByteCount; 1267 } __packed TRANSACT_IOCTL_RSP; 1268 1269 #define CIFS_ACL_OWNER 1 1270 #define CIFS_ACL_GROUP 2 1271 #define CIFS_ACL_DACL 4 1272 #define CIFS_ACL_SACL 8 1273 1274 typedef struct smb_com_transaction_qsec_req { 1275 struct smb_hdr hdr; /* wct = 19 */ 1276 __u8 MaxSetupCount; 1277 __u16 Reserved; 1278 __le32 TotalParameterCount; 1279 __le32 TotalDataCount; 1280 __le32 MaxParameterCount; 1281 __le32 MaxDataCount; 1282 __le32 ParameterCount; 1283 __le32 ParameterOffset; 1284 __le32 DataCount; 1285 __le32 DataOffset; 1286 __u8 SetupCount; /* no setup words follow subcommand */ 1287 /* SNIA spec incorrectly included spurious pad here */ 1288 __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */ 1289 __le16 ByteCount; /* bcc = 3 + 8 */ 1290 __u8 Pad[3]; 1291 __u16 Fid; 1292 __u16 Reserved2; 1293 __le32 AclFlags; 1294 } __packed QUERY_SEC_DESC_REQ; 1295 1296 1297 typedef struct smb_com_transaction_ssec_req { 1298 struct smb_hdr hdr; /* wct = 19 */ 1299 __u8 MaxSetupCount; 1300 __u16 Reserved; 1301 __le32 TotalParameterCount; 1302 __le32 TotalDataCount; 1303 __le32 MaxParameterCount; 1304 __le32 MaxDataCount; 1305 __le32 ParameterCount; 1306 __le32 ParameterOffset; 1307 __le32 DataCount; 1308 __le32 DataOffset; 1309 __u8 SetupCount; /* no setup words follow subcommand */ 1310 /* SNIA spec incorrectly included spurious pad here */ 1311 __le16 SubCommand; /* 3 = SET_SECURITY_DESC */ 1312 __le16 ByteCount; /* bcc = 3 + 8 */ 1313 __u8 Pad[3]; 1314 __u16 Fid; 1315 __u16 Reserved2; 1316 __le32 AclFlags; 1317 } __packed SET_SEC_DESC_REQ; 1318 1319 typedef struct smb_com_transaction_change_notify_req { 1320 struct smb_hdr hdr; /* wct = 23 */ 1321 __u8 MaxSetupCount; 1322 __u16 Reserved; 1323 __le32 TotalParameterCount; 1324 __le32 TotalDataCount; 1325 __le32 MaxParameterCount; 1326 __le32 MaxDataCount; 1327 __le32 ParameterCount; 1328 __le32 ParameterOffset; 1329 __le32 DataCount; 1330 __le32 DataOffset; 1331 __u8 SetupCount; /* four setup words follow subcommand */ 1332 /* SNIA spec incorrectly included spurious pad here */ 1333 __le16 SubCommand;/* 4 = Change Notify */ 1334 __le32 CompletionFilter; /* operation to monitor */ 1335 __u16 Fid; 1336 __u8 WatchTree; /* 1 = Monitor subdirectories */ 1337 __u8 Reserved2; 1338 __le16 ByteCount; 1339 /* __u8 Pad[3];*/ 1340 /* __u8 Data[];*/ 1341 } __packed TRANSACT_CHANGE_NOTIFY_REQ; 1342 1343 /* BB eventually change to use generic ntransact rsp struct 1344 and validation routine */ 1345 typedef struct smb_com_transaction_change_notify_rsp { 1346 struct smb_hdr hdr; /* wct = 18 */ 1347 __u8 Reserved[3]; 1348 __le32 TotalParameterCount; 1349 __le32 TotalDataCount; 1350 __le32 ParameterCount; 1351 __le32 ParameterOffset; 1352 __le32 ParameterDisplacement; 1353 __le32 DataCount; 1354 __le32 DataOffset; 1355 __le32 DataDisplacement; 1356 __u8 SetupCount; /* 0 */ 1357 __u16 ByteCount; 1358 /* __u8 Pad[3]; */ 1359 } __packed TRANSACT_CHANGE_NOTIFY_RSP; 1360 /* Completion Filter flags for Notify */ 1361 #define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 1362 #define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 1363 #define FILE_NOTIFY_CHANGE_NAME 0x00000003 1364 #define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 1365 #define FILE_NOTIFY_CHANGE_SIZE 0x00000008 1366 #define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 1367 #define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020 1368 #define FILE_NOTIFY_CHANGE_CREATION 0x00000040 1369 #define FILE_NOTIFY_CHANGE_EA 0x00000080 1370 #define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 1371 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 1372 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 1373 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 1374 1375 #define FILE_ACTION_ADDED 0x00000001 1376 #define FILE_ACTION_REMOVED 0x00000002 1377 #define FILE_ACTION_MODIFIED 0x00000003 1378 #define FILE_ACTION_RENAMED_OLD_NAME 0x00000004 1379 #define FILE_ACTION_RENAMED_NEW_NAME 0x00000005 1380 #define FILE_ACTION_ADDED_STREAM 0x00000006 1381 #define FILE_ACTION_REMOVED_STREAM 0x00000007 1382 #define FILE_ACTION_MODIFIED_STREAM 0x00000008 1383 1384 /* response contains array of the following structures */ 1385 struct file_notify_information { 1386 __le32 NextEntryOffset; 1387 __le32 Action; 1388 __le32 FileNameLength; 1389 __u8 FileName[]; 1390 } __packed; 1391 1392 struct cifs_quota_data { 1393 __u32 rsrvd1; /* 0 */ 1394 __u32 sid_size; 1395 __u64 rsrvd2; /* 0 */ 1396 __u64 space_used; 1397 __u64 soft_limit; 1398 __u64 hard_limit; 1399 char sid[]; /* variable size? */ 1400 } __packed; 1401 1402 /* quota sub commands */ 1403 #define QUOTA_LIST_CONTINUE 0 1404 #define QUOTA_LIST_START 0x100 1405 #define QUOTA_FOR_SID 0x101 1406 1407 struct trans2_req { 1408 /* struct smb_hdr hdr precedes. Set wct = 14+ */ 1409 __le16 TotalParameterCount; 1410 __le16 TotalDataCount; 1411 __le16 MaxParameterCount; 1412 __le16 MaxDataCount; 1413 __u8 MaxSetupCount; 1414 __u8 Reserved; 1415 __le16 Flags; 1416 __le32 Timeout; 1417 __u16 Reserved2; 1418 __le16 ParameterCount; 1419 __le16 ParameterOffset; 1420 __le16 DataCount; 1421 __le16 DataOffset; 1422 __u8 SetupCount; 1423 __u8 Reserved3; 1424 __le16 SubCommand; /* 1st setup word - SetupCount words follow */ 1425 __le16 ByteCount; 1426 } __packed; 1427 1428 struct smb_t2_req { 1429 struct smb_hdr hdr; 1430 struct trans2_req t2_req; 1431 } __packed; 1432 1433 struct trans2_resp { 1434 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */ 1435 __le16 TotalParameterCount; 1436 __le16 TotalDataCount; 1437 __u16 Reserved; 1438 __le16 ParameterCount; 1439 __le16 ParameterOffset; 1440 __le16 ParameterDisplacement; 1441 __le16 DataCount; 1442 __le16 DataOffset; 1443 __le16 DataDisplacement; 1444 __u8 SetupCount; 1445 __u8 Reserved1; 1446 /* SetupWords[SetupCount]; 1447 __u16 ByteCount; 1448 __u16 Reserved2;*/ 1449 /* data area follows */ 1450 } __packed; 1451 1452 struct smb_t2_rsp { 1453 struct smb_hdr hdr; 1454 struct trans2_resp t2_rsp; 1455 } __packed; 1456 1457 /* PathInfo/FileInfo infolevels */ 1458 #define SMB_INFO_STANDARD 1 1459 #define SMB_SET_FILE_EA 2 1460 #define SMB_QUERY_FILE_EA_SIZE 2 1461 #define SMB_INFO_QUERY_EAS_FROM_LIST 3 1462 #define SMB_INFO_QUERY_ALL_EAS 4 1463 #define SMB_INFO_IS_NAME_VALID 6 1464 #define SMB_QUERY_FILE_BASIC_INFO 0x101 1465 #define SMB_QUERY_FILE_STANDARD_INFO 0x102 1466 #define SMB_QUERY_FILE_EA_INFO 0x103 1467 #define SMB_QUERY_FILE_NAME_INFO 0x104 1468 #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105 1469 #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106 1470 #define SMB_QUERY_FILE_ALL_INFO 0x107 1471 #define SMB_QUERY_ALT_NAME_INFO 0x108 1472 #define SMB_QUERY_FILE_STREAM_INFO 0x109 1473 #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B 1474 #define SMB_QUERY_FILE_UNIX_BASIC 0x200 1475 #define SMB_QUERY_FILE_UNIX_LINK 0x201 1476 #define SMB_QUERY_POSIX_ACL 0x204 1477 #define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */ 1478 #define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */ 1479 #define SMB_QUERY_POSIX_PERMISSION 0x207 1480 #define SMB_QUERY_POSIX_LOCK 0x208 1481 /* #define SMB_POSIX_OPEN 0x209 */ 1482 /* #define SMB_POSIX_UNLINK 0x20a */ 1483 #define SMB_QUERY_FILE__UNIX_INFO2 0x20b 1484 #define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee 1485 #define SMB_QUERY_FILE_ACCESS_INFO 0x3f0 1486 #define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */ 1487 #define SMB_QUERY_FILE_POSITION_INFO 0x3f6 1488 #define SMB_QUERY_FILE_MODE_INFO 0x3f8 1489 #define SMB_QUERY_FILE_ALGN_INFO 0x3f9 1490 1491 1492 #define SMB_SET_FILE_BASIC_INFO 0x101 1493 #define SMB_SET_FILE_DISPOSITION_INFO 0x102 1494 #define SMB_SET_FILE_ALLOCATION_INFO 0x103 1495 #define SMB_SET_FILE_END_OF_FILE_INFO 0x104 1496 #define SMB_SET_FILE_UNIX_BASIC 0x200 1497 #define SMB_SET_FILE_UNIX_LINK 0x201 1498 #define SMB_SET_FILE_UNIX_HLINK 0x203 1499 #define SMB_SET_POSIX_ACL 0x204 1500 #define SMB_SET_XATTR 0x205 1501 #define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */ 1502 #define SMB_SET_POSIX_LOCK 0x208 1503 #define SMB_POSIX_OPEN 0x209 1504 #define SMB_POSIX_UNLINK 0x20a 1505 #define SMB_SET_FILE_UNIX_INFO2 0x20b 1506 #define SMB_SET_FILE_BASIC_INFO2 0x3ec 1507 #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */ 1508 #define SMB_FILE_ALL_INFO2 0x3fa 1509 #define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb 1510 #define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc 1511 #define SMB_FILE_MOVE_CLUSTER_INFO 0x407 1512 #define SMB_FILE_QUOTA_INFO 0x408 1513 #define SMB_FILE_REPARSEPOINT_INFO 0x409 1514 #define SMB_FILE_MAXIMUM_INFO 0x40d 1515 1516 /* Find File infolevels */ 1517 #define SMB_FIND_FILE_INFO_STANDARD 0x001 1518 #define SMB_FIND_FILE_QUERY_EA_SIZE 0x002 1519 #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003 1520 #define SMB_FIND_FILE_DIRECTORY_INFO 0x101 1521 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102 1522 #define SMB_FIND_FILE_NAMES_INFO 0x103 1523 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104 1524 #define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105 1525 #define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106 1526 #define SMB_FIND_FILE_UNIX 0x202 1527 /* #define SMB_FIND_FILE_POSIX_INFO 0x064 */ 1528 1529 typedef struct smb_com_transaction2_qpi_req { 1530 struct smb_hdr hdr; /* wct = 14+ */ 1531 __le16 TotalParameterCount; 1532 __le16 TotalDataCount; 1533 __le16 MaxParameterCount; 1534 __le16 MaxDataCount; 1535 __u8 MaxSetupCount; 1536 __u8 Reserved; 1537 __le16 Flags; 1538 __le32 Timeout; 1539 __u16 Reserved2; 1540 __le16 ParameterCount; 1541 __le16 ParameterOffset; 1542 __le16 DataCount; 1543 __le16 DataOffset; 1544 __u8 SetupCount; 1545 __u8 Reserved3; 1546 __le16 SubCommand; /* one setup word */ 1547 __le16 ByteCount; 1548 __u8 Pad; 1549 __le16 InformationLevel; 1550 __u32 Reserved4; 1551 char FileName[]; 1552 } __packed TRANSACTION2_QPI_REQ; 1553 1554 typedef struct smb_com_transaction2_qpi_rsp { 1555 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1556 struct trans2_resp t2; 1557 __u16 ByteCount; 1558 __u16 Reserved2; /* parameter word is present for infolevels > 100 */ 1559 } __packed TRANSACTION2_QPI_RSP; 1560 1561 typedef struct smb_com_transaction2_spi_req { 1562 struct smb_hdr hdr; /* wct = 15 */ 1563 __le16 TotalParameterCount; 1564 __le16 TotalDataCount; 1565 __le16 MaxParameterCount; 1566 __le16 MaxDataCount; 1567 __u8 MaxSetupCount; 1568 __u8 Reserved; 1569 __le16 Flags; 1570 __le32 Timeout; 1571 __u16 Reserved2; 1572 __le16 ParameterCount; 1573 __le16 ParameterOffset; 1574 __le16 DataCount; 1575 __le16 DataOffset; 1576 __u8 SetupCount; 1577 __u8 Reserved3; 1578 __le16 SubCommand; /* one setup word */ 1579 __le16 ByteCount; 1580 __u8 Pad; 1581 __u16 Pad1; 1582 __le16 InformationLevel; 1583 __u32 Reserved4; 1584 char FileName[]; 1585 } __packed TRANSACTION2_SPI_REQ; 1586 1587 typedef struct smb_com_transaction2_spi_rsp { 1588 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1589 struct trans2_resp t2; 1590 __u16 ByteCount; 1591 __u16 Reserved2; /* parameter word is present for infolevels > 100 */ 1592 } __packed TRANSACTION2_SPI_RSP; 1593 1594 struct set_file_rename { 1595 __le32 overwrite; /* 1 = overwrite dest */ 1596 __u32 root_fid; /* zero */ 1597 __le32 target_name_len; 1598 char target_name[]; /* Must be unicode */ 1599 } __packed; 1600 1601 struct smb_com_transaction2_sfi_req { 1602 struct smb_hdr hdr; /* wct = 15 */ 1603 __le16 TotalParameterCount; 1604 __le16 TotalDataCount; 1605 __le16 MaxParameterCount; 1606 __le16 MaxDataCount; 1607 __u8 MaxSetupCount; 1608 __u8 Reserved; 1609 __le16 Flags; 1610 __le32 Timeout; 1611 __u16 Reserved2; 1612 __le16 ParameterCount; 1613 __le16 ParameterOffset; 1614 __le16 DataCount; 1615 __le16 DataOffset; 1616 __u8 SetupCount; 1617 __u8 Reserved3; 1618 __le16 SubCommand; /* one setup word */ 1619 __le16 ByteCount; 1620 __u8 Pad; 1621 __u16 Pad1; 1622 __u16 Fid; 1623 __le16 InformationLevel; 1624 __u16 Reserved4; 1625 __u8 payload[]; 1626 } __packed; 1627 1628 struct smb_com_transaction2_sfi_rsp { 1629 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1630 struct trans2_resp t2; 1631 __u16 ByteCount; 1632 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ 1633 } __packed; 1634 1635 struct smb_t2_qfi_req { 1636 struct smb_hdr hdr; 1637 struct trans2_req t2; 1638 __u8 Pad; 1639 __u16 Fid; 1640 __le16 InformationLevel; 1641 } __packed; 1642 1643 struct smb_t2_qfi_rsp { 1644 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1645 struct trans2_resp t2; 1646 __u16 ByteCount; 1647 __u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */ 1648 } __packed; 1649 1650 /* 1651 * Flags on T2 FINDFIRST and FINDNEXT 1652 */ 1653 #define CIFS_SEARCH_CLOSE_ALWAYS 0x0001 1654 #define CIFS_SEARCH_CLOSE_AT_END 0x0002 1655 #define CIFS_SEARCH_RETURN_RESUME 0x0004 1656 #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008 1657 #define CIFS_SEARCH_BACKUP_SEARCH 0x0010 1658 1659 /* 1660 * Size of the resume key on FINDFIRST and FINDNEXT calls 1661 */ 1662 #define CIFS_SMB_RESUME_KEY_SIZE 4 1663 1664 typedef struct smb_com_transaction2_ffirst_req { 1665 struct smb_hdr hdr; /* wct = 15 */ 1666 __le16 TotalParameterCount; 1667 __le16 TotalDataCount; 1668 __le16 MaxParameterCount; 1669 __le16 MaxDataCount; 1670 __u8 MaxSetupCount; 1671 __u8 Reserved; 1672 __le16 Flags; 1673 __le32 Timeout; 1674 __u16 Reserved2; 1675 __le16 ParameterCount; 1676 __le16 ParameterOffset; 1677 __le16 DataCount; 1678 __le16 DataOffset; 1679 __u8 SetupCount; /* one */ 1680 __u8 Reserved3; 1681 __le16 SubCommand; /* TRANS2_FIND_FIRST */ 1682 __le16 ByteCount; 1683 __u8 Pad; 1684 __le16 SearchAttributes; 1685 __le16 SearchCount; 1686 __le16 SearchFlags; 1687 __le16 InformationLevel; 1688 __le32 SearchStorageType; 1689 char FileName[]; 1690 } __packed TRANSACTION2_FFIRST_REQ; 1691 1692 typedef struct smb_com_transaction2_ffirst_rsp { 1693 struct smb_hdr hdr; /* wct = 10 */ 1694 struct trans2_resp t2; 1695 __u16 ByteCount; 1696 } __packed TRANSACTION2_FFIRST_RSP; 1697 1698 typedef struct smb_com_transaction2_ffirst_rsp_parms { 1699 __u16 SearchHandle; 1700 __le16 SearchCount; 1701 __le16 EndofSearch; 1702 __le16 EAErrorOffset; 1703 __le16 LastNameOffset; 1704 } __packed T2_FFIRST_RSP_PARMS; 1705 1706 typedef struct smb_com_transaction2_fnext_req { 1707 struct smb_hdr hdr; /* wct = 15 */ 1708 __le16 TotalParameterCount; 1709 __le16 TotalDataCount; 1710 __le16 MaxParameterCount; 1711 __le16 MaxDataCount; 1712 __u8 MaxSetupCount; 1713 __u8 Reserved; 1714 __le16 Flags; 1715 __le32 Timeout; 1716 __u16 Reserved2; 1717 __le16 ParameterCount; 1718 __le16 ParameterOffset; 1719 __le16 DataCount; 1720 __le16 DataOffset; 1721 __u8 SetupCount; /* one */ 1722 __u8 Reserved3; 1723 __le16 SubCommand; /* TRANS2_FIND_NEXT */ 1724 __le16 ByteCount; 1725 __u8 Pad; 1726 __u16 SearchHandle; 1727 __le16 SearchCount; 1728 __le16 InformationLevel; 1729 __u32 ResumeKey; 1730 __le16 SearchFlags; 1731 char ResumeFileName[]; 1732 } __packed TRANSACTION2_FNEXT_REQ; 1733 1734 typedef struct smb_com_transaction2_fnext_rsp { 1735 struct smb_hdr hdr; /* wct = 10 */ 1736 struct trans2_resp t2; 1737 __u16 ByteCount; 1738 } __packed TRANSACTION2_FNEXT_RSP; 1739 1740 typedef struct smb_com_transaction2_fnext_rsp_parms { 1741 __le16 SearchCount; 1742 __le16 EndofSearch; 1743 __le16 EAErrorOffset; 1744 __le16 LastNameOffset; 1745 } __packed T2_FNEXT_RSP_PARMS; 1746 1747 /* QFSInfo Levels */ 1748 #define SMB_INFO_ALLOCATION 1 1749 #define SMB_INFO_VOLUME 2 1750 #define SMB_QUERY_FS_VOLUME_INFO 0x102 1751 #define SMB_QUERY_FS_SIZE_INFO 0x103 1752 #define SMB_QUERY_FS_DEVICE_INFO 0x104 1753 #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105 1754 #define SMB_QUERY_CIFS_UNIX_INFO 0x200 1755 #define SMB_QUERY_POSIX_FS_INFO 0x201 1756 #define SMB_QUERY_POSIX_WHO_AM_I 0x202 1757 #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203 1758 #define SMB_QUERY_FS_PROXY 0x204 /* WAFS enabled. Returns structure 1759 FILE_SYSTEM__UNIX_INFO to tell 1760 whether new NTIOCTL available 1761 (0xACE) for WAN friendly SMB 1762 operations to be carried */ 1763 #define SMB_QUERY_LABEL_INFO 0x3ea 1764 #define SMB_QUERY_FS_QUOTA_INFO 0x3ee 1765 #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef 1766 #define SMB_QUERY_OBJECTID_INFO 0x3f0 1767 1768 typedef struct smb_com_transaction2_qfsi_req { 1769 struct smb_hdr hdr; /* wct = 14+ */ 1770 __le16 TotalParameterCount; 1771 __le16 TotalDataCount; 1772 __le16 MaxParameterCount; 1773 __le16 MaxDataCount; 1774 __u8 MaxSetupCount; 1775 __u8 Reserved; 1776 __le16 Flags; 1777 __le32 Timeout; 1778 __u16 Reserved2; 1779 __le16 ParameterCount; 1780 __le16 ParameterOffset; 1781 __le16 DataCount; 1782 __le16 DataOffset; 1783 __u8 SetupCount; 1784 __u8 Reserved3; 1785 __le16 SubCommand; /* one setup word */ 1786 __le16 ByteCount; 1787 __u8 Pad; 1788 __le16 InformationLevel; 1789 } __packed TRANSACTION2_QFSI_REQ; 1790 1791 typedef struct smb_com_transaction_qfsi_rsp { 1792 struct smb_hdr hdr; /* wct = 10 + SetupCount */ 1793 struct trans2_resp t2; 1794 __u16 ByteCount; 1795 __u8 Pad; /* may be three bytes? *//* followed by data area */ 1796 } __packed TRANSACTION2_QFSI_RSP; 1797 1798 typedef struct whoami_rsp_data { /* Query level 0x202 */ 1799 __u32 flags; /* 0 = Authenticated user 1 = GUEST */ 1800 __u32 mask; /* which flags bits server understands ie 0x0001 */ 1801 __u64 unix_user_id; 1802 __u64 unix_user_gid; 1803 __u32 number_of_supplementary_gids; /* may be zero */ 1804 __u32 number_of_sids; /* may be zero */ 1805 __u32 length_of_sid_array; /* in bytes - may be zero */ 1806 __u32 pad; /* reserved - MBZ */ 1807 /* __u64 gid_array[0]; */ /* may be empty */ 1808 /* __u8 * psid_list */ /* may be empty */ 1809 } __packed WHOAMI_RSP_DATA; 1810 1811 /* SETFSInfo Levels */ 1812 #define SMB_SET_CIFS_UNIX_INFO 0x200 1813 /* level 0x203 is defined above in list of QFS info levels */ 1814 /* #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203 */ 1815 1816 /* Level 0x200 request structure follows */ 1817 typedef struct smb_com_transaction2_setfsi_req { 1818 struct smb_hdr hdr; /* wct = 15 */ 1819 __le16 TotalParameterCount; 1820 __le16 TotalDataCount; 1821 __le16 MaxParameterCount; 1822 __le16 MaxDataCount; 1823 __u8 MaxSetupCount; 1824 __u8 Reserved; 1825 __le16 Flags; 1826 __le32 Timeout; 1827 __u16 Reserved2; 1828 __le16 ParameterCount; /* 4 */ 1829 __le16 ParameterOffset; 1830 __le16 DataCount; /* 12 */ 1831 __le16 DataOffset; 1832 __u8 SetupCount; /* one */ 1833 __u8 Reserved3; 1834 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */ 1835 __le16 ByteCount; 1836 __u8 Pad; 1837 __u16 FileNum; /* Parameters start. */ 1838 __le16 InformationLevel;/* Parameters end. */ 1839 __le16 ClientUnixMajor; /* Data start. */ 1840 __le16 ClientUnixMinor; 1841 __le64 ClientUnixCap; /* Data end */ 1842 } __packed TRANSACTION2_SETFSI_REQ; 1843 1844 /* level 0x203 request structure follows */ 1845 typedef struct smb_com_transaction2_setfs_enc_req { 1846 struct smb_hdr hdr; /* wct = 15 */ 1847 __le16 TotalParameterCount; 1848 __le16 TotalDataCount; 1849 __le16 MaxParameterCount; 1850 __le16 MaxDataCount; 1851 __u8 MaxSetupCount; 1852 __u8 Reserved; 1853 __le16 Flags; 1854 __le32 Timeout; 1855 __u16 Reserved2; 1856 __le16 ParameterCount; /* 4 */ 1857 __le16 ParameterOffset; 1858 __le16 DataCount; /* 12 */ 1859 __le16 DataOffset; 1860 __u8 SetupCount; /* one */ 1861 __u8 Reserved3; 1862 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */ 1863 __le16 ByteCount; 1864 __u8 Pad; 1865 __u16 Reserved4; /* Parameters start. */ 1866 __le16 InformationLevel;/* Parameters end. */ 1867 /* NTLMSSP Blob, Data start. */ 1868 } __packed TRANSACTION2_SETFSI_ENC_REQ; 1869 1870 /* response for setfsinfo levels 0x200 and 0x203 */ 1871 typedef struct smb_com_transaction2_setfsi_rsp { 1872 struct smb_hdr hdr; /* wct = 10 */ 1873 struct trans2_resp t2; 1874 __u16 ByteCount; 1875 } __packed TRANSACTION2_SETFSI_RSP; 1876 1877 typedef struct smb_com_transaction2_get_dfs_refer_req { 1878 struct smb_hdr hdr; /* wct = 15 */ 1879 __le16 TotalParameterCount; 1880 __le16 TotalDataCount; 1881 __le16 MaxParameterCount; 1882 __le16 MaxDataCount; 1883 __u8 MaxSetupCount; 1884 __u8 Reserved; 1885 __le16 Flags; 1886 __le32 Timeout; 1887 __u16 Reserved2; 1888 __le16 ParameterCount; 1889 __le16 ParameterOffset; 1890 __le16 DataCount; 1891 __le16 DataOffset; 1892 __u8 SetupCount; 1893 __u8 Reserved3; 1894 __le16 SubCommand; /* one setup word */ 1895 __le16 ByteCount; 1896 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max response length 1897 perhaps?) followed by one byte pad - doesn't 1898 seem to matter though */ 1899 __le16 MaxReferralLevel; 1900 char RequestFileName[]; 1901 } __packed TRANSACTION2_GET_DFS_REFER_REQ; 1902 1903 #define DFS_VERSION cpu_to_le16(0x0003) 1904 1905 /* DFS server target type */ 1906 #define DFS_TYPE_LINK 0x0000 /* also for sysvol targets */ 1907 #define DFS_TYPE_ROOT 0x0001 1908 1909 /* Referral Entry Flags */ 1910 #define DFS_NAME_LIST_REF 0x0200 /* set for domain or DC referral responses */ 1911 #define DFS_TARGET_SET_BOUNDARY 0x0400 /* only valid with version 4 dfs req */ 1912 1913 typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */ 1914 __le16 VersionNumber; /* must be 3 or 4 */ 1915 __le16 Size; 1916 __le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */ 1917 __le16 ReferralEntryFlags; 1918 __le32 TimeToLive; 1919 __le16 DfsPathOffset; 1920 __le16 DfsAlternatePathOffset; 1921 __le16 NetworkAddressOffset; /* offset of the link target */ 1922 __u8 ServiceSiteGuid[16]; /* MBZ, ignored */ 1923 } __packed REFERRAL3; 1924 1925 struct get_dfs_referral_rsp { 1926 __le16 PathConsumed; 1927 __le16 NumberOfReferrals; 1928 __le32 DFSFlags; 1929 REFERRAL3 referrals[]; /* array of level 3 dfs_referral structures */ 1930 /* followed by the strings pointed to by the referral structures */ 1931 } __packed; 1932 1933 typedef struct smb_com_transaction_get_dfs_refer_rsp { 1934 struct smb_hdr hdr; /* wct = 10 */ 1935 struct trans2_resp t2; 1936 __u16 ByteCount; 1937 __u8 Pad; 1938 struct get_dfs_referral_rsp dfs_data; 1939 } __packed TRANSACTION2_GET_DFS_REFER_RSP; 1940 1941 /* DFS Flags */ 1942 #define DFSREF_REFERRAL_SERVER 0x00000001 /* all targets are DFS roots */ 1943 #define DFSREF_STORAGE_SERVER 0x00000002 /* no further ref requests needed */ 1944 #define DFSREF_TARGET_FAILBACK 0x00000004 /* only for DFS referral version 4 */ 1945 1946 /* 1947 ************************************************************************ 1948 * All structs for everything above the SMB PDUs themselves 1949 * (such as the T2 level specific data) go here 1950 ************************************************************************ 1951 */ 1952 1953 /* 1954 * Information on a server 1955 */ 1956 1957 struct serverInfo { 1958 char name[16]; 1959 unsigned char versionMajor; 1960 unsigned char versionMinor; 1961 unsigned long type; 1962 unsigned int commentOffset; 1963 } __packed; 1964 1965 /* 1966 * The following structure is the format of the data returned on a NetShareEnum 1967 * with level "90" (x5A) 1968 */ 1969 1970 struct shareInfo { 1971 char shareName[13]; 1972 char pad; 1973 unsigned short type; 1974 unsigned int commentOffset; 1975 } __packed; 1976 1977 struct aliasInfo { 1978 char aliasName[9]; 1979 char pad; 1980 unsigned int commentOffset; 1981 unsigned char type[2]; 1982 } __packed; 1983 1984 struct aliasInfo92 { 1985 int aliasNameOffset; 1986 int serverNameOffset; 1987 int shareNameOffset; 1988 } __packed; 1989 1990 typedef struct { 1991 __le32 fsid; 1992 __le32 SectorsPerAllocationUnit; 1993 __le32 TotalAllocationUnits; 1994 __le32 FreeAllocationUnits; 1995 __le16 BytesPerSector; 1996 } __packed FILE_SYSTEM_ALLOC_INFO; 1997 1998 typedef struct { 1999 __le16 MajorVersionNumber; 2000 __le16 MinorVersionNumber; 2001 __le64 Capability; 2002 } __packed FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/ 2003 2004 /* Version numbers for CIFS UNIX major and minor. */ 2005 #define CIFS_UNIX_MAJOR_VERSION 1 2006 #define CIFS_UNIX_MINOR_VERSION 0 2007 2008 /* Linux/Unix extensions capability flags */ 2009 #define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */ 2010 #define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */ 2011 #define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */ 2012 #define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */ 2013 #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */ 2014 #define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based 2015 calls including posix open 2016 and posix unlink */ 2017 #define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up to 0xFFFF00 */ 2018 #define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080 2019 #define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */ 2020 #define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */ 2021 #define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and QFS PROXY call */ 2022 #ifdef CONFIG_CIFS_POSIX 2023 /* presumably don't need the 0x20 POSIX_PATH_OPS_CAP since we never send 2024 LockingX instead of posix locking call on unix sess (and we do not expect 2025 LockingX to use different (ie Windows) semantics than posix locking on 2026 the same session (if WINE needs to do this later, we can add this cap 2027 back in later */ 2028 /* #define CIFS_UNIX_CAP_MASK 0x000000fb */ 2029 #define CIFS_UNIX_CAP_MASK 0x000003db 2030 #else 2031 #define CIFS_UNIX_CAP_MASK 0x00000013 2032 #endif /* CONFIG_CIFS_POSIX */ 2033 2034 2035 #define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */ 2036 2037 /* DeviceType Flags */ 2038 #define FILE_DEVICE_CD_ROM 0x00000002 2039 #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 2040 #define FILE_DEVICE_DFS 0x00000006 2041 #define FILE_DEVICE_DISK 0x00000007 2042 #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 2043 #define FILE_DEVICE_FILE_SYSTEM 0x00000009 2044 #define FILE_DEVICE_NAMED_PIPE 0x00000011 2045 #define FILE_DEVICE_NETWORK 0x00000012 2046 #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 2047 #define FILE_DEVICE_NULL 0x00000015 2048 #define FILE_DEVICE_PARALLEL_PORT 0x00000016 2049 #define FILE_DEVICE_PRINTER 0x00000018 2050 #define FILE_DEVICE_SERIAL_PORT 0x0000001b 2051 #define FILE_DEVICE_STREAMS 0x0000001e 2052 #define FILE_DEVICE_TAPE 0x0000001f 2053 #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 2054 #define FILE_DEVICE_VIRTUAL_DISK 0x00000024 2055 #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 2056 2057 /* Device Characteristics */ 2058 #define FILE_REMOVABLE_MEDIA 0x00000001 2059 #define FILE_READ_ONLY_DEVICE 0x00000002 2060 #define FILE_FLOPPY_DISKETTE 0x00000004 2061 #define FILE_WRITE_ONCE_MEDIA 0x00000008 2062 #define FILE_REMOTE_DEVICE 0x00000010 2063 #define FILE_DEVICE_IS_MOUNTED 0x00000020 2064 #define FILE_VIRTUAL_VOLUME 0x00000040 2065 #define FILE_DEVICE_SECURE_OPEN 0x00000100 2066 #define FILE_CHARACTERISTIC_TS_DEVICE 0x00001000 2067 #define FILE_CHARACTERISTIC_WEBDAV_DEVICE 0x00002000 2068 #define FILE_PORTABLE_DEVICE 0x00004000 2069 #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000 2070 2071 /******************************************************************************/ 2072 /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */ 2073 /******************************************************************************/ 2074 typedef struct { /* data block encoding of response to level 263 QPathInfo */ 2075 struct_group_attr(common_attributes, __packed, 2076 __le64 CreationTime; 2077 __le64 LastAccessTime; 2078 __le64 LastWriteTime; 2079 __le64 ChangeTime; 2080 __le32 Attributes; 2081 ); 2082 __u32 Pad1; 2083 __le64 AllocationSize; 2084 __le64 EndOfFile; /* size ie offset to first free byte in file */ 2085 __le32 NumberOfLinks; /* hard links */ 2086 __u8 DeletePending; 2087 __u8 Directory; 2088 __u16 Pad2; 2089 __le32 EASize; 2090 __le32 FileNameLength; 2091 union { 2092 char __pad; 2093 DECLARE_FLEX_ARRAY(char, FileName); 2094 }; 2095 } __packed FILE_ALL_INFO; /* level 0x107 QPathInfo */ 2096 2097 typedef struct { 2098 __le64 AllocationSize; 2099 __le64 EndOfFile; /* size ie offset to first free byte in file */ 2100 __le32 NumberOfLinks; /* hard links */ 2101 __u8 DeletePending; 2102 __u8 Directory; 2103 __u16 Pad; 2104 } __packed FILE_STANDARD_INFO; /* level 0x102 QPathInfo */ 2105 2106 2107 /* defines for enumerating possible values of the Unix type field below */ 2108 #define UNIX_FILE 0 2109 #define UNIX_DIR 1 2110 #define UNIX_SYMLINK 2 2111 #define UNIX_CHARDEV 3 2112 #define UNIX_BLOCKDEV 4 2113 #define UNIX_FIFO 5 2114 #define UNIX_SOCKET 6 2115 typedef struct { 2116 __le64 EndOfFile; 2117 __le64 NumOfBytes; 2118 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */ 2119 __le64 LastAccessTime; 2120 __le64 LastModificationTime; 2121 __le64 Uid; 2122 __le64 Gid; 2123 __le32 Type; 2124 __le64 DevMajor; 2125 __le64 DevMinor; 2126 __le64 UniqueId; 2127 __le64 Permissions; 2128 __le64 Nlinks; 2129 } __packed FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */ 2130 2131 typedef struct { 2132 DECLARE_FLEX_ARRAY(char, LinkDest); 2133 } __packed FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */ 2134 2135 /* The following three structures are needed only for 2136 setting time to NT4 and some older servers via 2137 the primitive DOS time format */ 2138 typedef struct { 2139 __u16 Day:5; 2140 __u16 Month:4; 2141 __u16 Year:7; 2142 } __packed SMB_DATE; 2143 2144 typedef struct { 2145 __u16 TwoSeconds:5; 2146 __u16 Minutes:6; 2147 __u16 Hours:5; 2148 } __packed SMB_TIME; 2149 2150 typedef struct { 2151 __le16 CreationDate; /* SMB Date see above */ 2152 __le16 CreationTime; /* SMB Time */ 2153 __le16 LastAccessDate; 2154 __le16 LastAccessTime; 2155 __le16 LastWriteDate; 2156 __le16 LastWriteTime; 2157 __le32 DataSize; /* File Size (EOF) */ 2158 __le32 AllocationSize; 2159 __le16 Attributes; /* verify not u32 */ 2160 __le32 EASize; 2161 } __packed FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */ 2162 2163 typedef struct { 2164 __le64 CreationTime; 2165 __le64 LastAccessTime; 2166 __le64 LastWriteTime; 2167 __le64 ChangeTime; 2168 __le32 Attributes; 2169 __u32 Pad; 2170 } __packed FILE_BASIC_INFO; /* size info, level 0x101 */ 2171 2172 struct file_allocation_info { 2173 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */ 2174 } __packed; /* size used on disk, for level 0x103 for set, 0x105 for query */ 2175 2176 struct file_end_of_file_info { 2177 __le64 FileSize; /* offset to end of file */ 2178 } __packed; /* size info, level 0x104 for set, 0x106 for query */ 2179 2180 struct file_alt_name_info { 2181 DECLARE_FLEX_ARRAY(__u8, alt_name); 2182 } __packed; /* level 0x0108 */ 2183 2184 struct file_stream_info { 2185 __le32 number_of_streams; /* BB check sizes and verify location */ 2186 /* followed by info on streams themselves 2187 u64 size; 2188 u64 allocation_size 2189 stream info */ 2190 }; /* level 0x109 */ 2191 2192 struct file_compression_info { 2193 __le64 compressed_size; 2194 __le16 format; 2195 __u8 unit_shift; 2196 __u8 ch_shift; 2197 __u8 cl_shift; 2198 __u8 pad[3]; 2199 } __packed; /* level 0x10b */ 2200 2201 /* POSIX ACL set/query path info structures */ 2202 #define CIFS_ACL_VERSION 1 2203 struct cifs_posix_ace { /* access control entry (ACE) */ 2204 __u8 cifs_e_tag; 2205 __u8 cifs_e_perm; 2206 __le64 cifs_uid; /* or gid */ 2207 } __packed; 2208 2209 struct cifs_posix_acl { /* access control list (ACL) */ 2210 __le16 version; 2211 __le16 access_entry_count; /* access ACL - count of entries */ 2212 __le16 default_entry_count; /* default ACL - count of entries */ 2213 struct cifs_posix_ace ace_array[]; 2214 /* followed by struct cifs_posix_ace default_ace_array[] */ 2215 } __packed; /* level 0x204 */ 2216 2217 /* types of access control entries already defined in posix_acl.h */ 2218 /* #define CIFS_POSIX_ACL_USER_OBJ 0x01 2219 #define CIFS_POSIX_ACL_USER 0x02 2220 #define CIFS_POSIX_ACL_GROUP_OBJ 0x04 2221 #define CIFS_POSIX_ACL_GROUP 0x08 2222 #define CIFS_POSIX_ACL_MASK 0x10 2223 #define CIFS_POSIX_ACL_OTHER 0x20 */ 2224 2225 /* types of perms */ 2226 /* #define CIFS_POSIX_ACL_EXECUTE 0x01 2227 #define CIFS_POSIX_ACL_WRITE 0x02 2228 #define CIFS_POSIX_ACL_READ 0x04 */ 2229 2230 /* end of POSIX ACL definitions */ 2231 2232 /* POSIX Open Flags */ 2233 #define SMB_O_RDONLY 0x1 2234 #define SMB_O_WRONLY 0x2 2235 #define SMB_O_RDWR 0x4 2236 #define SMB_O_CREAT 0x10 2237 #define SMB_O_EXCL 0x20 2238 #define SMB_O_TRUNC 0x40 2239 #define SMB_O_APPEND 0x80 2240 #define SMB_O_SYNC 0x100 2241 #define SMB_O_DIRECTORY 0x200 2242 #define SMB_O_NOFOLLOW 0x400 2243 #define SMB_O_DIRECT 0x800 2244 2245 typedef struct { 2246 __le32 OpenFlags; /* same as NT CreateX */ 2247 __le32 PosixOpenFlags; 2248 __le64 Permissions; 2249 __le16 Level; /* reply level requested (see QPathInfo levels) */ 2250 } __packed OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */ 2251 2252 typedef struct { 2253 __le16 OplockFlags; 2254 __u16 Fid; 2255 __le32 CreateAction; 2256 __le16 ReturnedLevel; 2257 __le16 Pad; 2258 /* struct following varies based on requested level */ 2259 } __packed OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */ 2260 2261 #define SMB_POSIX_UNLINK_FILE_TARGET 0 2262 #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1 2263 2264 struct unlink_psx_rq { /* level 0x20a SetPathInfo */ 2265 __le16 type; 2266 } __packed; 2267 2268 struct file_internal_info { 2269 __le64 UniqueId; /* inode number */ 2270 } __packed; /* level 0x3ee */ 2271 2272 struct file_mode_info { 2273 __le32 Mode; 2274 } __packed; /* level 0x3f8 */ 2275 2276 struct file_attrib_tag { 2277 __le32 Attribute; 2278 __le32 ReparseTag; 2279 } __packed; /* level 0x40b */ 2280 2281 2282 /********************************************************/ 2283 /* FindFirst/FindNext transact2 data buffer formats */ 2284 /********************************************************/ 2285 2286 typedef struct { 2287 __le32 NextEntryOffset; 2288 __u32 ResumeKey; /* as with FileIndex - no need to convert */ 2289 FILE_UNIX_BASIC_INFO basic; 2290 union { 2291 char __pad; 2292 DECLARE_FLEX_ARRAY(char, FileName); 2293 }; 2294 } __packed FILE_UNIX_INFO; /* level 0x202 */ 2295 2296 typedef struct { 2297 __u32 ResumeKey; 2298 __le16 CreationDate; /* SMB Date */ 2299 __le16 CreationTime; /* SMB Time */ 2300 __le16 LastAccessDate; 2301 __le16 LastAccessTime; 2302 __le16 LastWriteDate; 2303 __le16 LastWriteTime; 2304 __le32 DataSize; /* File Size (EOF) */ 2305 __le32 AllocationSize; 2306 __le16 Attributes; /* verify not u32 */ 2307 __u8 FileNameLength; 2308 char FileName[]; 2309 } __packed FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */ 2310 2311 2312 struct fea { 2313 unsigned char EA_flags; 2314 __u8 name_len; 2315 __le16 value_len; 2316 char name[]; 2317 /* optionally followed by value */ 2318 } __packed; 2319 /* flags for _FEA.fEA */ 2320 #define FEA_NEEDEA 0x80 /* need EA bit */ 2321 2322 struct fealist { 2323 __le32 list_len; 2324 struct fea list; 2325 } __packed; 2326 2327 /* used to hold an arbitrary blob of data */ 2328 struct data_blob { 2329 __u8 *data; 2330 size_t length; 2331 void (*free) (struct data_blob *data_blob); 2332 } __packed; 2333 2334 2335 #ifdef CONFIG_CIFS_POSIX 2336 /* 2337 For better POSIX semantics from Linux client, (even better 2338 than the existing CIFS Unix Extensions) we need updated PDUs for: 2339 2340 1) PosixCreateX - to set and return the mode, inode#, device info and 2341 perhaps add a CreateDevice - to create Pipes and other special .inodes 2342 Also note POSIX open flags 2343 2) Close - to return the last write time to do cache across close 2344 more safely 2345 3) FindFirst return unique inode number - what about resume key, two 2346 forms short (matches readdir) and full (enough info to cache inodes) 2347 4) Mkdir - set mode 2348 2349 And under consideration: 2350 5) FindClose2 (return nanosecond timestamp ??) 2351 6) Use nanosecond timestamps throughout all time fields if 2352 corresponding attribute flag is set 2353 7) sendfile - handle based copy 2354 2355 what about fixing 64 bit alignment 2356 2357 There are also various legacy SMB/CIFS requests used as is 2358 2359 From existing Lanman and NTLM dialects: 2360 -------------------------------------- 2361 NEGOTIATE 2362 SESSION_SETUP_ANDX (BB which?) 2363 TREE_CONNECT_ANDX (BB which wct?) 2364 TREE_DISCONNECT (BB add volume timestamp on response) 2365 LOGOFF_ANDX 2366 DELETE (note delete open file behavior) 2367 DELETE_DIRECTORY 2368 READ_AND_X 2369 WRITE_AND_X 2370 LOCKING_AND_X (note posix lock semantics) 2371 RENAME (note rename across dirs and open file rename posix behaviors) 2372 NT_RENAME (for hardlinks) Is this good enough for all features? 2373 FIND_CLOSE2 2374 TRANSACTION2 (18 cases) 2375 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2 2376 (BB verify that never need to set allocation size) 2377 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via 2378 Unix ext?) 2379 2380 COPY (note support for copy across directories) - FUTURE, OPTIONAL 2381 setting/getting OS/2 EAs - FUTURE (BB can this handle 2382 setting Linux xattrs perfectly) - OPTIONAL 2383 dnotify - FUTURE, OPTIONAL 2384 quota - FUTURE, OPTIONAL 2385 2386 Note that various requests implemented for NT interop such as 2387 NT_TRANSACT (IOCTL) QueryReparseInfo 2388 are unneeded to servers compliant with the CIFS POSIX extensions 2389 2390 From CIFS Unix Extensions: 2391 ------------------------- 2392 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks 2393 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2) 2394 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK) 2395 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing 2396 inode fields 2397 Actually a need QUERY_FILE_UNIX_INFO 2398 since has inode num 2399 BB what about a) blksize/blkbits/blocks 2400 b) i_version 2401 c) i_rdev 2402 d) notify mask? 2403 e) generation 2404 f) size_seqcount 2405 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX 2406 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended 2407 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL 2408 */ 2409 2410 /* xsymlink is a symlink format (used by MacOS) that can be used 2411 to save symlink info in a regular file when 2412 mounted to operating systems that do not 2413 support the cifs Unix extensions or EAs (for xattr 2414 based symlinks). For such a file to be recognized 2415 as containing symlink data: 2416 2417 1) file size must be 1067, 2418 2) signature must begin file data, 2419 3) length field must be set to ASCII representation 2420 of a number which is less than or equal to 1024, 2421 4) md5 must match that of the path data */ 2422 2423 struct xsymlink { 2424 /* 1067 bytes */ 2425 char signature[4]; /* XSym */ /* not null terminated */ 2426 char cr0; /* \n */ 2427 /* ASCII representation of length (4 bytes decimal) terminated by \n not null */ 2428 char length[4]; 2429 char cr1; /* \n */ 2430 /* md5 of valid subset of path ie path[0] through path[length-1] */ 2431 __u8 md5[32]; 2432 char cr2; /* \n */ 2433 /* if room left, then end with \n then 0x20s by convention but not required */ 2434 char path[1024]; 2435 } __packed; 2436 2437 typedef struct file_xattr_info { 2438 /* BB do we need another field for flags? BB */ 2439 __u32 xattr_name_len; 2440 __u32 xattr_value_len; 2441 char xattr_name[]; 2442 /* followed by xattr_value[xattr_value_len], no pad */ 2443 } __packed FILE_XATTR_INFO; /* extended attribute info level 0x205 */ 2444 2445 /* flags for lsattr and chflags commands removed arein uapi/linux/fs.h */ 2446 2447 typedef struct file_chattr_info { 2448 __le64 mask; /* list of all possible attribute bits */ 2449 __le64 mode; /* list of actual attribute bits on this inode */ 2450 } __packed FILE_CHATTR_INFO; /* ext attributes (chattr, chflags) level 0x206 */ 2451 #endif /* POSIX */ 2452 #endif /* _CIFSPDU_H */ 2453