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