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