blob: 47f79504f57b35524b5e9a6629e75264a2047184 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/cifs/cifspdu.h
3 *
Steve French87f440e2007-02-07 00:29:46 +00004 * Copyright (c) International Business Machines Corp., 2002,2007
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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
Steve French39798772006-05-31 22:40:51 +000019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 */
21
22#ifndef _CIFSPDU_H
23#define _CIFSPDU_H
24
25#include <net/sock.h>
26
Steve French39798772006-05-31 22:40:51 +000027#ifdef CONFIG_CIFS_WEAK_PW_HASH
28#define LANMAN_PROT 0
Steve French9ac00b72006-09-30 04:13:17 +000029#define LANMAN2_PROT 1
30#define CIFS_PROT 2
Steve French39798772006-05-31 22:40:51 +000031#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#define CIFS_PROT 0
Steve French39798772006-05-31 22:40:51 +000033#endif
34#define POSIX_PROT CIFS_PROT+1
35#define BAD_PROT 0xFFFF
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
37/* SMB command codes */
Steve Frenchc14e8942007-02-15 01:33:18 +000038/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#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 */
Steve French6b8edfe2005-08-23 20:26:03 -070048#define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#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*/
Steve Frencha9d02ad2005-08-24 23:06:05 -070052#define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#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
Steve Frenchff5dbd92005-08-24 17:10:36 -070066#define SMB_COM_NT_CANCEL 0xA4 /* no response */
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#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
Jeremy Allisonac670552005-06-22 17:26:35 -070074#define TRANS2_SET_FS_INFORMATION 0x04
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#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
Steve Frenchec637e32005-12-12 20:53:18 -080092#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
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 */
Steve French7c7b25b2006-06-01 19:20:10 +0000122#define CIFS_SESS_KEY_SIZE (24)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
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/*
Steve French50c2f752007-07-13 00:33:32 +0000147 * SMB flag definitions
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 */
Steve French0753ca72005-10-27 13:55:12 -0700149#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#define SMBFLG_RCV_POSTED 0x02 /* obsolete */
151#define SMBFLG_RSVD 0x04
Steve French0753ca72005-10-27 13:55:12 -0700152#define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
153 implies case sensitive file handling request) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#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/*
Steve French50c2f752007-07-13 00:33:32 +0000160 * SMB flag2 definitions
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 */
Steve French50c2f752007-07-13 00:33:32 +0000162#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
Steve French0753ca72005-10-27 13:55:12 -0700163 path names in response */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164#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
Steve French0753ca72005-10-27 13:55:12 -0700182#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191#define FILE_DELETE_CHILD 0x00000040
Steve French0753ca72005-10-27 13:55:12 -0700192#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#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 */
Steve French0753ca72005-10-27 13:55:12 -0700215 /* file_execute, file_read_attributes*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 /* write_dac, and delete. */
217
Steve Frencha750e772007-10-17 22:50:39 +0000218#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
Steve French953f8682007-10-31 04:54:42 +0000223#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
Steve French97837582007-12-31 07:47:21 +0000240#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
241 | READ_CONTROL | SYNCHRONIZE)
242
Steve Frencha750e772007-10-17 22:50:39 +0000243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244/*
245 * Invalid readdir handle
246 */
247#define CIFS_NO_HANDLE 0xFFFF
248
Al Viro82c05a12007-03-14 09:19:40 +0000249#define NO_CHANGE_64 cpu_to_le64(0xFFFFFFFFFFFFFFFFULL)
Steve Frenchc7af1852007-03-01 04:11:22 +0000250#define NO_CHANGE_32 0xFFFFFFFFUL
251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252/* IPC$ in ASCII */
253#define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
254
255/* IPC$ in Unicode */
256#define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
257
258/* Unicode Null terminate 2 bytes of 0 */
259#define UNICODE_NULL "\x00\x00"
260#define ASCII_NULL 0x00
261
262/*
263 * Server type values (returned on EnumServer API
264 */
265#define CIFS_SV_TYPE_DC 0x00000008
266#define CIFS_SV_TYPE_BACKDC 0x00000010
267
268/*
269 * Alias type flags (From EnumAlias API call
270 */
271#define CIFS_ALIAS_TYPE_FILE 0x0001
272#define CIFS_SHARE_TYPE_FILE 0x0000
273
274/*
275 * File Attribute flags
276 */
277#define ATTR_READONLY 0x0001
278#define ATTR_HIDDEN 0x0002
279#define ATTR_SYSTEM 0x0004
280#define ATTR_VOLUME 0x0008
281#define ATTR_DIRECTORY 0x0010
282#define ATTR_ARCHIVE 0x0020
283#define ATTR_DEVICE 0x0040
284#define ATTR_NORMAL 0x0080
285#define ATTR_TEMPORARY 0x0100
286#define ATTR_SPARSE 0x0200
287#define ATTR_REPARSE 0x0400
288#define ATTR_COMPRESSED 0x0800
Steve French50c2f752007-07-13 00:33:32 +0000289#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
Steve French0753ca72005-10-27 13:55:12 -0700290 on offline storage */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291#define ATTR_NOT_CONTENT_INDEXED 0x2000
292#define ATTR_ENCRYPTED 0x4000
293#define ATTR_POSIX_SEMANTICS 0x01000000
294#define ATTR_BACKUP_SEMANTICS 0x02000000
295#define ATTR_DELETE_ON_CLOSE 0x04000000
296#define ATTR_SEQUENTIAL_SCAN 0x08000000
297#define ATTR_RANDOM_ACCESS 0x10000000
298#define ATTR_NO_BUFFERING 0x20000000
299#define ATTR_WRITE_THROUGH 0x80000000
300
301/* ShareAccess flags */
302#define FILE_NO_SHARE 0x00000000
303#define FILE_SHARE_READ 0x00000001
304#define FILE_SHARE_WRITE 0x00000002
305#define FILE_SHARE_DELETE 0x00000004
306#define FILE_SHARE_ALL 0x00000007
307
308/* CreateDisposition flags */
309#define FILE_SUPERSEDE 0x00000000
310#define FILE_OPEN 0x00000001
311#define FILE_CREATE 0x00000002
312#define FILE_OPEN_IF 0x00000003
313#define FILE_OVERWRITE 0x00000004
314#define FILE_OVERWRITE_IF 0x00000005
315
316/* CreateOptions */
317#define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
318#define CREATE_WRITE_THROUGH 0x00000002
Steve Frencheda3c0292005-07-21 15:20:28 -0700319#define CREATE_SEQUENTIAL 0x00000004
320#define CREATE_SYNC_ALERT 0x00000010
321#define CREATE_ASYNC_ALERT 0x00000020
322#define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
323#define CREATE_NO_EA_KNOWLEDGE 0x00000200
324#define CREATE_EIGHT_DOT_THREE 0x00000400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325#define CREATE_RANDOM_ACCESS 0x00000800
326#define CREATE_DELETE_ON_CLOSE 0x00001000
Steve Frencheda3c0292005-07-21 15:20:28 -0700327#define CREATE_OPEN_BY_ID 0x00002000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328#define OPEN_REPARSE_POINT 0x00200000
Steve French50c2f752007-07-13 00:33:32 +0000329#define CREATE_OPTIONS_MASK 0x007FFFFF
Steve Frencheda3c0292005-07-21 15:20:28 -0700330#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
332/* ImpersonationLevel flags */
333#define SECURITY_ANONYMOUS 0
334#define SECURITY_IDENTIFICATION 1
335#define SECURITY_IMPERSONATION 2
336#define SECURITY_DELEGATION 3
337
338/* SecurityFlags */
339#define SECURITY_CONTEXT_TRACKING 0x01
340#define SECURITY_EFFECTIVE_ONLY 0x02
341
342/*
343 * Default PID value, used in all SMBs where the PID is not important
344 */
345#define CIFS_DFT_PID 0x1234
346
347/*
348 * We use the same routine for Copy and Move SMBs. This flag is used to
349 * distinguish
350 */
351#define CIFS_COPY_OP 1
352#define CIFS_RENAME_OP 2
353
354#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
355#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357struct smb_hdr {
Steve French0753ca72005-10-27 13:55:12 -0700358 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two
359 or three bytes - with one or two byte type preceding it that are
360 zero - we could mask the type byte off just in case BB */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 __u8 Protocol[4];
362 __u8 Command;
363 union {
364 struct {
365 __u8 ErrorClass;
366 __u8 Reserved;
367 __le16 Error;
Steve French0753ca72005-10-27 13:55:12 -0700368 } __attribute__((packed)) DosError;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 __le32 CifsError;
Steve French0753ca72005-10-27 13:55:12 -0700370 } __attribute__((packed)) Status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 __u8 Flags;
372 __le16 Flags2; /* note: le */
373 __le16 PidHigh;
374 union {
375 struct {
376 __le32 SequenceNumber; /* le */
377 __u32 Reserved; /* zero */
Steve French0753ca72005-10-27 13:55:12 -0700378 } __attribute__((packed)) Sequence;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 __u8 SecuritySignature[8]; /* le */
Steve French0753ca72005-10-27 13:55:12 -0700380 } __attribute__((packed)) Signature;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 __u8 pad[2];
382 __u16 Tid;
383 __le16 Pid;
384 __u16 Uid;
385 __u16 Mid;
386 __u8 WordCount;
Steve French0753ca72005-10-27 13:55:12 -0700387} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388/* given a pointer to an smb_hdr retrieve the value of byte count */
Steve French26f57362007-08-30 22:09:15 +0000389#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
390#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
Steve French26f57362007-08-30 22:09:15 +0000392#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393
394/*
Steve French50c2f752007-07-13 00:33:32 +0000395 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
396 * No longer as important, now that TCP names are more commonly used to
397 * resolve hosts.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 */
399#define CNLEN 15
400
401/*
Steve French50c2f752007-07-13 00:33:32 +0000402 * Share Name Length (SNLEN)
403 * Note: This length was limited by the SMB used to get
404 * the Share info. NetShareEnum only returned 13
405 * chars, including the null termination.
406 * This was removed because it no longer is limiting.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408
409/*
410 * Comment Length
411 */
412#define MAXCOMMENTLEN 40
413
414/*
415 * The OS/2 maximum path name
416 */
417#define MAX_PATHCONF 256
418
419/*
420 * SMB frame definitions (following must be packed structs)
421 * See the SNIA CIFS Specification for details.
422 *
423 * The Naming convention is the lower case version of the
424 * smb command code name for the struct and this is typedef to the
Steve French50c2f752007-07-13 00:33:32 +0000425 * uppercase version of the same name with the prefix SMB_ removed
426 * for brevity. Although typedefs are not commonly used for
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 * structure definitions in the Linux kernel, their use in the
428 * CIFS standards document, which this code is based on, may
429 * make this one of the cases where typedefs for structures make
430 * sense to improve readability for readers of the standards doc.
431 * Typedefs can always be removed later if they are too distracting
432 * and they are only used for the CIFSs PDUs themselves, not
433 * internal cifs vfs structures
Steve French50c2f752007-07-13 00:33:32 +0000434 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 */
436
437typedef struct negotiate_req {
438 struct smb_hdr hdr; /* wct = 0 */
439 __le16 ByteCount;
440 unsigned char DialectsArray[1];
Steve French0753ca72005-10-27 13:55:12 -0700441} __attribute__((packed)) NEGOTIATE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442
Steve French39798772006-05-31 22:40:51 +0000443/* Dialect index is 13 for LANMAN */
444
Steve Frenchb815f1e52006-10-02 05:53:29 +0000445#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
446
Steve French39798772006-05-31 22:40:51 +0000447typedef struct lanman_neg_rsp {
448 struct smb_hdr hdr; /* wct = 13 */
449 __le16 DialectIndex;
450 __le16 SecurityMode;
451 __le16 MaxBufSize;
452 __le16 MaxMpxCount;
453 __le16 MaxNumberVcs;
454 __le16 RawMode;
455 __le32 SessionKey;
Steve French175ec9e2006-09-30 01:07:38 +0000456 struct {
457 __le16 Time;
458 __le16 Date;
459 } __attribute__((packed)) SrvTime;
Steve French39798772006-05-31 22:40:51 +0000460 __le16 ServerTimeZone;
461 __le16 EncryptionKeyLength;
462 __le16 Reserved;
463 __u16 ByteCount;
464 unsigned char EncryptionKey[1];
465} __attribute__((packed)) LANMAN_NEG_RSP;
466
Steve French254e55e2006-06-04 05:53:15 +0000467#define READ_RAW_ENABLE 1
468#define WRITE_RAW_ENABLE 2
469#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
470
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471typedef struct negotiate_rsp {
472 struct smb_hdr hdr; /* wct = 17 */
473 __le16 DialectIndex;
474 __u8 SecurityMode;
475 __le16 MaxMpxCount;
476 __le16 MaxNumberVcs;
477 __le32 MaxBufferSize;
478 __le32 MaxRawSize;
479 __le32 SessionKey;
480 __le32 Capabilities; /* see below */
481 __le32 SystemTimeLow;
482 __le32 SystemTimeHigh;
483 __le16 ServerTimeZone;
484 __u8 EncryptionKeyLength;
485 __u16 ByteCount;
486 union {
Steve French0753ca72005-10-27 13:55:12 -0700487 unsigned char EncryptionKey[1]; /* cap extended security off */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 /* followed by Domain name - if extended security is off */
489 /* followed by 16 bytes of server GUID */
Steve French0753ca72005-10-27 13:55:12 -0700490 /* then security blob if cap_extended_security negotiated */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 struct {
492 unsigned char GUID[16];
493 unsigned char SecurityBlob[1];
Steve French0753ca72005-10-27 13:55:12 -0700494 } __attribute__((packed)) extended_response;
495 } __attribute__((packed)) u;
496} __attribute__((packed)) NEGOTIATE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497
498/* SecurityMode bits */
499#define SECMODE_USER 0x01 /* off indicates share level security */
500#define SECMODE_PW_ENCRYPT 0x02
501#define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
502#define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
503
504/* Negotiate response Capabilities */
505#define CAP_RAW_MODE 0x00000001
506#define CAP_MPX_MODE 0x00000002
507#define CAP_UNICODE 0x00000004
508#define CAP_LARGE_FILES 0x00000008
509#define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
510#define CAP_RPC_REMOTE_APIS 0x00000020
511#define CAP_STATUS32 0x00000040
512#define CAP_LEVEL_II_OPLOCKS 0x00000080
513#define CAP_LOCK_AND_READ 0x00000100
514#define CAP_NT_FIND 0x00000200
515#define CAP_DFS 0x00001000
516#define CAP_INFOLEVEL_PASSTHRU 0x00002000
517#define CAP_LARGE_READ_X 0x00004000
518#define CAP_LARGE_WRITE_X 0x00008000
519#define CAP_UNIX 0x00800000
520#define CAP_RESERVED 0x02000000
521#define CAP_BULK_TRANSFER 0x20000000
522#define CAP_COMPRESSED_DATA 0x40000000
523#define CAP_EXTENDED_SECURITY 0x80000000
524
525typedef union smb_com_session_setup_andx {
526 struct { /* request format */
527 struct smb_hdr hdr; /* wct = 12 */
528 __u8 AndXCommand;
529 __u8 AndXReserved;
530 __le16 AndXOffset;
531 __le16 MaxBufferSize;
532 __le16 MaxMpxCount;
533 __le16 VcNumber;
534 __u32 SessionKey;
535 __le16 SecurityBlobLength;
536 __u32 Reserved;
537 __le32 Capabilities; /* see below */
538 __le16 ByteCount;
539 unsigned char SecurityBlob[1]; /* followed by */
540 /* STRING NativeOS */
541 /* STRING NativeLanMan */
Steve French50c2f752007-07-13 00:33:32 +0000542 } __attribute__((packed)) req; /* NTLM request format (with
Steve French0753ca72005-10-27 13:55:12 -0700543 extended security */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544
545 struct { /* request format */
546 struct smb_hdr hdr; /* wct = 13 */
547 __u8 AndXCommand;
548 __u8 AndXReserved;
549 __le16 AndXOffset;
550 __le16 MaxBufferSize;
551 __le16 MaxMpxCount;
552 __le16 VcNumber;
553 __u32 SessionKey;
Steve French0753ca72005-10-27 13:55:12 -0700554 __le16 CaseInsensitivePasswordLength; /* ASCII password len */
555 __le16 CaseSensitivePasswordLength; /* Unicode password length*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 __u32 Reserved; /* see below */
557 __le32 Capabilities;
558 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700559 unsigned char CaseInsensitivePassword[1]; /* followed by: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 /* unsigned char * CaseSensitivePassword; */
561 /* STRING AccountName */
562 /* STRING PrimaryDomain */
563 /* STRING NativeOS */
564 /* STRING NativeLanMan */
Steve French0753ca72005-10-27 13:55:12 -0700565 } __attribute__((packed)) req_no_secext; /* NTLM request format (without
566 extended security */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567
568 struct { /* default (NTLM) response format */
569 struct smb_hdr hdr; /* wct = 4 */
570 __u8 AndXCommand;
571 __u8 AndXReserved;
572 __le16 AndXOffset;
573 __le16 Action; /* see below */
574 __le16 SecurityBlobLength;
575 __u16 ByteCount;
576 unsigned char SecurityBlob[1]; /* followed by */
577/* unsigned char * NativeOS; */
578/* unsigned char * NativeLanMan; */
579/* unsigned char * PrimaryDomain; */
Steve French50c2f752007-07-13 00:33:32 +0000580 } __attribute__((packed)) resp; /* NTLM response
Steve French87f440e2007-02-07 00:29:46 +0000581 (with or without extended sec) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582
583 struct { /* request format */
584 struct smb_hdr hdr; /* wct = 10 */
585 __u8 AndXCommand;
586 __u8 AndXReserved;
587 __le16 AndXOffset;
588 __le16 MaxBufferSize;
589 __le16 MaxMpxCount;
590 __le16 VcNumber;
591 __u32 SessionKey;
Steve French39798772006-05-31 22:40:51 +0000592 __le16 PasswordLength;
593 __u32 Reserved; /* encrypt key len and offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 __le16 ByteCount;
595 unsigned char AccountPassword[1]; /* followed by */
596 /* STRING AccountName */
597 /* STRING PrimaryDomain */
598 /* STRING NativeOS */
599 /* STRING NativeLanMan */
Steve French0a4b92c2006-01-12 15:44:21 -0800600 } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601
602 struct { /* default (NTLM) response format */
603 struct smb_hdr hdr; /* wct = 3 */
604 __u8 AndXCommand;
605 __u8 AndXReserved;
606 __le16 AndXOffset;
607 __le16 Action; /* see below */
608 __u16 ByteCount;
609 unsigned char NativeOS[1]; /* followed by */
610/* unsigned char * NativeLanMan; */
611/* unsigned char * PrimaryDomain; */
Steve French0a4b92c2006-01-12 15:44:21 -0800612 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
Steve French0753ca72005-10-27 13:55:12 -0700613} __attribute__((packed)) SESSION_SETUP_ANDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614
Steve Frenchf64b23a2006-06-05 05:27:37 +0000615/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
616
Steve French33ec32f2006-12-08 04:14:28 +0000617#define NTLMSSP_SERVER_TYPE 1
618#define NTLMSSP_DOMAIN_TYPE 2
619#define NTLMSSP_FQ_DOMAIN_TYPE 3
620#define NTLMSSP_DNS_DOMAIN_TYPE 4
621#define NTLMSSP_DNS_PARENT_TYPE 5
622
Steve Frenchf64b23a2006-06-05 05:27:37 +0000623struct ntlmssp2_name {
624 __le16 type;
625 __le16 length;
626/* char name[length]; */
627} __attribute__((packed));
628
629struct ntlmv2_resp {
630 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
Steve French6d027cf2006-06-05 16:26:05 +0000631 __le32 blob_signature;
Steve Frenchf64b23a2006-06-05 05:27:37 +0000632 __u32 reserved;
633 __le64 time;
634 __u64 client_chal; /* random */
635 __u32 reserved2;
Steve French33ec32f2006-12-08 04:14:28 +0000636 struct ntlmssp2_name names[2];
Steve Frenchf64b23a2006-06-05 05:27:37 +0000637 /* array of name entries could follow ending in minimum 4 byte struct */
638} __attribute__((packed));
639
640
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
642
643/* Capabilities bits (for NTLM SessSetup request) */
644#define CAP_UNICODE 0x00000004
645#define CAP_LARGE_FILES 0x00000008
646#define CAP_NT_SMBS 0x00000010
647#define CAP_STATUS32 0x00000040
648#define CAP_LEVEL_II_OPLOCKS 0x00000080
Steve French50c2f752007-07-13 00:33:32 +0000649#define CAP_NT_FIND 0x00000200 /* reserved should be zero
Steve French0753ca72005-10-27 13:55:12 -0700650 (because NT_SMBs implies the same thing?) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651#define CAP_BULK_TRANSFER 0x20000000
652#define CAP_EXTENDED_SECURITY 0x80000000
653
654/* Action bits */
655#define GUEST_LOGIN 1
656
657typedef struct smb_com_tconx_req {
658 struct smb_hdr hdr; /* wct = 4 */
659 __u8 AndXCommand;
660 __u8 AndXReserved;
661 __le16 AndXOffset;
662 __le16 Flags; /* see below */
663 __le16 PasswordLength;
664 __le16 ByteCount;
665 unsigned char Password[1]; /* followed by */
666/* STRING Path *//* \\server\share name */
667 /* STRING Service */
Steve French0753ca72005-10-27 13:55:12 -0700668} __attribute__((packed)) TCONX_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669
670typedef struct smb_com_tconx_rsp {
Steve Frenchf64b23a2006-06-05 05:27:37 +0000671 struct smb_hdr hdr; /* wct = 3 note that Win2000 has sent wct = 7
672 in some cases on responses. Four unspecified
673 words followed OptionalSupport */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 __u8 AndXCommand;
675 __u8 AndXReserved;
676 __le16 AndXOffset;
677 __le16 OptionalSupport; /* see below */
678 __u16 ByteCount;
679 unsigned char Service[1]; /* always ASCII, not Unicode */
680 /* STRING NativeFileSystem */
Steve French0753ca72005-10-27 13:55:12 -0700681} __attribute__((packed)) TCONX_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682
683/* tree connect Flags */
684#define DISCONNECT_TID 0x0001
685#define TCON_EXTENDED_SECINFO 0x0008
686/* OptionalSupport bits */
Steve French0753ca72005-10-27 13:55:12 -0700687#define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
688 (exclusive searches supported) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689#define SMB_SHARE_IS_IN_DFS 0x0002
690
691typedef struct smb_com_logoff_andx_req {
692 struct smb_hdr hdr; /* wct = 2 */
693 __u8 AndXCommand;
694 __u8 AndXReserved;
695 __u16 AndXOffset;
696 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700697} __attribute__((packed)) LOGOFF_ANDX_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698
699typedef struct smb_com_logoff_andx_rsp {
700 struct smb_hdr hdr; /* wct = 2 */
701 __u8 AndXCommand;
702 __u8 AndXReserved;
703 __u16 AndXOffset;
704 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700705} __attribute__((packed)) LOGOFF_ANDX_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706
Steve French50c2f752007-07-13 00:33:32 +0000707typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
Steve French86c96b42005-11-18 20:25:31 -0800708 tree_connect PDU to effect disconnect */
709 /* tdis is probably simplest SMB PDU */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 struct {
711 struct smb_hdr hdr; /* wct = 0 */
712 __u16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700713 } __attribute__((packed)) req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 struct {
715 struct smb_hdr hdr; /* wct = 0 */
716 __u16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700717 } __attribute__((packed)) resp;
718} __attribute__((packed)) TREE_DISCONNECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719
720typedef struct smb_com_close_req {
721 struct smb_hdr hdr; /* wct = 3 */
722 __u16 FileID;
Steve Frenchb815f1e52006-10-02 05:53:29 +0000723 __u32 LastWriteTime; /* should be zero or -1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 __u16 ByteCount; /* 0 */
Steve French0753ca72005-10-27 13:55:12 -0700725} __attribute__((packed)) CLOSE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726
727typedef struct smb_com_close_rsp {
728 struct smb_hdr hdr; /* wct = 0 */
729 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700730} __attribute__((packed)) CLOSE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731
732typedef struct smb_com_findclose_req {
733 struct smb_hdr hdr; /* wct = 1 */
734 __u16 FileID;
735 __u16 ByteCount; /* 0 */
Steve French0753ca72005-10-27 13:55:12 -0700736} __attribute__((packed)) FINDCLOSE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737
738/* OpenFlags */
Steve Frencha9d02ad2005-08-24 23:06:05 -0700739#define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740#define REQ_OPLOCK 0x00000002
741#define REQ_BATCHOPLOCK 0x00000004
742#define REQ_OPENDIRONLY 0x00000008
Steve French75865f8c2007-06-24 18:30:48 +0000743#define REQ_EXTENDED_INFO 0x00000010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744
Steve French92ad9b92007-09-29 05:21:58 +0000745/* File type */
746#define DISK_TYPE 0x0000
747#define BYTE_PIPE_TYPE 0x0001
748#define MESSAGE_PIPE_TYPE 0x0002
749#define PRINTER_TYPE 0x0003
750#define COMM_DEV_TYPE 0x0004
751#define UNKNOWN_TYPE 0xFFFF
752
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753typedef struct smb_com_open_req { /* also handles create */
754 struct smb_hdr hdr; /* wct = 24 */
755 __u8 AndXCommand;
756 __u8 AndXReserved;
757 __le16 AndXOffset;
758 __u8 Reserved; /* Must Be Zero */
759 __le16 NameLength;
760 __le32 OpenFlags;
761 __le32 RootDirectoryFid;
762 __le32 DesiredAccess;
763 __le64 AllocationSize;
764 __le32 FileAttributes;
765 __le32 ShareAccess;
766 __le32 CreateDisposition;
767 __le32 CreateOptions;
768 __le32 ImpersonationLevel;
769 __u8 SecurityFlags;
770 __le16 ByteCount;
771 char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -0700772} __attribute__((packed)) OPEN_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773
774/* open response: oplock levels */
775#define OPLOCK_NONE 0
776#define OPLOCK_EXCLUSIVE 1
777#define OPLOCK_BATCH 2
778#define OPLOCK_READ 3 /* level 2 oplock */
779
780/* open response for CreateAction shifted left */
781#define CIFS_CREATE_ACTION 0x20000 /* file created */
782
783typedef struct smb_com_open_rsp {
784 struct smb_hdr hdr; /* wct = 34 BB */
785 __u8 AndXCommand;
786 __u8 AndXReserved;
787 __le16 AndXOffset;
788 __u8 OplockLevel;
789 __u16 Fid;
790 __le32 CreateAction;
791 __le64 CreationTime;
792 __le64 LastAccessTime;
793 __le64 LastWriteTime;
794 __le64 ChangeTime;
795 __le32 FileAttributes;
796 __le64 AllocationSize;
797 __le64 EndOfFile;
798 __le16 FileType;
799 __le16 DeviceState;
800 __u8 DirectoryFlag;
801 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700802} __attribute__((packed)) OPEN_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803
Steve Frencha9d02ad2005-08-24 23:06:05 -0700804/* format of legacy open request */
805typedef struct smb_com_openx_req {
806 struct smb_hdr hdr; /* wct = 15 */
807 __u8 AndXCommand;
808 __u8 AndXReserved;
809 __le16 AndXOffset;
810 __le16 OpenFlags;
811 __le16 Mode;
812 __le16 Sattr; /* search attributes */
813 __le16 FileAttributes; /* dos attrs */
814 __le32 CreateTime; /* os2 format */
815 __le16 OpenFunction;
816 __le32 EndOfFile;
817 __le32 Timeout;
818 __le32 Reserved;
Steve French70ca7342005-09-22 16:32:06 -0700819 __le16 ByteCount; /* file name follows */
Steve Frencha9d02ad2005-08-24 23:06:05 -0700820 char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -0700821} __attribute__((packed)) OPENX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700822
823typedef struct smb_com_openx_rsp {
824 struct smb_hdr hdr; /* wct = 15 */
825 __u8 AndXCommand;
826 __u8 AndXReserved;
827 __le16 AndXOffset;
828 __u16 Fid;
829 __le16 FileAttributes;
830 __le32 LastWriteTime; /* os2 format */
831 __le32 EndOfFile;
832 __le16 Access;
833 __le16 FileType;
834 __le16 IPCState;
835 __le16 Action;
836 __u32 FileId;
837 __u16 Reserved;
838 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000839} __attribute__((packed)) OPENX_RSP;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700840
Steve French595dcfe2007-02-08 18:11:42 +0000841/* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
842
Steve Frencha9d02ad2005-08-24 23:06:05 -0700843/* Legacy write request for older servers */
844typedef struct smb_com_writex_req {
Steve French50c2f752007-07-13 00:33:32 +0000845 struct smb_hdr hdr; /* wct = 12 */
846 __u8 AndXCommand;
847 __u8 AndXReserved;
848 __le16 AndXOffset;
849 __u16 Fid;
850 __le32 OffsetLow;
851 __u32 Reserved; /* Timeout */
852 __le16 WriteMode; /* 1 = write through */
853 __le16 Remaining;
854 __le16 Reserved2;
855 __le16 DataLengthLow;
856 __le16 DataOffset;
857 __le16 ByteCount;
858 __u8 Pad; /* BB check for whether padded to DWORD
859 boundary and optimum performance here */
860 char Data[0];
Steve French0753ca72005-10-27 13:55:12 -0700861} __attribute__((packed)) WRITEX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700862
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863typedef struct smb_com_write_req {
864 struct smb_hdr hdr; /* wct = 14 */
865 __u8 AndXCommand;
866 __u8 AndXReserved;
867 __le16 AndXOffset;
868 __u16 Fid;
869 __le32 OffsetLow;
870 __u32 Reserved;
871 __le16 WriteMode;
872 __le16 Remaining;
873 __le16 DataLengthHigh;
874 __le16 DataLengthLow;
875 __le16 DataOffset;
876 __le32 OffsetHigh;
877 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000878 __u8 Pad; /* BB check for whether padded to DWORD
879 boundary and optimum performance here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 char Data[0];
Steve French0753ca72005-10-27 13:55:12 -0700881} __attribute__((packed)) WRITE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882
883typedef struct smb_com_write_rsp {
884 struct smb_hdr hdr; /* wct = 6 */
885 __u8 AndXCommand;
886 __u8 AndXReserved;
887 __le16 AndXOffset;
888 __le16 Count;
889 __le16 Remaining;
890 __le16 CountHigh;
891 __u16 Reserved;
892 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700893} __attribute__((packed)) WRITE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894
Steve Frencha9d02ad2005-08-24 23:06:05 -0700895/* legacy read request for older servers */
896typedef struct smb_com_readx_req {
Steve French50c2f752007-07-13 00:33:32 +0000897 struct smb_hdr hdr; /* wct = 10 */
898 __u8 AndXCommand;
899 __u8 AndXReserved;
900 __le16 AndXOffset;
901 __u16 Fid;
902 __le32 OffsetLow;
903 __le16 MaxCount;
904 __le16 MinCount; /* obsolete */
905 __le32 Reserved;
906 __le16 Remaining;
907 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700908} __attribute__((packed)) READX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700909
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910typedef struct smb_com_read_req {
911 struct smb_hdr hdr; /* wct = 12 */
912 __u8 AndXCommand;
913 __u8 AndXReserved;
914 __le16 AndXOffset;
915 __u16 Fid;
916 __le32 OffsetLow;
917 __le16 MaxCount;
918 __le16 MinCount; /* obsolete */
919 __le32 MaxCountHigh;
920 __le16 Remaining;
921 __le32 OffsetHigh;
922 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700923} __attribute__((packed)) READ_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924
925typedef struct smb_com_read_rsp {
926 struct smb_hdr hdr; /* wct = 12 */
927 __u8 AndXCommand;
928 __u8 AndXReserved;
929 __le16 AndXOffset;
930 __le16 Remaining;
931 __le16 DataCompactionMode;
932 __le16 Reserved;
933 __le16 DataLength;
934 __le16 DataOffset;
935 __le16 DataLengthHigh;
936 __u64 Reserved2;
937 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000938 __u8 Pad; /* BB check for whether padded to DWORD
939 boundary and optimum performance here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 char Data[1];
Steve French0753ca72005-10-27 13:55:12 -0700941} __attribute__((packed)) READ_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942
943typedef struct locking_andx_range {
944 __le16 Pid;
945 __le16 Pad;
946 __le32 OffsetHigh;
947 __le32 OffsetLow;
948 __le32 LengthHigh;
949 __le32 LengthLow;
Steve French0753ca72005-10-27 13:55:12 -0700950} __attribute__((packed)) LOCKING_ANDX_RANGE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951
952#define LOCKING_ANDX_SHARED_LOCK 0x01
953#define LOCKING_ANDX_OPLOCK_RELEASE 0x02
954#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
955#define LOCKING_ANDX_CANCEL_LOCK 0x08
956#define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
957
958typedef struct smb_com_lock_req {
959 struct smb_hdr hdr; /* wct = 8 */
960 __u8 AndXCommand;
961 __u8 AndXReserved;
962 __le16 AndXOffset;
963 __u16 Fid;
964 __u8 LockType;
965 __u8 OplockLevel;
966 __le32 Timeout;
967 __le16 NumberOfUnlocks;
968 __le16 NumberOfLocks;
969 __le16 ByteCount;
970 LOCKING_ANDX_RANGE Locks[1];
Steve French0753ca72005-10-27 13:55:12 -0700971} __attribute__((packed)) LOCK_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972
Steve French08547b02006-02-28 22:39:25 +0000973/* lock type */
974#define CIFS_RDLCK 0
975#define CIFS_WRLCK 1
976#define CIFS_UNLCK 2
Steve Frenchf654bac2005-04-28 22:41:04 -0700977typedef struct cifs_posix_lock {
978 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
979 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
980 __le32 pid;
981 __le64 start;
982 __le64 length;
983 /* BB what about additional owner info to identify network client */
Steve French0753ca72005-10-27 13:55:12 -0700984} __attribute__((packed)) CIFS_POSIX_LOCK;
Steve Frenchf654bac2005-04-28 22:41:04 -0700985
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986typedef struct smb_com_lock_rsp {
987 struct smb_hdr hdr; /* wct = 2 */
988 __u8 AndXCommand;
989 __u8 AndXReserved;
990 __le16 AndXOffset;
991 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700992} __attribute__((packed)) LOCK_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993
994typedef struct smb_com_rename_req {
995 struct smb_hdr hdr; /* wct = 1 */
996 __le16 SearchAttributes; /* target file attributes */
997 __le16 ByteCount;
998 __u8 BufferFormat; /* 4 = ASCII or Unicode */
999 unsigned char OldFileName[1];
1000 /* followed by __u8 BufferFormat2 */
1001 /* followed by NewFileName */
Steve French0753ca72005-10-27 13:55:12 -07001002} __attribute__((packed)) RENAME_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003
1004 /* copy request flags */
1005#define COPY_MUST_BE_FILE 0x0001
1006#define COPY_MUST_BE_DIR 0x0002
1007#define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
1008#define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
1009#define COPY_VERIFY_WRITES 0x0010
Steve French50c2f752007-07-13 00:33:32 +00001010#define COPY_TREE 0x0020
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011
1012typedef struct smb_com_copy_req {
1013 struct smb_hdr hdr; /* wct = 3 */
1014 __u16 Tid2;
1015 __le16 OpenFunction;
1016 __le16 Flags;
1017 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001018 __u8 BufferFormat; /* 4 = ASCII or Unicode */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019 unsigned char OldFileName[1];
1020 /* followed by __u8 BufferFormat2 */
1021 /* followed by NewFileName string */
Steve French0753ca72005-10-27 13:55:12 -07001022} __attribute__((packed)) COPY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023
1024typedef struct smb_com_copy_rsp {
1025 struct smb_hdr hdr; /* wct = 1 */
1026 __le16 CopyCount; /* number of files copied */
1027 __u16 ByteCount; /* may be zero */
1028 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
1029 unsigned char ErrorFileName[1]; /* only present if error in copy */
Steve French0753ca72005-10-27 13:55:12 -07001030} __attribute__((packed)) COPY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031
1032#define CREATE_HARD_LINK 0x103
1033#define MOVEFILE_COPY_ALLOWED 0x0002
1034#define MOVEFILE_REPLACE_EXISTING 0x0001
1035
1036typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
1037 struct smb_hdr hdr; /* wct = 4 */
1038 __le16 SearchAttributes; /* target file attributes */
1039 __le16 Flags; /* spec says Information Level */
1040 __le32 ClusterCount;
1041 __le16 ByteCount;
1042 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1043 unsigned char OldFileName[1];
1044 /* followed by __u8 BufferFormat2 */
1045 /* followed by NewFileName */
Steve French0753ca72005-10-27 13:55:12 -07001046} __attribute__((packed)) NT_RENAME_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047
1048typedef struct smb_com_rename_rsp {
1049 struct smb_hdr hdr; /* wct = 0 */
1050 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001051} __attribute__((packed)) RENAME_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052
1053typedef struct smb_com_delete_file_req {
1054 struct smb_hdr hdr; /* wct = 1 */
1055 __le16 SearchAttributes;
1056 __le16 ByteCount;
1057 __u8 BufferFormat; /* 4 = ASCII */
1058 unsigned char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001059} __attribute__((packed)) DELETE_FILE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060
1061typedef struct smb_com_delete_file_rsp {
1062 struct smb_hdr hdr; /* wct = 0 */
1063 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001064} __attribute__((packed)) DELETE_FILE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065
1066typedef struct smb_com_delete_directory_req {
1067 struct smb_hdr hdr; /* wct = 0 */
1068 __le16 ByteCount;
1069 __u8 BufferFormat; /* 4 = ASCII */
1070 unsigned char DirName[1];
Steve French0753ca72005-10-27 13:55:12 -07001071} __attribute__((packed)) DELETE_DIRECTORY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072
1073typedef struct smb_com_delete_directory_rsp {
1074 struct smb_hdr hdr; /* wct = 0 */
1075 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001076} __attribute__((packed)) DELETE_DIRECTORY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077
1078typedef struct smb_com_create_directory_req {
1079 struct smb_hdr hdr; /* wct = 0 */
1080 __le16 ByteCount;
1081 __u8 BufferFormat; /* 4 = ASCII */
1082 unsigned char DirName[1];
Steve French0753ca72005-10-27 13:55:12 -07001083} __attribute__((packed)) CREATE_DIRECTORY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084
1085typedef struct smb_com_create_directory_rsp {
1086 struct smb_hdr hdr; /* wct = 0 */
1087 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001088} __attribute__((packed)) CREATE_DIRECTORY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089
Steve French6b8edfe2005-08-23 20:26:03 -07001090typedef struct smb_com_query_information_req {
1091 struct smb_hdr hdr; /* wct = 0 */
1092 __le16 ByteCount; /* 1 + namelen + 1 */
1093 __u8 BufferFormat; /* 4 = ASCII */
1094 unsigned char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001095} __attribute__((packed)) QUERY_INFORMATION_REQ;
Steve French6b8edfe2005-08-23 20:26:03 -07001096
1097typedef struct smb_com_query_information_rsp {
1098 struct smb_hdr hdr; /* wct = 10 */
1099 __le16 attr;
1100 __le32 last_write_time;
1101 __le32 size;
1102 __u16 reserved[5];
1103 __le16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001104} __attribute__((packed)) QUERY_INFORMATION_RSP;
Steve French6b8edfe2005-08-23 20:26:03 -07001105
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106typedef struct smb_com_setattr_req {
1107 struct smb_hdr hdr; /* wct = 8 */
1108 __le16 attr;
1109 __le16 time_low;
1110 __le16 time_high;
1111 __le16 reserved[5]; /* must be zero */
1112 __u16 ByteCount;
1113 __u8 BufferFormat; /* 4 = ASCII */
1114 unsigned char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001115} __attribute__((packed)) SETATTR_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116
1117typedef struct smb_com_setattr_rsp {
1118 struct smb_hdr hdr; /* wct = 0 */
1119 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001120} __attribute__((packed)) SETATTR_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121
1122/* empty wct response to setattr */
1123
Steve French0a4b92c2006-01-12 15:44:21 -08001124/*******************************************************/
1125/* NT Transact structure defintions follow */
Steve French50c2f752007-07-13 00:33:32 +00001126/* Currently only ioctl, acl (get security descriptor) */
Steve French0a4b92c2006-01-12 15:44:21 -08001127/* and notify are implemented */
1128/*******************************************************/
1129typedef struct smb_com_ntransact_req {
Steve French50c2f752007-07-13 00:33:32 +00001130 struct smb_hdr hdr; /* wct >= 19 */
1131 __u8 MaxSetupCount;
1132 __u16 Reserved;
1133 __le32 TotalParameterCount;
1134 __le32 TotalDataCount;
1135 __le32 MaxParameterCount;
1136 __le32 MaxDataCount;
1137 __le32 ParameterCount;
1138 __le32 ParameterOffset;
1139 __le32 DataCount;
1140 __le32 DataOffset;
1141 __u8 SetupCount; /* four setup words follow subcommand */
1142 /* SNIA spec incorrectly included spurious pad here */
1143 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1144 /* SetupCount words follow then */
1145 __le16 ByteCount;
1146 __u8 Pad[3];
1147 __u8 Parms[0];
Steve French0a4b92c2006-01-12 15:44:21 -08001148} __attribute__((packed)) NTRANSACT_REQ;
1149
1150typedef struct smb_com_ntransact_rsp {
1151 struct smb_hdr hdr; /* wct = 18 */
1152 __u8 Reserved[3];
1153 __le32 TotalParameterCount;
1154 __le32 TotalDataCount;
1155 __le32 ParameterCount;
1156 __le32 ParameterOffset;
1157 __le32 ParameterDisplacement;
1158 __le32 DataCount;
1159 __le32 DataOffset;
1160 __le32 DataDisplacement;
1161 __u8 SetupCount; /* 0 */
1162 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001163 /* __u8 Pad[3]; */
Steve French0a4b92c2006-01-12 15:44:21 -08001164 /* parms and data follow */
1165} __attribute__((packed)) NTRANSACT_RSP;
1166
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167typedef struct smb_com_transaction_ioctl_req {
1168 struct smb_hdr hdr; /* wct = 23 */
1169 __u8 MaxSetupCount;
1170 __u16 Reserved;
1171 __le32 TotalParameterCount;
1172 __le32 TotalDataCount;
1173 __le32 MaxParameterCount;
1174 __le32 MaxDataCount;
1175 __le32 ParameterCount;
1176 __le32 ParameterOffset;
1177 __le32 DataCount;
1178 __le32 DataOffset;
1179 __u8 SetupCount; /* four setup words follow subcommand */
1180 /* SNIA spec incorrectly included spurious pad here */
Steve French0a4b92c2006-01-12 15:44:21 -08001181 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 __le32 FunctionCode;
1183 __u16 Fid;
Steve French0a4b92c2006-01-12 15:44:21 -08001184 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */
1185 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 __le16 ByteCount;
1187 __u8 Pad[3];
1188 __u8 Data[1];
Steve French0753ca72005-10-27 13:55:12 -07001189} __attribute__((packed)) TRANSACT_IOCTL_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190
1191typedef struct smb_com_transaction_ioctl_rsp {
1192 struct smb_hdr hdr; /* wct = 19 */
1193 __u8 Reserved[3];
1194 __le32 TotalParameterCount;
1195 __le32 TotalDataCount;
1196 __le32 ParameterCount;
1197 __le32 ParameterOffset;
1198 __le32 ParameterDisplacement;
1199 __le32 DataCount;
1200 __le32 DataOffset;
1201 __le32 DataDisplacement;
1202 __u8 SetupCount; /* 1 */
1203 __le16 ReturnedDataLen;
1204 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001205} __attribute__((packed)) TRANSACT_IOCTL_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206
Steve French0a4b92c2006-01-12 15:44:21 -08001207#define CIFS_ACL_OWNER 1
1208#define CIFS_ACL_GROUP 2
1209#define CIFS_ACL_DACL 4
1210#define CIFS_ACL_SACL 8
1211
1212typedef struct smb_com_transaction_qsec_req {
1213 struct smb_hdr hdr; /* wct = 19 */
1214 __u8 MaxSetupCount;
1215 __u16 Reserved;
1216 __le32 TotalParameterCount;
1217 __le32 TotalDataCount;
1218 __le32 MaxParameterCount;
1219 __le32 MaxDataCount;
1220 __le32 ParameterCount;
1221 __le32 ParameterOffset;
1222 __le32 DataCount;
1223 __le32 DataOffset;
1224 __u8 SetupCount; /* no setup words follow subcommand */
1225 /* SNIA spec incorrectly included spurious pad here */
1226 __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
1227 __le16 ByteCount; /* bcc = 3 + 8 */
1228 __u8 Pad[3];
1229 __u16 Fid;
1230 __u16 Reserved2;
1231 __le32 AclFlags;
1232} __attribute__((packed)) QUERY_SEC_DESC_REQ;
1233
Steve French7505e052007-11-01 18:03:01 +00001234
1235typedef struct smb_com_transaction_ssec_req {
1236 struct smb_hdr hdr; /* wct = 19 */
1237 __u8 MaxSetupCount;
1238 __u16 Reserved;
1239 __le32 TotalParameterCount;
1240 __le32 TotalDataCount;
1241 __le32 MaxParameterCount;
1242 __le32 MaxDataCount;
1243 __le32 ParameterCount;
1244 __le32 ParameterOffset;
1245 __le32 DataCount;
1246 __le32 DataOffset;
1247 __u8 SetupCount; /* no setup words follow subcommand */
1248 /* SNIA spec incorrectly included spurious pad here */
1249 __le16 SubCommand; /* 3 = SET_SECURITY_DESC */
1250 __le16 ByteCount; /* bcc = 3 + 8 */
1251 __u8 Pad[3];
1252 __u16 Fid;
1253 __u16 Reserved2;
1254 __le32 AclFlags;
1255} __attribute__((packed)) SET_SEC_DESC_REQ;
1256
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257typedef struct smb_com_transaction_change_notify_req {
1258 struct smb_hdr hdr; /* wct = 23 */
1259 __u8 MaxSetupCount;
1260 __u16 Reserved;
1261 __le32 TotalParameterCount;
1262 __le32 TotalDataCount;
1263 __le32 MaxParameterCount;
1264 __le32 MaxDataCount;
1265 __le32 ParameterCount;
1266 __le32 ParameterOffset;
1267 __le32 DataCount;
1268 __le32 DataOffset;
1269 __u8 SetupCount; /* four setup words follow subcommand */
1270 /* SNIA spec incorrectly included spurious pad here */
1271 __le16 SubCommand;/* 4 = Change Notify */
1272 __le32 CompletionFilter; /* operation to monitor */
1273 __u16 Fid;
1274 __u8 WatchTree; /* 1 = Monitor subdirectories */
1275 __u8 Reserved2;
1276 __le16 ByteCount;
Steve French0a4b92c2006-01-12 15:44:21 -08001277/* __u8 Pad[3];*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278/* __u8 Data[1];*/
Steve French0753ca72005-10-27 13:55:12 -07001279} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280
Steve French50c2f752007-07-13 00:33:32 +00001281/* BB eventually change to use generic ntransact rsp struct
Steve French0a4b92c2006-01-12 15:44:21 -08001282 and validation routine */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283typedef struct smb_com_transaction_change_notify_rsp {
1284 struct smb_hdr hdr; /* wct = 18 */
1285 __u8 Reserved[3];
1286 __le32 TotalParameterCount;
1287 __le32 TotalDataCount;
1288 __le32 ParameterCount;
1289 __le32 ParameterOffset;
1290 __le32 ParameterDisplacement;
1291 __le32 DataCount;
1292 __le32 DataOffset;
1293 __le32 DataDisplacement;
1294 __u8 SetupCount; /* 0 */
1295 __u16 ByteCount;
1296 /* __u8 Pad[3]; */
Steve French0753ca72005-10-27 13:55:12 -07001297} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298/* Completion Filter flags for Notify */
1299#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1300#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1301#define FILE_NOTIFY_CHANGE_NAME 0x00000003
1302#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1303#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1304#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1305#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1306#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1307#define FILE_NOTIFY_CHANGE_EA 0x00000080
1308#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1309#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1310#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1311#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1312
1313#define FILE_ACTION_ADDED 0x00000001
1314#define FILE_ACTION_REMOVED 0x00000002
1315#define FILE_ACTION_MODIFIED 0x00000003
1316#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1317#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1318#define FILE_ACTION_ADDED_STREAM 0x00000006
1319#define FILE_ACTION_REMOVED_STREAM 0x00000007
1320#define FILE_ACTION_MODIFIED_STREAM 0x00000008
1321
1322/* response contains array of the following structures */
1323struct file_notify_information {
1324 __le32 NextEntryOffset;
1325 __le32 Action;
1326 __le32 FileNameLength;
1327 __u8 FileName[0];
Steve French50c2f752007-07-13 00:33:32 +00001328} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329
1330struct reparse_data {
1331 __u32 ReparseTag;
1332 __u16 ReparseDataLength;
1333 __u16 Reserved;
1334 __u16 AltNameOffset;
1335 __u16 AltNameLen;
1336 __u16 TargetNameOffset;
1337 __u16 TargetNameLen;
1338 char LinkNamesBuf[1];
Steve French0753ca72005-10-27 13:55:12 -07001339} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340
1341struct cifs_quota_data {
1342 __u32 rsrvd1; /* 0 */
1343 __u32 sid_size;
1344 __u64 rsrvd2; /* 0 */
1345 __u64 space_used;
1346 __u64 soft_limit;
1347 __u64 hard_limit;
1348 char sid[1]; /* variable size? */
Steve French0753ca72005-10-27 13:55:12 -07001349} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350
1351/* quota sub commands */
1352#define QUOTA_LIST_CONTINUE 0
1353#define QUOTA_LIST_START 0x100
1354#define QUOTA_FOR_SID 0x101
1355
1356struct trans2_req {
1357 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1358 __le16 TotalParameterCount;
1359 __le16 TotalDataCount;
1360 __le16 MaxParameterCount;
1361 __le16 MaxDataCount;
1362 __u8 MaxSetupCount;
1363 __u8 Reserved;
1364 __le16 Flags;
1365 __le32 Timeout;
1366 __u16 Reserved2;
1367 __le16 ParameterCount;
1368 __le16 ParameterOffset;
1369 __le16 DataCount;
1370 __le16 DataOffset;
1371 __u8 SetupCount;
1372 __u8 Reserved3;
1373 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1374 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001375} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376
1377struct smb_t2_req {
1378 struct smb_hdr hdr;
1379 struct trans2_req t2_req;
Steve French0753ca72005-10-27 13:55:12 -07001380} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381
1382struct trans2_resp {
1383 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1384 __le16 TotalParameterCount;
1385 __le16 TotalDataCount;
1386 __u16 Reserved;
1387 __le16 ParameterCount;
1388 __le16 ParameterOffset;
1389 __le16 ParameterDisplacement;
1390 __le16 DataCount;
1391 __le16 DataOffset;
1392 __le16 DataDisplacement;
1393 __u8 SetupCount;
1394 __u8 Reserved1;
1395 /* SetupWords[SetupCount];
1396 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001397 __u16 Reserved2;*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 /* data area follows */
Steve French0753ca72005-10-27 13:55:12 -07001399} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400
1401struct smb_t2_rsp {
1402 struct smb_hdr hdr;
1403 struct trans2_resp t2_rsp;
Steve French0753ca72005-10-27 13:55:12 -07001404} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405
1406/* PathInfo/FileInfo infolevels */
1407#define SMB_INFO_STANDARD 1
1408#define SMB_SET_FILE_EA 2
1409#define SMB_QUERY_FILE_EA_SIZE 2
1410#define SMB_INFO_QUERY_EAS_FROM_LIST 3
1411#define SMB_INFO_QUERY_ALL_EAS 4
1412#define SMB_INFO_IS_NAME_VALID 6
1413#define SMB_QUERY_FILE_BASIC_INFO 0x101
1414#define SMB_QUERY_FILE_STANDARD_INFO 0x102
1415#define SMB_QUERY_FILE_EA_INFO 0x103
1416#define SMB_QUERY_FILE_NAME_INFO 0x104
1417#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1418#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1419#define SMB_QUERY_FILE_ALL_INFO 0x107
1420#define SMB_QUERY_ALT_NAME_INFO 0x108
1421#define SMB_QUERY_FILE_STREAM_INFO 0x109
1422#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1423#define SMB_QUERY_FILE_UNIX_BASIC 0x200
1424#define SMB_QUERY_FILE_UNIX_LINK 0x201
1425#define SMB_QUERY_POSIX_ACL 0x204
Steve French87f440e2007-02-07 00:29:46 +00001426#define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
Steve Frenchf654bac2005-04-28 22:41:04 -07001428#define SMB_QUERY_POSIX_PERMISSION 0x207
1429#define SMB_QUERY_POSIX_LOCK 0x208
Steve French87f440e2007-02-07 00:29:46 +00001430/* #define SMB_POSIX_OPEN 0x209 */
1431/* #define SMB_POSIX_UNLINK 0x20a */
1432#define SMB_QUERY_FILE__UNIX_INFO2 0x20b
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1434#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1435#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
Steve French50c2f752007-07-13 00:33:32 +00001436#define SMB_QUERY_FILE_POSITION_INFO 0x3f6
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437#define SMB_QUERY_FILE_MODE_INFO 0x3f8
Steve French50c2f752007-07-13 00:33:32 +00001438#define SMB_QUERY_FILE_ALGN_INFO 0x3f9
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439
1440
1441#define SMB_SET_FILE_BASIC_INFO 0x101
1442#define SMB_SET_FILE_DISPOSITION_INFO 0x102
1443#define SMB_SET_FILE_ALLOCATION_INFO 0x103
1444#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1445#define SMB_SET_FILE_UNIX_BASIC 0x200
1446#define SMB_SET_FILE_UNIX_LINK 0x201
1447#define SMB_SET_FILE_UNIX_HLINK 0x203
1448#define SMB_SET_POSIX_ACL 0x204
1449#define SMB_SET_XATTR 0x205
1450#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
Steve Frenchf654bac2005-04-28 22:41:04 -07001451#define SMB_SET_POSIX_LOCK 0x208
Steve French2fe87f02006-09-21 07:02:52 +00001452#define SMB_POSIX_OPEN 0x209
Steve French87f440e2007-02-07 00:29:46 +00001453#define SMB_POSIX_UNLINK 0x20a
Steve French2dd29d32007-04-23 22:07:35 +00001454#define SMB_SET_FILE_UNIX_INFO2 0x20b
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455#define SMB_SET_FILE_BASIC_INFO2 0x3ec
Steve French87f440e2007-02-07 00:29:46 +00001456#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457#define SMB_FILE_ALL_INFO2 0x3fa
1458#define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1459#define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1460#define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1461#define SMB_FILE_QUOTA_INFO 0x408
1462#define SMB_FILE_REPARSEPOINT_INFO 0x409
1463#define SMB_FILE_MAXIMUM_INFO 0x40d
1464
1465/* Find File infolevels */
Steve French5bafd762006-06-07 00:18:43 +00001466#define SMB_FIND_FILE_INFO_STANDARD 0x001
1467#define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1468#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1470#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1471#define SMB_FIND_FILE_NAMES_INFO 0x103
1472#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1473#define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1474#define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1475#define SMB_FIND_FILE_UNIX 0x202
1476
1477typedef struct smb_com_transaction2_qpi_req {
1478 struct smb_hdr hdr; /* wct = 14+ */
1479 __le16 TotalParameterCount;
1480 __le16 TotalDataCount;
1481 __le16 MaxParameterCount;
1482 __le16 MaxDataCount;
1483 __u8 MaxSetupCount;
1484 __u8 Reserved;
1485 __le16 Flags;
1486 __le32 Timeout;
1487 __u16 Reserved2;
1488 __le16 ParameterCount;
1489 __le16 ParameterOffset;
1490 __le16 DataCount;
1491 __le16 DataOffset;
1492 __u8 SetupCount;
1493 __u8 Reserved3;
1494 __le16 SubCommand; /* one setup word */
1495 __le16 ByteCount;
1496 __u8 Pad;
1497 __le16 InformationLevel;
1498 __u32 Reserved4;
1499 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001500} __attribute__((packed)) TRANSACTION2_QPI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501
1502typedef struct smb_com_transaction2_qpi_rsp {
1503 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1504 struct trans2_resp t2;
1505 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001506 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001507} __attribute__((packed)) TRANSACTION2_QPI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508
1509typedef struct smb_com_transaction2_spi_req {
1510 struct smb_hdr hdr; /* wct = 15 */
1511 __le16 TotalParameterCount;
1512 __le16 TotalDataCount;
1513 __le16 MaxParameterCount;
1514 __le16 MaxDataCount;
1515 __u8 MaxSetupCount;
1516 __u8 Reserved;
1517 __le16 Flags;
1518 __le32 Timeout;
1519 __u16 Reserved2;
1520 __le16 ParameterCount;
1521 __le16 ParameterOffset;
1522 __le16 DataCount;
1523 __le16 DataOffset;
1524 __u8 SetupCount;
1525 __u8 Reserved3;
1526 __le16 SubCommand; /* one setup word */
1527 __le16 ByteCount;
1528 __u8 Pad;
1529 __u16 Pad1;
1530 __le16 InformationLevel;
1531 __u32 Reserved4;
1532 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001533} __attribute__((packed)) TRANSACTION2_SPI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534
1535typedef struct smb_com_transaction2_spi_rsp {
1536 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1537 struct trans2_resp t2;
1538 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001539 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001540} __attribute__((packed)) TRANSACTION2_SPI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541
1542struct set_file_rename {
1543 __le32 overwrite; /* 1 = overwrite dest */
1544 __u32 root_fid; /* zero */
1545 __le32 target_name_len;
1546 char target_name[0]; /* Must be unicode */
Steve French0753ca72005-10-27 13:55:12 -07001547} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548
1549struct smb_com_transaction2_sfi_req {
1550 struct smb_hdr hdr; /* wct = 15 */
1551 __le16 TotalParameterCount;
1552 __le16 TotalDataCount;
1553 __le16 MaxParameterCount;
1554 __le16 MaxDataCount;
1555 __u8 MaxSetupCount;
1556 __u8 Reserved;
1557 __le16 Flags;
1558 __le32 Timeout;
1559 __u16 Reserved2;
1560 __le16 ParameterCount;
1561 __le16 ParameterOffset;
1562 __le16 DataCount;
1563 __le16 DataOffset;
1564 __u8 SetupCount;
1565 __u8 Reserved3;
1566 __le16 SubCommand; /* one setup word */
1567 __le16 ByteCount;
1568 __u8 Pad;
1569 __u16 Pad1;
1570 __u16 Fid;
1571 __le16 InformationLevel;
Steve French50c2f752007-07-13 00:33:32 +00001572 __u16 Reserved4;
Steve French0753ca72005-10-27 13:55:12 -07001573} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001574
1575struct smb_com_transaction2_sfi_rsp {
1576 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1577 struct trans2_resp t2;
1578 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001579 __u16 Reserved2; /* parameter word reserved -
Steve Frenchf654bac2005-04-28 22:41:04 -07001580 present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001581} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001582
Steve Frenchf654bac2005-04-28 22:41:04 -07001583struct smb_t2_qfi_req {
Steve French50c2f752007-07-13 00:33:32 +00001584 struct smb_hdr hdr;
1585 struct trans2_req t2;
Steve Frenchf654bac2005-04-28 22:41:04 -07001586 __u8 Pad;
Steve Frenchf654bac2005-04-28 22:41:04 -07001587 __u16 Fid;
1588 __le16 InformationLevel;
Steve French0753ca72005-10-27 13:55:12 -07001589} __attribute__((packed));
Steve Frenchf654bac2005-04-28 22:41:04 -07001590
1591struct smb_t2_qfi_rsp {
Steve French50c2f752007-07-13 00:33:32 +00001592 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1593 struct trans2_resp t2;
1594 __u16 ByteCount;
1595 __u16 Reserved2; /* parameter word reserved -
1596 present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001597} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598
1599/*
Steve French50c2f752007-07-13 00:33:32 +00001600 * Flags on T2 FINDFIRST and FINDNEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001601 */
1602#define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1603#define CIFS_SEARCH_CLOSE_AT_END 0x0002
1604#define CIFS_SEARCH_RETURN_RESUME 0x0004
1605#define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1606#define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1607
1608/*
1609 * Size of the resume key on FINDFIRST and FINDNEXT calls
1610 */
1611#define CIFS_SMB_RESUME_KEY_SIZE 4
1612
1613typedef struct smb_com_transaction2_ffirst_req {
1614 struct smb_hdr hdr; /* wct = 15 */
1615 __le16 TotalParameterCount;
1616 __le16 TotalDataCount;
1617 __le16 MaxParameterCount;
1618 __le16 MaxDataCount;
1619 __u8 MaxSetupCount;
1620 __u8 Reserved;
1621 __le16 Flags;
1622 __le32 Timeout;
1623 __u16 Reserved2;
1624 __le16 ParameterCount;
1625 __le16 ParameterOffset;
1626 __le16 DataCount;
1627 __le16 DataOffset;
1628 __u8 SetupCount; /* one */
1629 __u8 Reserved3;
1630 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1631 __le16 ByteCount;
1632 __u8 Pad;
1633 __le16 SearchAttributes;
1634 __le16 SearchCount;
1635 __le16 SearchFlags;
1636 __le16 InformationLevel;
1637 __le32 SearchStorageType;
1638 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001639} __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640
1641typedef struct smb_com_transaction2_ffirst_rsp {
1642 struct smb_hdr hdr; /* wct = 10 */
1643 struct trans2_resp t2;
1644 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001645} __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646
1647typedef struct smb_com_transaction2_ffirst_rsp_parms {
1648 __u16 SearchHandle;
1649 __le16 SearchCount;
1650 __le16 EndofSearch;
1651 __le16 EAErrorOffset;
1652 __le16 LastNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001653} __attribute__((packed)) T2_FFIRST_RSP_PARMS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654
1655typedef struct smb_com_transaction2_fnext_req {
1656 struct smb_hdr hdr; /* wct = 15 */
1657 __le16 TotalParameterCount;
1658 __le16 TotalDataCount;
1659 __le16 MaxParameterCount;
1660 __le16 MaxDataCount;
1661 __u8 MaxSetupCount;
1662 __u8 Reserved;
1663 __le16 Flags;
1664 __le32 Timeout;
1665 __u16 Reserved2;
1666 __le16 ParameterCount;
1667 __le16 ParameterOffset;
1668 __le16 DataCount;
1669 __le16 DataOffset;
1670 __u8 SetupCount; /* one */
1671 __u8 Reserved3;
1672 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1673 __le16 ByteCount;
1674 __u8 Pad;
1675 __u16 SearchHandle;
1676 __le16 SearchCount;
1677 __le16 InformationLevel;
1678 __u32 ResumeKey;
1679 __le16 SearchFlags;
1680 char ResumeFileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001681} __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682
1683typedef struct smb_com_transaction2_fnext_rsp {
1684 struct smb_hdr hdr; /* wct = 10 */
1685 struct trans2_resp t2;
1686 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001687} __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688
1689typedef struct smb_com_transaction2_fnext_rsp_parms {
1690 __le16 SearchCount;
1691 __le16 EndofSearch;
1692 __le16 EAErrorOffset;
1693 __le16 LastNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001694} __attribute__((packed)) T2_FNEXT_RSP_PARMS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695
1696/* QFSInfo Levels */
1697#define SMB_INFO_ALLOCATION 1
1698#define SMB_INFO_VOLUME 2
1699#define SMB_QUERY_FS_VOLUME_INFO 0x102
1700#define SMB_QUERY_FS_SIZE_INFO 0x103
1701#define SMB_QUERY_FS_DEVICE_INFO 0x104
1702#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1703#define SMB_QUERY_CIFS_UNIX_INFO 0x200
1704#define SMB_QUERY_POSIX_FS_INFO 0x201
Steve French87f440e2007-02-07 00:29:46 +00001705#define SMB_QUERY_POSIX_WHO_AM_I 0x202
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706#define SMB_QUERY_LABEL_INFO 0x3ea
1707#define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1708#define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1709#define SMB_QUERY_OBJECTID_INFO 0x3f0
1710
1711typedef struct smb_com_transaction2_qfsi_req {
1712 struct smb_hdr hdr; /* wct = 14+ */
1713 __le16 TotalParameterCount;
1714 __le16 TotalDataCount;
1715 __le16 MaxParameterCount;
1716 __le16 MaxDataCount;
1717 __u8 MaxSetupCount;
1718 __u8 Reserved;
1719 __le16 Flags;
1720 __le32 Timeout;
1721 __u16 Reserved2;
1722 __le16 ParameterCount;
1723 __le16 ParameterOffset;
1724 __le16 DataCount;
1725 __le16 DataOffset;
1726 __u8 SetupCount;
1727 __u8 Reserved3;
1728 __le16 SubCommand; /* one setup word */
1729 __le16 ByteCount;
1730 __u8 Pad;
1731 __le16 InformationLevel;
Steve French0753ca72005-10-27 13:55:12 -07001732} __attribute__((packed)) TRANSACTION2_QFSI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733
1734typedef struct smb_com_transaction_qfsi_rsp {
1735 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1736 struct trans2_resp t2;
1737 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001738 __u8 Pad; /* may be three bytes? *//* followed by data area */
Steve French0753ca72005-10-27 13:55:12 -07001739} __attribute__((packed)) TRANSACTION2_QFSI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740
Steve French87f440e2007-02-07 00:29:46 +00001741typedef struct whoami_rsp_data { /* Query level 0x202 */
1742 __u32 flags; /* 0 = Authenticated user 1 = GUEST */
1743 __u32 mask; /* which flags bits server understands ie 0x0001 */
1744 __u64 unix_user_id;
1745 __u64 unix_user_gid;
1746 __u32 number_of_supplementary_gids; /* may be zero */
1747 __u32 number_of_sids; /* may be zero */
1748 __u32 length_of_sid_array; /* in bytes - may be zero */
1749 __u32 pad; /* reserved - MBZ */
1750 /* __u64 gid_array[0]; */ /* may be empty */
1751 /* __u8 * psid_list */ /* may be empty */
1752} __attribute__((packed)) WHOAMI_RSP_DATA;
Jeremy Allisonac670552005-06-22 17:26:35 -07001753
1754/* SETFSInfo Levels */
1755#define SMB_SET_CIFS_UNIX_INFO 0x200
1756typedef struct smb_com_transaction2_setfsi_req {
1757 struct smb_hdr hdr; /* wct = 15 */
1758 __le16 TotalParameterCount;
1759 __le16 TotalDataCount;
1760 __le16 MaxParameterCount;
1761 __le16 MaxDataCount;
1762 __u8 MaxSetupCount;
1763 __u8 Reserved;
1764 __le16 Flags;
1765 __le32 Timeout;
1766 __u16 Reserved2;
1767 __le16 ParameterCount; /* 4 */
1768 __le16 ParameterOffset;
1769 __le16 DataCount; /* 12 */
1770 __le16 DataOffset;
1771 __u8 SetupCount; /* one */
1772 __u8 Reserved3;
1773 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1774 __le16 ByteCount;
1775 __u8 Pad;
1776 __u16 FileNum; /* Parameters start. */
1777 __le16 InformationLevel;/* Parameters end. */
1778 __le16 ClientUnixMajor; /* Data start. */
1779 __le16 ClientUnixMinor;
1780 __le64 ClientUnixCap; /* Data end */
Steve French0753ca72005-10-27 13:55:12 -07001781} __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
Jeremy Allisonac670552005-06-22 17:26:35 -07001782
1783typedef struct smb_com_transaction2_setfsi_rsp {
1784 struct smb_hdr hdr; /* wct = 10 */
1785 struct trans2_resp t2;
1786 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001787} __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
Jeremy Allisonac670552005-06-22 17:26:35 -07001788
1789
Linus Torvalds1da177e2005-04-16 15:20:36 -07001790typedef struct smb_com_transaction2_get_dfs_refer_req {
1791 struct smb_hdr hdr; /* wct = 15 */
1792 __le16 TotalParameterCount;
1793 __le16 TotalDataCount;
1794 __le16 MaxParameterCount;
1795 __le16 MaxDataCount;
1796 __u8 MaxSetupCount;
1797 __u8 Reserved;
1798 __le16 Flags;
1799 __le32 Timeout;
1800 __u16 Reserved2;
1801 __le16 ParameterCount;
1802 __le16 ParameterOffset;
1803 __le16 DataCount;
1804 __le16 DataOffset;
1805 __u8 SetupCount;
1806 __u8 Reserved3;
1807 __le16 SubCommand; /* one setup word */
1808 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001809 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max response length
1810 perhaps?) followed by one byte pad - doesn't
1811 seem to matter though */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812 __le16 MaxReferralLevel;
1813 char RequestFileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001814} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815
1816typedef struct dfs_referral_level_3 {
1817 __le16 VersionNumber;
1818 __le16 ReferralSize;
1819 __le16 ServerType; /* 0x0001 = CIFS server */
Steve French50c2f752007-07-13 00:33:32 +00001820 __le16 ReferralFlags; /* or proximity - not clear which since it is
1821 always set to zero - SNIA spec says 0x01
1822 means strip off PathConsumed chars before
1823 submitting RequestFileName to remote node */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824 __le16 TimeToLive;
1825 __le16 Proximity;
1826 __le16 DfsPathOffset;
1827 __le16 DfsAlternatePathOffset;
1828 __le16 NetworkAddressOffset;
Steve French0753ca72005-10-27 13:55:12 -07001829} __attribute__((packed)) REFERRAL3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830
1831typedef struct smb_com_transaction_get_dfs_refer_rsp {
1832 struct smb_hdr hdr; /* wct = 10 */
1833 struct trans2_resp t2;
1834 __u16 ByteCount;
1835 __u8 Pad;
1836 __le16 PathConsumed;
1837 __le16 NumberOfReferrals;
1838 __le16 DFSFlags;
1839 __u16 Pad2;
1840 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1841 /* followed by the strings pointed to by the referral structures */
Steve French0753ca72005-10-27 13:55:12 -07001842} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843
1844/* DFS Flags */
1845#define DFSREF_REFERRAL_SERVER 0x0001
1846#define DFSREF_STORAGE_SERVER 0x0002
1847
1848/* IOCTL information */
Steve French50c2f752007-07-13 00:33:32 +00001849/*
1850 * List of ioctl function codes that look to be of interest to remote clients
1851 * like this one. Need to do some experimentation to make sure they all work
1852 * remotely. Some of the following, such as the encryption/compression ones
1853 * would be invoked from tools via a specialized hook into the VFS rather
1854 * than via the standard vfs entry points
1855 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001856#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1857#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1858#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1859#define FSCTL_LOCK_VOLUME 0x00090018
1860#define FSCTL_UNLOCK_VOLUME 0x0009001C
1861#define FSCTL_GET_COMPRESSION 0x0009003C
1862#define FSCTL_SET_COMPRESSION 0x0009C040
1863#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1864#define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1865#define FSCTL_SET_REPARSE_POINT 0x000900A4
1866#define FSCTL_GET_REPARSE_POINT 0x000900A8
1867#define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1868#define FSCTL_SET_SPARSE 0x000900C4
1869#define FSCTL_SET_ZERO_DATA 0x000900C8
1870#define FSCTL_SET_ENCRYPTION 0x000900D7
1871#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1872#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1873#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1874#define FSCTL_SIS_COPYFILE 0x00090100
1875#define FSCTL_SIS_LINK_FILES 0x0009C104
1876
1877#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1878#define IO_REPARSE_TAG_HSM 0xC0000004
1879#define IO_REPARSE_TAG_SIS 0x80000007
1880
1881/*
1882 ************************************************************************
1883 * All structs for everything above the SMB PDUs themselves
Steve French50c2f752007-07-13 00:33:32 +00001884 * (such as the T2 level specific data) go here
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885 ************************************************************************
1886 */
1887
1888/*
1889 * Information on a server
1890 */
1891
1892struct serverInfo {
1893 char name[16];
1894 unsigned char versionMajor;
1895 unsigned char versionMinor;
1896 unsigned long type;
1897 unsigned int commentOffset;
Steve French0753ca72005-10-27 13:55:12 -07001898} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899
1900/*
1901 * The following structure is the format of the data returned on a NetShareEnum
1902 * with level "90" (x5A)
1903 */
1904
1905struct shareInfo {
1906 char shareName[13];
1907 char pad;
1908 unsigned short type;
1909 unsigned int commentOffset;
Steve French0753ca72005-10-27 13:55:12 -07001910} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911
1912struct aliasInfo {
1913 char aliasName[9];
1914 char pad;
1915 unsigned int commentOffset;
1916 unsigned char type[2];
Steve French0753ca72005-10-27 13:55:12 -07001917} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918
1919struct aliasInfo92 {
1920 int aliasNameOffset;
1921 int serverNameOffset;
1922 int shareNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001923} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001924
1925typedef struct {
1926 __le64 TotalAllocationUnits;
1927 __le64 FreeAllocationUnits;
1928 __le32 SectorsPerAllocationUnit;
1929 __le32 BytesPerSector;
Steve French50c2f752007-07-13 00:33:32 +00001930} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001931
1932typedef struct {
Steve French20962432005-09-21 22:05:57 -07001933 __le32 fsid;
1934 __le32 SectorsPerAllocationUnit;
1935 __le32 TotalAllocationUnits;
1936 __le32 FreeAllocationUnits;
1937 __le16 BytesPerSector;
Steve French0753ca72005-10-27 13:55:12 -07001938} __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
Steve French20962432005-09-21 22:05:57 -07001939
1940typedef struct {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001941 __le16 MajorVersionNumber;
1942 __le16 MinorVersionNumber;
1943 __le64 Capability;
Steve French50c2f752007-07-13 00:33:32 +00001944} __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/
Jeremy Allisonac670552005-06-22 17:26:35 -07001945
1946/* Version numbers for CIFS UNIX major and minor. */
1947#define CIFS_UNIX_MAJOR_VERSION 1
1948#define CIFS_UNIX_MINOR_VERSION 0
1949
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950/* Linux/Unix extensions capability flags */
1951#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
Steve Frenchf654bac2005-04-28 22:41:04 -07001952#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1953#define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1954#define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
Steve French82940a42006-03-02 03:24:57 +00001955#define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
Steve French87f440e2007-02-07 00:29:46 +00001956#define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
1957 calls including posix open
Steve French75865f8c2007-06-24 18:30:48 +00001958 and posix unlink */
1959#define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
Steve French50c2f752007-07-13 00:33:32 +00001960 to 0xFFFF00 */
Steve French75865f8c2007-06-24 18:30:48 +00001961#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
1962
Steve French82940a42006-03-02 03:24:57 +00001963#ifdef CONFIG_CIFS_POSIX
Steve French38e2aff2007-03-16 05:12:53 +00001964/* Can not set pathnames cap yet until we send new posix create SMB since
1965 otherwise server can treat such handles opened with older ntcreatex
1966 (by a new client which knows how to send posix path ops)
1967 as non-posix handles (can affect write behavior with byte range locks.
1968 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
Steve French75865f8c2007-06-24 18:30:48 +00001969/* #define CIFS_UNIX_CAP_MASK 0x000000fb */
Steve French50c2f752007-07-13 00:33:32 +00001970#define CIFS_UNIX_CAP_MASK 0x000000db
1971#else
Steve French82940a42006-03-02 03:24:57 +00001972#define CIFS_UNIX_CAP_MASK 0x00000013
1973#endif /* CONFIG_CIFS_POSIX */
1974
Jeremy Allisonac670552005-06-22 17:26:35 -07001975
Steve Frenchf28ac912005-04-28 22:41:07 -07001976#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
Jeremy Allisonac670552005-06-22 17:26:35 -07001977
Linus Torvalds1da177e2005-04-16 15:20:36 -07001978typedef struct {
1979 /* For undefined recommended transfer size return -1 in that field */
1980 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
Steve French50c2f752007-07-13 00:33:32 +00001981 __le32 BlockSize;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982 /* The next three fields are in terms of the block size.
1983 (above). If block size is unknown, 4096 would be a
Steve French50c2f752007-07-13 00:33:32 +00001984 reasonable block size for a server to report.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985 Note that returning the blocks/blocksavail removes need
1986 to make a second call (to QFSInfo level 0x103 to get this info.
1987 UserBlockAvail is typically less than or equal to BlocksAvail,
1988 if no distinction is made return the same value in each */
1989 __le64 TotalBlocks;
1990 __le64 BlocksAvail; /* bfree */
1991 __le64 UserBlocksAvail; /* bavail */
1992 /* For undefined Node fields or FSID return -1 */
1993 __le64 TotalFileNodes;
1994 __le64 FreeFileNodes;
1995 __le64 FileSysIdentifier; /* fsid */
1996 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1997 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
Steve French0753ca72005-10-27 13:55:12 -07001998} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999
2000/* DeviceType Flags */
2001#define FILE_DEVICE_CD_ROM 0x00000002
2002#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2003#define FILE_DEVICE_DFS 0x00000006
2004#define FILE_DEVICE_DISK 0x00000007
2005#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2006#define FILE_DEVICE_FILE_SYSTEM 0x00000009
2007#define FILE_DEVICE_NAMED_PIPE 0x00000011
2008#define FILE_DEVICE_NETWORK 0x00000012
2009#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2010#define FILE_DEVICE_NULL 0x00000015
2011#define FILE_DEVICE_PARALLEL_PORT 0x00000016
2012#define FILE_DEVICE_PRINTER 0x00000018
2013#define FILE_DEVICE_SERIAL_PORT 0x0000001b
2014#define FILE_DEVICE_STREAMS 0x0000001e
2015#define FILE_DEVICE_TAPE 0x0000001f
2016#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2017#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2018#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2019
2020typedef struct {
2021 __le32 DeviceType;
2022 __le32 DeviceCharacteristics;
Steve French39798772006-05-31 22:40:51 +00002023} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024
2025typedef struct {
2026 __le32 Attributes;
2027 __le32 MaxPathNameComponentLength;
2028 __le32 FileSystemNameLen;
Steve French39798772006-05-31 22:40:51 +00002029 char FileSystemName[52]; /* do not have to save this - get subset? */
Steve French0753ca72005-10-27 13:55:12 -07002030} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031
2032/******************************************************************************/
2033/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2034/******************************************************************************/
2035typedef struct { /* data block encoding of response to level 263 QPathInfo */
2036 __le64 CreationTime;
2037 __le64 LastAccessTime;
2038 __le64 LastWriteTime;
2039 __le64 ChangeTime;
2040 __le32 Attributes;
2041 __u32 Pad1;
2042 __le64 AllocationSize;
2043 __le64 EndOfFile; /* size ie offset to first free byte in file */
2044 __le32 NumberOfLinks; /* hard links */
2045 __u8 DeletePending;
2046 __u8 Directory;
2047 __u16 Pad2;
2048 __u64 IndexNumber;
2049 __le32 EASize;
2050 __le32 AccessFlags;
2051 __u64 IndexNumber1;
2052 __le64 CurrentByteOffset;
2053 __le32 Mode;
2054 __le32 AlignmentRequirement;
2055 __le32 FileNameLength;
2056 char FileName[1];
Steve French87f440e2007-02-07 00:29:46 +00002057} __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058
2059/* defines for enumerating possible values of the Unix type field below */
2060#define UNIX_FILE 0
2061#define UNIX_DIR 1
2062#define UNIX_SYMLINK 2
2063#define UNIX_CHARDEV 3
2064#define UNIX_BLOCKDEV 4
2065#define UNIX_FIFO 5
2066#define UNIX_SOCKET 6
2067typedef struct {
2068 __le64 EndOfFile;
2069 __le64 NumOfBytes;
2070 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2071 __le64 LastAccessTime;
2072 __le64 LastModificationTime;
2073 __le64 Uid;
2074 __le64 Gid;
2075 __le32 Type;
2076 __le64 DevMajor;
2077 __le64 DevMinor;
2078 __u64 UniqueId;
2079 __le64 Permissions;
2080 __le64 Nlinks;
Steve French87f440e2007-02-07 00:29:46 +00002081} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082
2083typedef struct {
2084 char LinkDest[1];
Steve French87f440e2007-02-07 00:29:46 +00002085} __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086
2087/* The following three structures are needed only for
2088 setting time to NT4 and some older servers via
2089 the primitive DOS time format */
2090typedef struct {
2091 __u16 Day:5;
2092 __u16 Month:4;
2093 __u16 Year:7;
Steve French0753ca72005-10-27 13:55:12 -07002094} __attribute__((packed)) SMB_DATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095
2096typedef struct {
2097 __u16 TwoSeconds:5;
2098 __u16 Minutes:6;
2099 __u16 Hours:5;
Steve French0753ca72005-10-27 13:55:12 -07002100} __attribute__((packed)) SMB_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101
2102typedef struct {
2103 __le16 CreationDate; /* SMB Date see above */
2104 __le16 CreationTime; /* SMB Time */
2105 __le16 LastAccessDate;
2106 __le16 LastAccessTime;
2107 __le16 LastWriteDate;
2108 __le16 LastWriteTime;
2109 __le32 DataSize; /* File Size (EOF) */
2110 __le32 AllocationSize;
2111 __le16 Attributes; /* verify not u32 */
2112 __le32 EASize;
Steve French0753ca72005-10-27 13:55:12 -07002113} __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002114
2115typedef struct {
2116 __le64 CreationTime;
2117 __le64 LastAccessTime;
2118 __le64 LastWriteTime;
2119 __le64 ChangeTime;
2120 __le32 Attributes;
2121 __u32 Pad;
Steve French87f440e2007-02-07 00:29:46 +00002122} __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123
2124struct file_allocation_info {
2125 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
Steve French5bafd762006-06-07 00:18:43 +00002126} __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2127 0x105 for query */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128
2129struct file_end_of_file_info {
2130 __le64 FileSize; /* offset to end of file */
Steve French87f440e2007-02-07 00:29:46 +00002131} __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132
2133struct file_alt_name_info {
2134 __u8 alt_name[1];
Steve French0753ca72005-10-27 13:55:12 -07002135} __attribute__((packed)); /* level 0x0108 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136
2137struct file_stream_info {
2138 __le32 number_of_streams; /* BB check sizes and verify location */
Steve French50c2f752007-07-13 00:33:32 +00002139 /* followed by info on streams themselves
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140 u64 size;
Steve French50c2f752007-07-13 00:33:32 +00002141 u64 allocation_size
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142 stream info */
2143}; /* level 0x109 */
2144
2145struct file_compression_info {
2146 __le64 compressed_size;
2147 __le16 format;
2148 __u8 unit_shift;
2149 __u8 ch_shift;
2150 __u8 cl_shift;
2151 __u8 pad[3];
Steve French0753ca72005-10-27 13:55:12 -07002152} __attribute__((packed)); /* level 0x10b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153
2154/* POSIX ACL set/query path info structures */
2155#define CIFS_ACL_VERSION 1
2156struct cifs_posix_ace { /* access control entry (ACE) */
2157 __u8 cifs_e_tag;
2158 __u8 cifs_e_perm;
2159 __le64 cifs_uid; /* or gid */
Steve French50c2f752007-07-13 00:33:32 +00002160} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161
2162struct cifs_posix_acl { /* access conrol list (ACL) */
2163 __le16 version;
2164 __le16 access_entry_count; /* access ACL - count of entries */
2165 __le16 default_entry_count; /* default ACL - count of entries */
2166 struct cifs_posix_ace ace_array[0];
2167 /* followed by
2168 struct cifs_posix_ace default_ace_arraay[] */
Steve French0753ca72005-10-27 13:55:12 -07002169} __attribute__((packed)); /* level 0x204 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170
2171/* types of access control entries already defined in posix_acl.h */
2172/* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2173#define CIFS_POSIX_ACL_USER 0x02
2174#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2175#define CIFS_POSIX_ACL_GROUP 0x08
2176#define CIFS_POSIX_ACL_MASK 0x10
2177#define CIFS_POSIX_ACL_OTHER 0x20 */
2178
2179/* types of perms */
2180/* #define CIFS_POSIX_ACL_EXECUTE 0x01
2181#define CIFS_POSIX_ACL_WRITE 0x02
2182#define CIFS_POSIX_ACL_READ 0x04 */
2183
2184/* end of POSIX ACL definitions */
2185
Steve French2dd29d32007-04-23 22:07:35 +00002186/* POSIX Open Flags */
2187#define SMB_O_RDONLY 0x1
2188#define SMB_O_WRONLY 0x2
2189#define SMB_O_RDWR 0x4
2190#define SMB_O_CREAT 0x10
2191#define SMB_O_EXCL 0x20
2192#define SMB_O_TRUNC 0x40
2193#define SMB_O_APPEND 0x80
2194#define SMB_O_SYNC 0x100
2195#define SMB_O_DIRECTORY 0x200
2196#define SMB_O_NOFOLLOW 0x400
2197#define SMB_O_DIRECT 0x800
2198
Steve French595dcfe2007-02-08 18:11:42 +00002199typedef struct {
Steve French2dd29d32007-04-23 22:07:35 +00002200 __le32 OpenFlags; /* same as NT CreateX */
2201 __le32 PosixOpenFlags;
2202 __le64 Permissions;
2203 __le16 Level; /* reply level requested (see QPathInfo levels) */
Steve French595dcfe2007-02-08 18:11:42 +00002204} __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
2205
2206typedef struct {
Steve French2dd29d32007-04-23 22:07:35 +00002207 __le16 OplockFlags;
2208 __u16 Fid;
2209 __le32 CreateAction;
2210 __le16 ReturnedLevel;
2211 __le16 Pad;
2212 /* struct following varies based on requested level */
Steve French8af18972007-02-14 04:42:51 +00002213} __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
Steve French595dcfe2007-02-08 18:11:42 +00002214
Steve French2d785a52007-07-15 01:48:57 +00002215#define SMB_POSIX_UNLINK_FILE_TARGET 0
2216#define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2217
2218struct unlink_psx_rq { /* level 0x20a SetPathInfo */
2219 __le16 type;
2220} __attribute__((packed));
Steve French595dcfe2007-02-08 18:11:42 +00002221
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222struct file_internal_info {
2223 __u64 UniqueId; /* inode number */
Steve French0753ca72005-10-27 13:55:12 -07002224} __attribute__((packed)); /* level 0x3ee */
Steve French2dd29d32007-04-23 22:07:35 +00002225
Linus Torvalds1da177e2005-04-16 15:20:36 -07002226struct file_mode_info {
2227 __le32 Mode;
Steve French0753ca72005-10-27 13:55:12 -07002228} __attribute__((packed)); /* level 0x3f8 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229
2230struct file_attrib_tag {
2231 __le32 Attribute;
2232 __le32 ReparseTag;
Steve French0753ca72005-10-27 13:55:12 -07002233} __attribute__((packed)); /* level 0x40b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234
2235
2236/********************************************************/
Steve French50c2f752007-07-13 00:33:32 +00002237/* FindFirst/FindNext transact2 data buffer formats */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238/********************************************************/
2239
2240typedef struct {
2241 __le32 NextEntryOffset;
2242 __u32 ResumeKey; /* as with FileIndex - no need to convert */
2243 __le64 EndOfFile;
2244 __le64 NumOfBytes;
2245 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2246 __le64 LastAccessTime;
2247 __le64 LastModificationTime;
2248 __le64 Uid;
2249 __le64 Gid;
2250 __le32 Type;
2251 __le64 DevMajor;
2252 __le64 DevMinor;
2253 __u64 UniqueId;
2254 __le64 Permissions;
2255 __le64 Nlinks;
2256 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07002257} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002258
2259typedef struct {
2260 __le32 NextEntryOffset;
2261 __u32 FileIndex;
2262 __le64 CreationTime;
2263 __le64 LastAccessTime;
2264 __le64 LastWriteTime;
2265 __le64 ChangeTime;
2266 __le64 EndOfFile;
2267 __le64 AllocationSize;
2268 __le32 ExtFileAttributes;
2269 __le32 FileNameLength;
2270 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002271} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272
2273typedef struct {
2274 __le32 NextEntryOffset;
2275 __u32 FileIndex;
2276 __le64 CreationTime;
2277 __le64 LastAccessTime;
2278 __le64 LastWriteTime;
2279 __le64 ChangeTime;
2280 __le64 EndOfFile;
2281 __le64 AllocationSize;
2282 __le32 ExtFileAttributes;
2283 __le32 FileNameLength;
2284 __le32 EaSize; /* length of the xattrs */
2285 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002286} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287
2288typedef struct {
2289 __le32 NextEntryOffset;
2290 __u32 FileIndex;
2291 __le64 CreationTime;
2292 __le64 LastAccessTime;
2293 __le64 LastWriteTime;
2294 __le64 ChangeTime;
2295 __le64 EndOfFile;
2296 __le64 AllocationSize;
2297 __le32 ExtFileAttributes;
2298 __le32 FileNameLength;
2299 __le32 EaSize; /* EA size */
2300 __le32 Reserved;
2301 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2302 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002303} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304
2305typedef struct {
2306 __le32 NextEntryOffset;
2307 __u32 FileIndex;
2308 __le64 CreationTime;
2309 __le64 LastAccessTime;
2310 __le64 LastWriteTime;
2311 __le64 ChangeTime;
2312 __le64 EndOfFile;
2313 __le64 AllocationSize;
2314 __le32 ExtFileAttributes;
Steve French50c2f752007-07-13 00:33:32 +00002315 __le32 FileNameLength;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 __le32 EaSize; /* length of the xattrs */
2317 __u8 ShortNameLength;
2318 __u8 Reserved;
2319 __u8 ShortName[12];
2320 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002321} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2322
2323typedef struct {
2324 __u32 ResumeKey;
2325 __le16 CreationDate; /* SMB Date */
2326 __le16 CreationTime; /* SMB Time */
2327 __le16 LastAccessDate;
2328 __le16 LastAccessTime;
2329 __le16 LastWriteDate;
2330 __le16 LastWriteTime;
2331 __le32 DataSize; /* File Size (EOF) */
2332 __le32 AllocationSize;
2333 __le16 Attributes; /* verify not u32 */
2334 __u8 FileNameLength;
2335 char FileName[1];
2336} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337
2338
Steve French86c96b42005-11-18 20:25:31 -08002339struct win_dev {
2340 unsigned char type[8]; /* IntxCHR or IntxBLK */
2341 __le64 major;
Steve French50c2f752007-07-13 00:33:32 +00002342 __le64 minor;
Steve French86c96b42005-11-18 20:25:31 -08002343} __attribute__((packed));
2344
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345struct gea {
2346 unsigned char name_len;
2347 char name[1];
Steve French0753ca72005-10-27 13:55:12 -07002348} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002349
2350struct gealist {
2351 unsigned long list_len;
2352 struct gea list[1];
Steve French0753ca72005-10-27 13:55:12 -07002353} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354
2355struct fea {
2356 unsigned char EA_flags;
2357 __u8 name_len;
2358 __le16 value_len;
2359 char name[1];
2360 /* optionally followed by value */
Steve French0753ca72005-10-27 13:55:12 -07002361} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362/* flags for _FEA.fEA */
2363#define FEA_NEEDEA 0x80 /* need EA bit */
2364
2365struct fealist {
2366 __le32 list_len;
2367 struct fea list[1];
Steve French0753ca72005-10-27 13:55:12 -07002368} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369
2370/* used to hold an arbitrary blob of data */
2371struct data_blob {
2372 __u8 *data;
2373 size_t length;
Steve French50c2f752007-07-13 00:33:32 +00002374 void (*free) (struct data_blob *data_blob);
Steve French0753ca72005-10-27 13:55:12 -07002375} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376
2377
2378#ifdef CONFIG_CIFS_POSIX
Steve French50c2f752007-07-13 00:33:32 +00002379/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380 For better POSIX semantics from Linux client, (even better
2381 than the existing CIFS Unix Extensions) we need updated PDUs for:
Steve French50c2f752007-07-13 00:33:32 +00002382
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 1) PosixCreateX - to set and return the mode, inode#, device info and
2384 perhaps add a CreateDevice - to create Pipes and other special .inodes
2385 Also note POSIX open flags
Steve French50c2f752007-07-13 00:33:32 +00002386 2) Close - to return the last write time to do cache across close
Steve French87f440e2007-02-07 00:29:46 +00002387 more safely
Steve French50c2f752007-07-13 00:33:32 +00002388 3) FindFirst return unique inode number - what about resume key, two
Steve French1982c342005-08-17 12:38:22 -07002389 forms short (matches readdir) and full (enough info to cache inodes)
2390 4) Mkdir - set mode
Steve French50c2f752007-07-13 00:33:32 +00002391
2392 And under consideration:
Steve French1982c342005-08-17 12:38:22 -07002393 5) FindClose2 (return nanosecond timestamp ??)
Steve French50c2f752007-07-13 00:33:32 +00002394 6) Use nanosecond timestamps throughout all time fields if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 corresponding attribute flag is set
Steve French1982c342005-08-17 12:38:22 -07002396 7) sendfile - handle based copy
2397 8) Direct i/o
2398 9) Misc fcntls?
Steve French50c2f752007-07-13 00:33:32 +00002399
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 what about fixing 64 bit alignment
Steve French50c2f752007-07-13 00:33:32 +00002401
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 There are also various legacy SMB/CIFS requests used as is
Steve French50c2f752007-07-13 00:33:32 +00002403
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 From existing Lanman and NTLM dialects:
2405 --------------------------------------
2406 NEGOTIATE
2407 SESSION_SETUP_ANDX (BB which?)
2408 TREE_CONNECT_ANDX (BB which wct?)
2409 TREE_DISCONNECT (BB add volume timestamp on response)
2410 LOGOFF_ANDX
2411 DELETE (note delete open file behavior)
2412 DELETE_DIRECTORY
2413 READ_AND_X
2414 WRITE_AND_X
2415 LOCKING_AND_X (note posix lock semantics)
2416 RENAME (note rename across dirs and open file rename posix behaviors)
2417 NT_RENAME (for hardlinks) Is this good enough for all features?
2418 FIND_CLOSE2
2419 TRANSACTION2 (18 cases)
2420 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2421 (BB verify that never need to set allocation size)
Steve French87f440e2007-02-07 00:29:46 +00002422 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2423 Unix ext?)
Steve French50c2f752007-07-13 00:33:32 +00002424
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2426 setting/getting OS/2 EAs - FUTURE (BB can this handle
2427 setting Linux xattrs perfectly) - OPTIONAL
2428 dnotify - FUTURE, OPTIONAL
2429 quota - FUTURE, OPTIONAL
Steve French50c2f752007-07-13 00:33:32 +00002430
2431 Note that various requests implemented for NT interop such as
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432 NT_TRANSACT (IOCTL) QueryReparseInfo
2433 are unneeded to servers compliant with the CIFS POSIX extensions
Steve French50c2f752007-07-13 00:33:32 +00002434
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 From CIFS Unix Extensions:
2436 -------------------------
2437 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2438 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2439 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
Steve French50c2f752007-07-13 00:33:32 +00002440 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2441 inode fields
2442 Actually a need QUERY_FILE_UNIX_INFO
2443 since has inode num
2444 BB what about a) blksize/blkbits/blocks
Steve French87f440e2007-02-07 00:29:46 +00002445 b) i_version
2446 c) i_rdev
2447 d) notify mask?
2448 e) generation
2449 f) size_seqcount
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
Steve French50c2f752007-07-13 00:33:32 +00002451 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 */
2454
Steve French1982c342005-08-17 12:38:22 -07002455/* xsymlink is a symlink format (used by MacOS) that can be used
Steve French50c2f752007-07-13 00:33:32 +00002456 to save symlink info in a regular file when
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 mounted to operating systems that do not
2458 support the cifs Unix extensions or EAs (for xattr
2459 based symlinks). For such a file to be recognized
Steve French50c2f752007-07-13 00:33:32 +00002460 as containing symlink data:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002461
Steve French50c2f752007-07-13 00:33:32 +00002462 1) file size must be 1067,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463 2) signature must begin file data,
2464 3) length field must be set to ASCII representation
Steve French50c2f752007-07-13 00:33:32 +00002465 of a number which is less than or equal to 1024,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002466 4) md5 must match that of the path data */
2467
2468struct xsymlink {
2469 /* 1067 bytes */
2470 char signature[4]; /* XSym */ /* not null terminated */
2471 char cr0; /* \n */
2472/* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2473 char length[4];
2474 char cr1; /* \n */
2475/* md5 of valid subset of path ie path[0] through path[length-1] */
Steve French50c2f752007-07-13 00:33:32 +00002476 __u8 md5[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477 char cr2; /* \n */
2478/* if room left, then end with \n then 0x20s by convention but not required */
Steve French50c2f752007-07-13 00:33:32 +00002479 char path[1024];
Steve French0753ca72005-10-27 13:55:12 -07002480} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481
Steve Frenchf654bac2005-04-28 22:41:04 -07002482typedef struct file_xattr_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 /* BB do we need another field for flags? BB */
2484 __u32 xattr_name_len;
2485 __u32 xattr_value_len;
2486 char xattr_name[0];
2487 /* followed by xattr_value[xattr_value_len], no pad */
Steve French50c2f752007-07-13 00:33:32 +00002488} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
2489 level 0x205 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490
2491
Steve Frenchf654bac2005-04-28 22:41:04 -07002492/* flags for chattr command */
2493#define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2494#define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2495/* Reserved for compress file 0x4 */
2496#define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2497#define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2498#define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2499#define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2500#define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2501/* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2502#define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2503/* 0x2000 reserved for IMAGIC_FL */
2504#define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2505/* 0x8000 reserved for EXT3_NOTAIL_FL */
2506#define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2507#define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2508
2509#define EXT_SET_MASK 0x000300FF
2510#define EXT_GET_MASK 0x0003DFFF
2511
2512typedef struct file_chattr_info {
2513 __le64 mask; /* list of all possible attribute bits */
2514 __le64 mode; /* list of actual attribute bits on this inode */
Steve French50c2f752007-07-13 00:33:32 +00002515} __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes
2516 (chattr, chflags) level 0x206 */
Steve Frenchf654bac2005-04-28 22:41:04 -07002517
Steve French50c2f752007-07-13 00:33:32 +00002518#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519
Linus Torvalds1da177e2005-04-16 15:20:36 -07002520#endif /* _CIFSPDU_H */