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