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