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