Debian Codegraph @

fs/smb/client/smb1pdu.h

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