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