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