File Index
Files and directories
Sign in
FILE

cifspdu.h

File preview with syntax highlighting.

linux-6.19.14/fs/smb/client/cifspdu.h C
   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/smb1pdu.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 0x54 /* 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 */
 326static inline void *
 327BCC(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 */
 336static inline __u16
 337get_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 */
 345static inline void
 346put_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 */
 404typedef 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
 460typedef 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
 558struct ntlmssp2_name {
 559	__le16 type;
 560	__le16 length;
 561	__u8 data[];
 562} __packed;
 563
 564struct 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
 602typedef 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
 615typedef 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
 626typedef 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
 668typedef struct smb_com_echo_req {
 669	struct	smb_hdr hdr;
 670	__le16	EchoCount;
 671	__le16	ByteCount;
 672	char	Data[];
 673} __packed ECHO_REQ;
 674
 675typedef struct smb_com_echo_rsp {
 676	struct	smb_hdr hdr;
 677	__le16	SequenceNumber;
 678	__le16	ByteCount;
 679	char	Data[];
 680} __packed ECHO_RSP;
 681
 682typedef 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
 690typedef 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
 698typedef 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
 711typedef 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
 718typedef struct smb_com_close_rsp {
 719	struct smb_hdr hdr;	/* wct = 0 */
 720	__u16 ByteCount;	/* bct = 0 */
 721} __packed CLOSE_RSP;
 722
 723typedef struct smb_com_flush_req {
 724	struct smb_hdr hdr;	/* wct = 1 */
 725	__u16 FileID;
 726	__u16 ByteCount;	/* 0 */
 727} __packed FLUSH_REQ;
 728
 729typedef 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
 761typedef 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
 791typedef 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
 814typedef 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 */
 841typedef 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
 859typedef 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 */
 880typedef 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
 899typedef 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
 919typedef 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 */
 932typedef 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
 946typedef 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
 961typedef 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
 977typedef 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
 992typedef 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
1011typedef 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
1020typedef 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
1028typedef 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
1046typedef 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
1058typedef 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
1070typedef 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
1082typedef struct smb_com_rename_rsp {
1083	struct smb_hdr hdr;	/* wct = 0 */
1084	__u16 ByteCount;	/* bct = 0 */
1085} __packed RENAME_RSP;
1086
1087typedef 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
1095typedef struct smb_com_delete_file_rsp {
1096	struct smb_hdr hdr;	/* wct = 0 */
1097	__u16 ByteCount;	/* bct = 0 */
1098} __packed DELETE_FILE_RSP;
1099
1100typedef 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
1107typedef struct smb_com_delete_directory_rsp {
1108	struct smb_hdr hdr;	/* wct = 0 */
1109	__u16 ByteCount;	/* bct = 0 */
1110} __packed DELETE_DIRECTORY_RSP;
1111
1112typedef 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
1119typedef struct smb_com_create_directory_rsp {
1120	struct smb_hdr hdr;	/* wct = 0 */
1121	__u16 ByteCount;	/* bct = 0 */
1122} __packed CREATE_DIRECTORY_RSP;
1123
1124typedef 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
1131typedef 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
1140typedef 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
1150typedef 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/*******************************************************/
1162typedef 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
1183typedef 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
1200typedef 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
1224typedef 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
1253typedef 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
1274typedef 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
1297typedef 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
1319typedef 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 */
1345typedef 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
1361struct cifs_quota_data {
1362	__u32	rsrvd1;  /* 0 */
1363	__u32	sid_size;
1364	__u64	rsrvd2;  /* 0 */
1365	__u64	space_used;
1366	__u64	soft_limit;
1367	__u64	hard_limit;
1368	char	sid[];  /* variable size? */
1369} __packed;
1370
1371/* quota sub commands */
1372#define QUOTA_LIST_CONTINUE	    0
1373#define QUOTA_LIST_START	0x100
1374#define QUOTA_FOR_SID		0x101
1375
1376struct trans2_req {
1377	/* struct smb_hdr hdr precedes. Set wct = 14+ */
1378	__le16 TotalParameterCount;
1379	__le16 TotalDataCount;
1380	__le16 MaxParameterCount;
1381	__le16 MaxDataCount;
1382	__u8 MaxSetupCount;
1383	__u8 Reserved;
1384	__le16 Flags;
1385	__le32 Timeout;
1386	__u16 Reserved2;
1387	__le16 ParameterCount;
1388	__le16 ParameterOffset;
1389	__le16 DataCount;
1390	__le16 DataOffset;
1391	__u8 SetupCount;
1392	__u8 Reserved3;
1393	__le16 SubCommand; /* 1st setup word - SetupCount words follow */
1394	__le16 ByteCount;
1395} __packed;
1396
1397struct smb_t2_req {
1398	struct smb_hdr hdr;
1399	struct trans2_req t2_req;
1400} __packed;
1401
1402struct trans2_resp {
1403	/* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1404	__le16 TotalParameterCount;
1405	__le16 TotalDataCount;
1406	__u16 Reserved;
1407	__le16 ParameterCount;
1408	__le16 ParameterOffset;
1409	__le16 ParameterDisplacement;
1410	__le16 DataCount;
1411	__le16 DataOffset;
1412	__le16 DataDisplacement;
1413	__u8 SetupCount;
1414	__u8 Reserved1;
1415	/* SetupWords[SetupCount];
1416	__u16 ByteCount;
1417	__u16 Reserved2;*/
1418	/* data area follows */
1419} __packed;
1420
1421struct smb_t2_rsp {
1422	struct smb_hdr hdr;
1423	struct trans2_resp t2_rsp;
1424} __packed;
1425
1426/* PathInfo/FileInfo infolevels */
1427#define SMB_INFO_STANDARD                   1
1428#define SMB_SET_FILE_EA                     2
1429#define SMB_QUERY_FILE_EA_SIZE              2
1430#define SMB_INFO_QUERY_EAS_FROM_LIST        3
1431#define SMB_INFO_QUERY_ALL_EAS              4
1432#define SMB_INFO_IS_NAME_VALID              6
1433#define SMB_QUERY_FILE_BASIC_INFO       0x101
1434#define SMB_QUERY_FILE_STANDARD_INFO    0x102
1435#define SMB_QUERY_FILE_EA_INFO          0x103
1436#define SMB_QUERY_FILE_NAME_INFO        0x104
1437#define SMB_QUERY_FILE_ALLOCATION_INFO  0x105
1438#define SMB_QUERY_FILE_END_OF_FILEINFO  0x106
1439#define SMB_QUERY_FILE_ALL_INFO         0x107
1440#define SMB_QUERY_ALT_NAME_INFO         0x108
1441#define SMB_QUERY_FILE_STREAM_INFO      0x109
1442#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1443#define SMB_QUERY_FILE_UNIX_BASIC       0x200
1444#define SMB_QUERY_FILE_UNIX_LINK        0x201
1445#define SMB_QUERY_POSIX_ACL             0x204
1446#define SMB_QUERY_XATTR                 0x205  /* e.g. system EA name space */
1447#define SMB_QUERY_ATTR_FLAGS            0x206  /* append,immutable etc. */
1448#define SMB_QUERY_POSIX_PERMISSION      0x207
1449#define SMB_QUERY_POSIX_LOCK            0x208
1450/* #define SMB_POSIX_OPEN               0x209 */
1451/* #define SMB_POSIX_UNLINK             0x20a */
1452#define SMB_QUERY_FILE__UNIX_INFO2      0x20b
1453#define SMB_QUERY_FILE_INTERNAL_INFO    0x3ee
1454#define SMB_QUERY_FILE_ACCESS_INFO      0x3f0
1455#define SMB_QUERY_FILE_NAME_INFO2       0x3f1 /* 0x30 bytes */
1456#define SMB_QUERY_FILE_POSITION_INFO    0x3f6
1457#define SMB_QUERY_FILE_MODE_INFO        0x3f8
1458#define SMB_QUERY_FILE_ALGN_INFO        0x3f9
1459
1460
1461#define SMB_SET_FILE_BASIC_INFO	        0x101
1462#define SMB_SET_FILE_DISPOSITION_INFO   0x102
1463#define SMB_SET_FILE_ALLOCATION_INFO    0x103
1464#define SMB_SET_FILE_END_OF_FILE_INFO   0x104
1465#define SMB_SET_FILE_UNIX_BASIC         0x200
1466#define SMB_SET_FILE_UNIX_LINK          0x201
1467#define SMB_SET_FILE_UNIX_HLINK         0x203
1468#define SMB_SET_POSIX_ACL               0x204
1469#define SMB_SET_XATTR                   0x205
1470#define SMB_SET_ATTR_FLAGS              0x206  /* append, immutable etc. */
1471#define SMB_SET_POSIX_LOCK              0x208
1472#define SMB_POSIX_OPEN                  0x209
1473#define SMB_POSIX_UNLINK                0x20a
1474#define SMB_SET_FILE_UNIX_INFO2         0x20b
1475#define SMB_SET_FILE_BASIC_INFO2        0x3ec
1476#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1477#define SMB_FILE_ALL_INFO2              0x3fa
1478#define SMB_SET_FILE_ALLOCATION_INFO2   0x3fb
1479#define SMB_SET_FILE_END_OF_FILE_INFO2  0x3fc
1480#define SMB_FILE_MOVE_CLUSTER_INFO      0x407
1481#define SMB_FILE_QUOTA_INFO             0x408
1482#define SMB_FILE_REPARSEPOINT_INFO      0x409
1483#define SMB_FILE_MAXIMUM_INFO           0x40d
1484
1485/* Find File infolevels */
1486#define SMB_FIND_FILE_INFO_STANDARD       0x001
1487#define SMB_FIND_FILE_QUERY_EA_SIZE       0x002
1488#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1489#define SMB_FIND_FILE_DIRECTORY_INFO      0x101
1490#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1491#define SMB_FIND_FILE_NAMES_INFO          0x103
1492#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1493#define SMB_FIND_FILE_ID_FULL_DIR_INFO    0x105
1494#define SMB_FIND_FILE_ID_BOTH_DIR_INFO    0x106
1495#define SMB_FIND_FILE_UNIX                0x202
1496/* #define SMB_FIND_FILE_POSIX_INFO          0x064 */
1497
1498typedef struct smb_com_transaction2_qpi_req {
1499	struct smb_hdr hdr;	/* wct = 14+ */
1500	__le16 TotalParameterCount;
1501	__le16 TotalDataCount;
1502	__le16 MaxParameterCount;
1503	__le16 MaxDataCount;
1504	__u8 MaxSetupCount;
1505	__u8 Reserved;
1506	__le16 Flags;
1507	__le32 Timeout;
1508	__u16 Reserved2;
1509	__le16 ParameterCount;
1510	__le16 ParameterOffset;
1511	__le16 DataCount;
1512	__le16 DataOffset;
1513	__u8 SetupCount;
1514	__u8 Reserved3;
1515	__le16 SubCommand;	/* one setup word */
1516	__le16 ByteCount;
1517	__u8 Pad;
1518	__le16 InformationLevel;
1519	__u32 Reserved4;
1520	char FileName[];
1521} __packed TRANSACTION2_QPI_REQ;
1522
1523typedef struct smb_com_transaction2_qpi_rsp {
1524	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
1525	struct trans2_resp t2;
1526	__u16 ByteCount;
1527	__u16 Reserved2; /* parameter word is present for infolevels > 100 */
1528} __packed TRANSACTION2_QPI_RSP;
1529
1530typedef struct smb_com_transaction2_spi_req {
1531	struct smb_hdr hdr;	/* wct = 15 */
1532	__le16 TotalParameterCount;
1533	__le16 TotalDataCount;
1534	__le16 MaxParameterCount;
1535	__le16 MaxDataCount;
1536	__u8 MaxSetupCount;
1537	__u8 Reserved;
1538	__le16 Flags;
1539	__le32 Timeout;
1540	__u16 Reserved2;
1541	__le16 ParameterCount;
1542	__le16 ParameterOffset;
1543	__le16 DataCount;
1544	__le16 DataOffset;
1545	__u8 SetupCount;
1546	__u8 Reserved3;
1547	__le16 SubCommand;	/* one setup word */
1548	__le16 ByteCount;
1549	__u8 Pad;
1550	__u16 Pad1;
1551	__le16 InformationLevel;
1552	__u32 Reserved4;
1553	char FileName[];
1554} __packed TRANSACTION2_SPI_REQ;
1555
1556typedef struct smb_com_transaction2_spi_rsp {
1557	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
1558	struct trans2_resp t2;
1559	__u16 ByteCount;
1560	__u16 Reserved2; /* parameter word is present for infolevels > 100 */
1561} __packed TRANSACTION2_SPI_RSP;
1562
1563struct set_file_rename {
1564	__le32 overwrite;   /* 1 = overwrite dest */
1565	__u32 root_fid;   /* zero */
1566	__le32 target_name_len;
1567	char  target_name[];  /* Must be unicode */
1568} __packed;
1569
1570struct smb_com_transaction2_sfi_req {
1571	struct smb_hdr hdr;	/* wct = 15 */
1572	__le16 TotalParameterCount;
1573	__le16 TotalDataCount;
1574	__le16 MaxParameterCount;
1575	__le16 MaxDataCount;
1576	__u8 MaxSetupCount;
1577	__u8 Reserved;
1578	__le16 Flags;
1579	__le32 Timeout;
1580	__u16 Reserved2;
1581	__le16 ParameterCount;
1582	__le16 ParameterOffset;
1583	__le16 DataCount;
1584	__le16 DataOffset;
1585	__u8 SetupCount;
1586	__u8 Reserved3;
1587	__le16 SubCommand;	/* one setup word */
1588	__le16 ByteCount;
1589	__u8 Pad;
1590	__u16 Pad1;
1591	__u16 Fid;
1592	__le16 InformationLevel;
1593	__u16 Reserved4;
1594	__u8  payload[];
1595} __packed;
1596
1597struct smb_com_transaction2_sfi_rsp {
1598	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
1599	struct trans2_resp t2;
1600	__u16 ByteCount;
1601	__u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
1602} __packed;
1603
1604struct smb_t2_qfi_req {
1605	struct	smb_hdr hdr;
1606	struct	trans2_req t2;
1607	__u8	Pad;
1608	__u16	Fid;
1609	__le16	InformationLevel;
1610} __packed;
1611
1612struct smb_t2_qfi_rsp {
1613	struct smb_hdr hdr;     /* wct = 10 + SetupCount */
1614	struct trans2_resp t2;
1615	__u16 ByteCount;
1616	__u16 Reserved2; /* parameter word reserved - present for infolevels > 100 */
1617} __packed;
1618
1619/*
1620 * Flags on T2 FINDFIRST and FINDNEXT
1621 */
1622#define CIFS_SEARCH_CLOSE_ALWAYS  0x0001
1623#define CIFS_SEARCH_CLOSE_AT_END  0x0002
1624#define CIFS_SEARCH_RETURN_RESUME 0x0004
1625#define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1626#define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1627
1628/*
1629 * Size of the resume key on FINDFIRST and FINDNEXT calls
1630 */
1631#define CIFS_SMB_RESUME_KEY_SIZE 4
1632
1633typedef struct smb_com_transaction2_ffirst_req {
1634	struct smb_hdr hdr;	/* wct = 15 */
1635	__le16 TotalParameterCount;
1636	__le16 TotalDataCount;
1637	__le16 MaxParameterCount;
1638	__le16 MaxDataCount;
1639	__u8 MaxSetupCount;
1640	__u8 Reserved;
1641	__le16 Flags;
1642	__le32 Timeout;
1643	__u16 Reserved2;
1644	__le16 ParameterCount;
1645	__le16 ParameterOffset;
1646	__le16 DataCount;
1647	__le16 DataOffset;
1648	__u8 SetupCount;	/* one */
1649	__u8 Reserved3;
1650	__le16 SubCommand;	/* TRANS2_FIND_FIRST */
1651	__le16 ByteCount;
1652	__u8 Pad;
1653	__le16 SearchAttributes;
1654	__le16 SearchCount;
1655	__le16 SearchFlags;
1656	__le16 InformationLevel;
1657	__le32 SearchStorageType;
1658	char FileName[];
1659} __packed TRANSACTION2_FFIRST_REQ;
1660
1661typedef struct smb_com_transaction2_ffirst_rsp {
1662	struct smb_hdr hdr;	/* wct = 10 */
1663	struct trans2_resp t2;
1664	__u16 ByteCount;
1665} __packed TRANSACTION2_FFIRST_RSP;
1666
1667typedef struct smb_com_transaction2_ffirst_rsp_parms {
1668	__u16 SearchHandle;
1669	__le16 SearchCount;
1670	__le16 EndofSearch;
1671	__le16 EAErrorOffset;
1672	__le16 LastNameOffset;
1673} __packed T2_FFIRST_RSP_PARMS;
1674
1675typedef struct smb_com_transaction2_fnext_req {
1676	struct smb_hdr hdr;	/* wct = 15 */
1677	__le16 TotalParameterCount;
1678	__le16 TotalDataCount;
1679	__le16 MaxParameterCount;
1680	__le16 MaxDataCount;
1681	__u8 MaxSetupCount;
1682	__u8 Reserved;
1683	__le16 Flags;
1684	__le32 Timeout;
1685	__u16 Reserved2;
1686	__le16 ParameterCount;
1687	__le16 ParameterOffset;
1688	__le16 DataCount;
1689	__le16 DataOffset;
1690	__u8 SetupCount;	/* one */
1691	__u8 Reserved3;
1692	__le16 SubCommand;	/* TRANS2_FIND_NEXT */
1693	__le16 ByteCount;
1694	__u8 Pad;
1695	__u16 SearchHandle;
1696	__le16 SearchCount;
1697	__le16 InformationLevel;
1698	__u32 ResumeKey;
1699	__le16 SearchFlags;
1700	char ResumeFileName[];
1701} __packed TRANSACTION2_FNEXT_REQ;
1702
1703typedef struct smb_com_transaction2_fnext_rsp {
1704	struct smb_hdr hdr;	/* wct = 10 */
1705	struct trans2_resp t2;
1706	__u16 ByteCount;
1707} __packed TRANSACTION2_FNEXT_RSP;
1708
1709typedef struct smb_com_transaction2_fnext_rsp_parms {
1710	__le16 SearchCount;
1711	__le16 EndofSearch;
1712	__le16 EAErrorOffset;
1713	__le16 LastNameOffset;
1714} __packed T2_FNEXT_RSP_PARMS;
1715
1716/* QFSInfo Levels */
1717#define SMB_INFO_ALLOCATION         1
1718#define SMB_INFO_VOLUME             2
1719#define SMB_QUERY_FS_VOLUME_INFO    0x102
1720#define SMB_QUERY_FS_SIZE_INFO      0x103
1721#define SMB_QUERY_FS_DEVICE_INFO    0x104
1722#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1723#define SMB_QUERY_CIFS_UNIX_INFO    0x200
1724#define SMB_QUERY_POSIX_FS_INFO     0x201
1725#define SMB_QUERY_POSIX_WHO_AM_I    0x202
1726#define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
1727#define SMB_QUERY_FS_PROXY          0x204 /* WAFS enabled. Returns structure
1728					    FILE_SYSTEM__UNIX_INFO to tell
1729					    whether new NTIOCTL available
1730					    (0xACE) for WAN friendly SMB
1731					    operations to be carried */
1732#define SMB_QUERY_LABEL_INFO        0x3ea
1733#define SMB_QUERY_FS_QUOTA_INFO     0x3ee
1734#define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1735#define SMB_QUERY_OBJECTID_INFO     0x3f0
1736
1737typedef struct smb_com_transaction2_qfsi_req {
1738	struct smb_hdr hdr;	/* wct = 14+ */
1739	__le16 TotalParameterCount;
1740	__le16 TotalDataCount;
1741	__le16 MaxParameterCount;
1742	__le16 MaxDataCount;
1743	__u8 MaxSetupCount;
1744	__u8 Reserved;
1745	__le16 Flags;
1746	__le32 Timeout;
1747	__u16 Reserved2;
1748	__le16 ParameterCount;
1749	__le16 ParameterOffset;
1750	__le16 DataCount;
1751	__le16 DataOffset;
1752	__u8 SetupCount;
1753	__u8 Reserved3;
1754	__le16 SubCommand;	/* one setup word */
1755	__le16 ByteCount;
1756	__u8 Pad;
1757	__le16 InformationLevel;
1758} __packed TRANSACTION2_QFSI_REQ;
1759
1760typedef struct smb_com_transaction_qfsi_rsp {
1761	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
1762	struct trans2_resp t2;
1763	__u16 ByteCount;
1764	__u8 Pad;	/* may be three bytes? *//* followed by data area */
1765} __packed TRANSACTION2_QFSI_RSP;
1766
1767typedef struct whoami_rsp_data { /* Query level 0x202 */
1768	__u32 flags; /* 0 = Authenticated user 1 = GUEST */
1769	__u32 mask; /* which flags bits server understands ie 0x0001 */
1770	__u64 unix_user_id;
1771	__u64 unix_user_gid;
1772	__u32 number_of_supplementary_gids; /* may be zero */
1773	__u32 number_of_sids; /* may be zero */
1774	__u32 length_of_sid_array; /* in bytes - may be zero */
1775	__u32 pad; /* reserved - MBZ */
1776	/* __u64 gid_array[0]; */  /* may be empty */
1777	/* __u8 * psid_list */  /* may be empty */
1778} __packed WHOAMI_RSP_DATA;
1779
1780/* SETFSInfo Levels */
1781#define SMB_SET_CIFS_UNIX_INFO    0x200
1782/* level 0x203 is defined above in list of QFS info levels */
1783/* #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203 */
1784
1785/* Level 0x200 request structure follows */
1786typedef struct smb_com_transaction2_setfsi_req {
1787	struct smb_hdr hdr;	/* wct = 15 */
1788	__le16 TotalParameterCount;
1789	__le16 TotalDataCount;
1790	__le16 MaxParameterCount;
1791	__le16 MaxDataCount;
1792	__u8 MaxSetupCount;
1793	__u8 Reserved;
1794	__le16 Flags;
1795	__le32 Timeout;
1796	__u16 Reserved2;
1797	__le16 ParameterCount;	/* 4 */
1798	__le16 ParameterOffset;
1799	__le16 DataCount;	/* 12 */
1800	__le16 DataOffset;
1801	__u8 SetupCount;	/* one */
1802	__u8 Reserved3;
1803	__le16 SubCommand;	/* TRANS2_SET_FS_INFORMATION */
1804	__le16 ByteCount;
1805	__u8 Pad;
1806	__u16 FileNum;		/* Parameters start. */
1807	__le16 InformationLevel;/* Parameters end. */
1808	__le16 ClientUnixMajor; /* Data start. */
1809	__le16 ClientUnixMinor;
1810	__le64 ClientUnixCap;   /* Data end */
1811} __packed TRANSACTION2_SETFSI_REQ;
1812
1813/* level 0x203 request structure follows */
1814typedef struct smb_com_transaction2_setfs_enc_req {
1815	struct smb_hdr hdr;	/* wct = 15 */
1816	__le16 TotalParameterCount;
1817	__le16 TotalDataCount;
1818	__le16 MaxParameterCount;
1819	__le16 MaxDataCount;
1820	__u8 MaxSetupCount;
1821	__u8 Reserved;
1822	__le16 Flags;
1823	__le32 Timeout;
1824	__u16 Reserved2;
1825	__le16 ParameterCount;	/* 4 */
1826	__le16 ParameterOffset;
1827	__le16 DataCount;	/* 12 */
1828	__le16 DataOffset;
1829	__u8 SetupCount;	/* one */
1830	__u8 Reserved3;
1831	__le16 SubCommand;	/* TRANS2_SET_FS_INFORMATION */
1832	__le16 ByteCount;
1833	__u8 Pad;
1834	__u16  Reserved4;	/* Parameters start. */
1835	__le16 InformationLevel;/* Parameters end. */
1836	/* NTLMSSP Blob, Data start. */
1837} __packed TRANSACTION2_SETFSI_ENC_REQ;
1838
1839/* response for setfsinfo levels 0x200 and 0x203 */
1840typedef struct smb_com_transaction2_setfsi_rsp {
1841	struct smb_hdr hdr;	/* wct = 10 */
1842	struct trans2_resp t2;
1843	__u16 ByteCount;
1844} __packed TRANSACTION2_SETFSI_RSP;
1845
1846typedef struct smb_com_transaction2_get_dfs_refer_req {
1847	struct smb_hdr hdr;	/* wct = 15 */
1848	__le16 TotalParameterCount;
1849	__le16 TotalDataCount;
1850	__le16 MaxParameterCount;
1851	__le16 MaxDataCount;
1852	__u8 MaxSetupCount;
1853	__u8 Reserved;
1854	__le16 Flags;
1855	__le32 Timeout;
1856	__u16 Reserved2;
1857	__le16 ParameterCount;
1858	__le16 ParameterOffset;
1859	__le16 DataCount;
1860	__le16 DataOffset;
1861	__u8 SetupCount;
1862	__u8 Reserved3;
1863	__le16 SubCommand;	/* one setup word */
1864	__le16 ByteCount;
1865	__u8 Pad[3];		/* Win2K has sent 0x0F01 (max response length
1866				   perhaps?) followed by one byte pad - doesn't
1867				   seem to matter though */
1868	__le16 MaxReferralLevel;
1869	char RequestFileName[];
1870} __packed TRANSACTION2_GET_DFS_REFER_REQ;
1871
1872#define DFS_VERSION cpu_to_le16(0x0003)
1873
1874/* DFS server target type */
1875#define DFS_TYPE_LINK 0x0000  /* also for sysvol targets */
1876#define DFS_TYPE_ROOT 0x0001
1877
1878/* Referral Entry Flags */
1879#define DFS_NAME_LIST_REF 0x0200 /* set for domain or DC referral responses */
1880#define DFS_TARGET_SET_BOUNDARY 0x0400 /* only valid with version 4 dfs req */
1881
1882typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */
1883	__le16 VersionNumber;  /* must be 3 or 4 */
1884	__le16 Size;
1885	__le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */
1886	__le16 ReferralEntryFlags;
1887	__le32 TimeToLive;
1888	__le16 DfsPathOffset;
1889	__le16 DfsAlternatePathOffset;
1890	__le16 NetworkAddressOffset; /* offset of the link target */
1891	__u8   ServiceSiteGuid[16];  /* MBZ, ignored */
1892} __packed REFERRAL3;
1893
1894struct get_dfs_referral_rsp {
1895	__le16 PathConsumed;
1896	__le16 NumberOfReferrals;
1897	__le32 DFSFlags;
1898	REFERRAL3 referrals[];	/* array of level 3 dfs_referral structures */
1899	/* followed by the strings pointed to by the referral structures */
1900} __packed;
1901
1902typedef struct smb_com_transaction_get_dfs_refer_rsp {
1903	struct smb_hdr hdr;	/* wct = 10 */
1904	struct trans2_resp t2;
1905	__u16 ByteCount;
1906	__u8 Pad;
1907	struct get_dfs_referral_rsp dfs_data;
1908} __packed TRANSACTION2_GET_DFS_REFER_RSP;
1909
1910/* DFS Flags */
1911#define DFSREF_REFERRAL_SERVER  0x00000001 /* all targets are DFS roots */
1912#define DFSREF_STORAGE_SERVER   0x00000002 /* no further ref requests needed */
1913#define DFSREF_TARGET_FAILBACK  0x00000004 /* only for DFS referral version 4 */
1914
1915/*
1916 ************************************************************************
1917 * All structs for everything above the SMB PDUs themselves
1918 * (such as the T2 level specific data) go here
1919 ************************************************************************
1920 */
1921
1922/*
1923 * Information on a server
1924 */
1925
1926struct serverInfo {
1927	char name[16];
1928	unsigned char versionMajor;
1929	unsigned char versionMinor;
1930	unsigned long type;
1931	unsigned int commentOffset;
1932} __packed;
1933
1934/*
1935 * The following structure is the format of the data returned on a NetShareEnum
1936 * with level "90" (x5A)
1937 */
1938
1939struct shareInfo {
1940	char shareName[13];
1941	char pad;
1942	unsigned short type;
1943	unsigned int commentOffset;
1944} __packed;
1945
1946struct aliasInfo {
1947	char aliasName[9];
1948	char pad;
1949	unsigned int commentOffset;
1950	unsigned char type[2];
1951} __packed;
1952
1953struct aliasInfo92 {
1954	int aliasNameOffset;
1955	int serverNameOffset;
1956	int shareNameOffset;
1957} __packed;
1958
1959typedef struct {
1960	__le32 fsid;
1961	__le32 SectorsPerAllocationUnit;
1962	__le32 TotalAllocationUnits;
1963	__le32 FreeAllocationUnits;
1964	__le16  BytesPerSector;
1965} __packed FILE_SYSTEM_ALLOC_INFO;
1966
1967typedef struct {
1968	__le16 MajorVersionNumber;
1969	__le16 MinorVersionNumber;
1970	__le64 Capability;
1971} __packed FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/
1972
1973/* Version numbers for CIFS UNIX major and minor. */
1974#define CIFS_UNIX_MAJOR_VERSION 1
1975#define CIFS_UNIX_MINOR_VERSION 0
1976
1977/* Linux/Unix extensions capability flags */
1978#define CIFS_UNIX_FCNTL_CAP             0x00000001 /* support for fcntl locks */
1979#define CIFS_UNIX_POSIX_ACL_CAP         0x00000002 /* support getfacl/setfacl */
1980#define CIFS_UNIX_XATTR_CAP             0x00000004 /* support new namespace   */
1981#define CIFS_UNIX_EXTATTR_CAP           0x00000008 /* support chattr/chflag   */
1982#define CIFS_UNIX_POSIX_PATHNAMES_CAP   0x00000010 /* Allow POSIX path chars  */
1983#define CIFS_UNIX_POSIX_PATH_OPS_CAP    0x00000020 /* Allow new POSIX path based
1984						      calls including posix open
1985						      and posix unlink */
1986#define CIFS_UNIX_LARGE_READ_CAP        0x00000040 /* support reads >128K (up to 0xFFFF00 */
1987#define CIFS_UNIX_LARGE_WRITE_CAP       0x00000080
1988#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
1989#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP  0x00000200 /* must do  */
1990#define CIFS_UNIX_PROXY_CAP             0x00000400 /* Proxy cap: 0xACE ioctl and QFS PROXY call */
1991#ifdef CONFIG_CIFS_POSIX
1992/* presumably don't need the 0x20 POSIX_PATH_OPS_CAP since we never send
1993   LockingX instead of posix locking call on unix sess (and we do not expect
1994   LockingX to use different (ie Windows) semantics than posix locking on
1995   the same session (if WINE needs to do this later, we can add this cap
1996   back in later */
1997/* #define CIFS_UNIX_CAP_MASK              0x000000fb */
1998#define CIFS_UNIX_CAP_MASK              0x000003db
1999#else
2000#define CIFS_UNIX_CAP_MASK              0x00000013
2001#endif /* CONFIG_CIFS_POSIX */
2002
2003
2004#define CIFS_POSIX_EXTENSIONS           0x00000010 /* support for new QFSInfo */
2005
2006/******************************************************************************/
2007/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2008/******************************************************************************/
2009typedef struct { /* data block encoding of response to level 263 QPathInfo */
2010	struct_group_attr(common_attributes, __packed,
2011		__le64 CreationTime;
2012		__le64 LastAccessTime;
2013		__le64 LastWriteTime;
2014		__le64 ChangeTime;
2015		__le32 Attributes;
2016	);
2017	__u32 Pad1;
2018	__le64 AllocationSize;
2019	__le64 EndOfFile;	/* size ie offset to first free byte in file */
2020	__le32 NumberOfLinks;	/* hard links */
2021	__u8 DeletePending;
2022	__u8 Directory;
2023	__u16 Pad2;
2024	__le32 EASize;
2025	__le32 FileNameLength;
2026	union {
2027		char __pad;
2028		DECLARE_FLEX_ARRAY(char, FileName);
2029	};
2030} __packed FILE_ALL_INFO;	/* level 0x107 QPathInfo */
2031
2032typedef struct {
2033	__le64 AllocationSize;
2034	__le64 EndOfFile;	/* size ie offset to first free byte in file */
2035	__le32 NumberOfLinks;	/* hard links */
2036	__u8 DeletePending;
2037	__u8 Directory;
2038	__u16 Pad;
2039} __packed FILE_STANDARD_INFO;	/* level 0x102 QPathInfo */
2040
2041
2042/* defines for enumerating possible values of the Unix type field below */
2043#define UNIX_FILE      0
2044#define UNIX_DIR       1
2045#define UNIX_SYMLINK   2
2046#define UNIX_CHARDEV   3
2047#define UNIX_BLOCKDEV  4
2048#define UNIX_FIFO      5
2049#define UNIX_SOCKET    6
2050typedef struct {
2051	__le64 EndOfFile;
2052	__le64 NumOfBytes;
2053	__le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2054	__le64 LastAccessTime;
2055	__le64 LastModificationTime;
2056	__le64 Uid;
2057	__le64 Gid;
2058	__le32 Type;
2059	__le64 DevMajor;
2060	__le64 DevMinor;
2061	__le64 UniqueId;
2062	__le64 Permissions;
2063	__le64 Nlinks;
2064} __packed FILE_UNIX_BASIC_INFO;	/* level 0x200 QPathInfo */
2065
2066typedef struct {
2067	DECLARE_FLEX_ARRAY(char, LinkDest);
2068} __packed FILE_UNIX_LINK_INFO;	/* level 0x201 QPathInfo */
2069
2070/* The following three structures are needed only for
2071	setting time to NT4 and some older servers via
2072	the primitive DOS time format */
2073typedef struct {
2074	__u16 Day:5;
2075	__u16 Month:4;
2076	__u16 Year:7;
2077} __packed SMB_DATE;
2078
2079typedef struct {
2080	__u16 TwoSeconds:5;
2081	__u16 Minutes:6;
2082	__u16 Hours:5;
2083} __packed SMB_TIME;
2084
2085typedef struct {
2086	__le16 CreationDate; /* SMB Date see above */
2087	__le16 CreationTime; /* SMB Time */
2088	__le16 LastAccessDate;
2089	__le16 LastAccessTime;
2090	__le16 LastWriteDate;
2091	__le16 LastWriteTime;
2092	__le32 DataSize; /* File Size (EOF) */
2093	__le32 AllocationSize;
2094	__le16 Attributes; /* verify not u32 */
2095	__le32 EASize;
2096} __packed FILE_INFO_STANDARD;  /* level 1 SetPath/FileInfo */
2097
2098typedef struct {
2099	__le64 CreationTime;
2100	__le64 LastAccessTime;
2101	__le64 LastWriteTime;
2102	__le64 ChangeTime;
2103	__le32 Attributes;
2104	__u32 Pad;
2105} __packed FILE_BASIC_INFO;	/* size info, level 0x101 */
2106
2107struct file_allocation_info {
2108	__le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
2109} __packed; /* size used on disk, for level 0x103 for set, 0x105 for query */
2110
2111struct file_end_of_file_info {
2112	__le64 FileSize;		/* offset to end of file */
2113} __packed; /* size info, level 0x104 for set, 0x106 for query */
2114
2115struct file_alt_name_info {
2116	DECLARE_FLEX_ARRAY(__u8, alt_name);
2117} __packed;      /* level 0x0108 */
2118
2119struct file_stream_info {
2120	__le32 number_of_streams;  /* BB check sizes and verify location */
2121	/* followed by info on streams themselves
2122		u64 size;
2123		u64 allocation_size
2124		stream info */
2125};      /* level 0x109 */
2126
2127struct file_compression_info {
2128	__le64 compressed_size;
2129	__le16 format;
2130	__u8   unit_shift;
2131	__u8   ch_shift;
2132	__u8   cl_shift;
2133	__u8   pad[3];
2134} __packed;      /* level 0x10b */
2135
2136/* POSIX ACL set/query path info structures */
2137#define CIFS_ACL_VERSION 1
2138struct cifs_posix_ace { /* access control entry (ACE) */
2139	__u8  cifs_e_tag;
2140	__u8  cifs_e_perm;
2141	__le64 cifs_uid; /* or gid */
2142} __packed;
2143
2144struct cifs_posix_acl { /* access control list  (ACL) */
2145	__le16	version;
2146	__le16	access_entry_count;  /* access ACL - count of entries */
2147	__le16	default_entry_count; /* default ACL - count of entries */
2148	struct cifs_posix_ace ace_array[];
2149	/* followed by struct cifs_posix_ace default_ace_array[] */
2150} __packed;  /* level 0x204 */
2151
2152/* types of access control entries already defined in posix_acl.h */
2153/* #define CIFS_POSIX_ACL_USER_OBJ	 0x01
2154#define CIFS_POSIX_ACL_USER      0x02
2155#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2156#define CIFS_POSIX_ACL_GROUP     0x08
2157#define CIFS_POSIX_ACL_MASK      0x10
2158#define CIFS_POSIX_ACL_OTHER     0x20 */
2159
2160/* types of perms */
2161/* #define CIFS_POSIX_ACL_EXECUTE   0x01
2162#define CIFS_POSIX_ACL_WRITE     0x02
2163#define CIFS_POSIX_ACL_READ	     0x04 */
2164
2165/* end of POSIX ACL definitions */
2166
2167/* POSIX Open Flags */
2168#define SMB_O_RDONLY	0x1
2169#define SMB_O_WRONLY	0x2
2170#define SMB_O_RDWR	0x4
2171#define SMB_O_CREAT	0x10
2172#define SMB_O_EXCL	0x20
2173#define SMB_O_TRUNC	0x40
2174#define SMB_O_APPEND	0x80
2175#define SMB_O_SYNC	0x100
2176#define SMB_O_DIRECTORY	0x200
2177#define SMB_O_NOFOLLOW	0x400
2178#define SMB_O_DIRECT	0x800
2179
2180typedef struct {
2181	__le32 OpenFlags; /* same as NT CreateX */
2182	__le32 PosixOpenFlags;
2183	__le64 Permissions;
2184	__le16 Level; /* reply level requested (see QPathInfo levels) */
2185} __packed OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
2186
2187typedef struct {
2188	__le16 OplockFlags;
2189	__u16 Fid;
2190	__le32 CreateAction;
2191	__le16 ReturnedLevel;
2192	__le16 Pad;
2193	/* struct following varies based on requested level */
2194} __packed OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
2195
2196#define SMB_POSIX_UNLINK_FILE_TARGET		0
2197#define SMB_POSIX_UNLINK_DIRECTORY_TARGET	1
2198
2199struct unlink_psx_rq { /* level 0x20a SetPathInfo */
2200	__le16 type;
2201} __packed;
2202
2203struct file_internal_info {
2204	__le64  UniqueId; /* inode number */
2205} __packed;      /* level 0x3ee */
2206
2207struct file_mode_info {
2208	__le32	Mode;
2209} __packed;      /* level 0x3f8 */
2210
2211struct file_attrib_tag {
2212	__le32 Attribute;
2213	__le32 ReparseTag;
2214} __packed;      /* level 0x40b */
2215
2216
2217/********************************************************/
2218/*  FindFirst/FindNext transact2 data buffer formats    */
2219/********************************************************/
2220
2221typedef struct {
2222	__le32 NextEntryOffset;
2223	__u32 ResumeKey; /* as with FileIndex - no need to convert */
2224	FILE_UNIX_BASIC_INFO basic;
2225	union {
2226		char __pad;
2227		DECLARE_FLEX_ARRAY(char, FileName);
2228	};
2229} __packed FILE_UNIX_INFO; /* level 0x202 */
2230
2231typedef struct {
2232	__u32  ResumeKey;
2233	__le16 CreationDate; /* SMB Date */
2234	__le16 CreationTime; /* SMB Time */
2235	__le16 LastAccessDate;
2236	__le16 LastAccessTime;
2237	__le16 LastWriteDate;
2238	__le16 LastWriteTime;
2239	__le32 DataSize; /* File Size (EOF) */
2240	__le32 AllocationSize;
2241	__le16 Attributes; /* verify not u32 */
2242	__u8   FileNameLength;
2243	char FileName[];
2244} __packed FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
2245
2246
2247struct fea {
2248	unsigned char EA_flags;
2249	__u8 name_len;
2250	__le16 value_len;
2251	char name[];
2252	/* optionally followed by value */
2253} __packed;
2254/* flags for _FEA.fEA */
2255#define FEA_NEEDEA         0x80	/* need EA bit */
2256
2257struct fealist {
2258	__le32 list_len;
2259	struct fea list;
2260} __packed;
2261
2262/* used to hold an arbitrary blob of data */
2263struct data_blob {
2264	__u8 *data;
2265	size_t length;
2266	void (*free) (struct data_blob *data_blob);
2267} __packed;
2268
2269
2270#ifdef CONFIG_CIFS_POSIX
2271/*
2272	For better POSIX semantics from Linux client, (even better
2273	than the existing CIFS Unix Extensions) we need updated PDUs for:
2274
2275	1) PosixCreateX - to set and return the mode, inode#, device info and
2276	perhaps add a CreateDevice - to create Pipes and other special .inodes
2277	Also note POSIX open flags
2278	2) Close - to return the last write time to do cache across close
2279		more safely
2280	3) FindFirst return unique inode number - what about resume key, two
2281	forms short (matches readdir) and full (enough info to cache inodes)
2282	4) Mkdir - set mode
2283
2284	And under consideration:
2285	5) FindClose2 (return nanosecond timestamp ??)
2286	6) Use nanosecond timestamps throughout all time fields if
2287	   corresponding attribute flag is set
2288	7) sendfile - handle based copy
2289
2290	what about fixing 64 bit alignment
2291
2292	There are also various legacy SMB/CIFS requests used as is
2293
2294	From existing Lanman and NTLM dialects:
2295	--------------------------------------
2296	NEGOTIATE
2297	SESSION_SETUP_ANDX (BB which?)
2298	TREE_CONNECT_ANDX (BB which wct?)
2299	TREE_DISCONNECT (BB add volume timestamp on response)
2300	LOGOFF_ANDX
2301	DELETE (note delete open file behavior)
2302	DELETE_DIRECTORY
2303	READ_AND_X
2304	WRITE_AND_X
2305	LOCKING_AND_X (note posix lock semantics)
2306	RENAME (note rename across dirs and open file rename posix behaviors)
2307	NT_RENAME (for hardlinks) Is this good enough for all features?
2308	FIND_CLOSE2
2309	TRANSACTION2 (18 cases)
2310		SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2311		(BB verify that never need to set allocation size)
2312		SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2313			 Unix ext?)
2314
2315	COPY (note support for copy across directories) - FUTURE, OPTIONAL
2316	setting/getting OS/2 EAs - FUTURE (BB can this handle
2317	setting Linux xattrs perfectly)         - OPTIONAL
2318	dnotify                                 - FUTURE, OPTIONAL
2319	quota                                   - FUTURE, OPTIONAL
2320
2321	Note that various requests implemented for NT interop such as
2322		NT_TRANSACT (IOCTL) QueryReparseInfo
2323	are unneeded to servers compliant with the CIFS POSIX extensions
2324
2325	From CIFS Unix Extensions:
2326	-------------------------
2327	T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2328	T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2329	T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
2330	T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC)	BB check for missing
2331							inode fields
2332				Actually a need QUERY_FILE_UNIX_INFO
2333				since has inode num
2334				BB what about a) blksize/blkbits/blocks
2335							  b) i_version
2336							  c) i_rdev
2337							  d) notify mask?
2338							  e) generation
2339							  f) size_seqcount
2340	T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
2341	TRANS2_GET_DFS_REFERRAL		      - OPTIONAL but recommended
2342	T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
2343 */
2344
2345/* xsymlink is a symlink format (used by MacOS) that can be used
2346   to save symlink info in a regular file when
2347   mounted to operating systems that do not
2348   support the cifs Unix extensions or EAs (for xattr
2349   based symlinks).  For such a file to be recognized
2350   as containing symlink data:
2351
2352   1) file size must be 1067,
2353   2) signature must begin file data,
2354   3) length field must be set to ASCII representation
2355	of a number which is less than or equal to 1024,
2356   4) md5 must match that of the path data */
2357
2358struct xsymlink {
2359	/* 1067 bytes */
2360	char signature[4]; /* XSym */ /* not null terminated */
2361	char cr0;         /* \n */
2362/* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2363	char length[4];
2364	char cr1;         /* \n */
2365/* md5 of valid subset of path ie path[0] through path[length-1] */
2366	__u8 md5[32];
2367	char cr2;        /* \n */
2368/* if room left, then end with \n then 0x20s by convention but not required */
2369	char path[1024];
2370} __packed;
2371
2372typedef struct file_xattr_info {
2373	/* BB do we need another field for flags? BB */
2374	__u32 xattr_name_len;
2375	__u32 xattr_value_len;
2376	char  xattr_name[];
2377	/* followed by xattr_value[xattr_value_len], no pad */
2378} __packed FILE_XATTR_INFO; /* extended attribute info level 0x205 */
2379
2380/* flags for lsattr and chflags commands removed arein uapi/linux/fs.h */
2381
2382typedef struct file_chattr_info {
2383	__le64	mask; /* list of all possible attribute bits */
2384	__le64	mode; /* list of actual attribute bits on this inode */
2385} __packed FILE_CHATTR_INFO;  /* ext attributes (chattr, chflags) level 0x206 */
2386#endif				/* POSIX */
2387#endif				/* _CIFSPDU_H */
~/ Read-only file preview.