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