blob: d2f0cf23bbba429df22ea99ce91e84dfa59145a8 [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
218/*
219 * Invalid readdir handle
220 */
221#define CIFS_NO_HANDLE 0xFFFF
222
Al Viro82c05a12007-03-14 09:19:40 +0000223#define NO_CHANGE_64 cpu_to_le64(0xFFFFFFFFFFFFFFFFULL)
Steve Frenchc7af1852007-03-01 04:11:22 +0000224#define NO_CHANGE_32 0xFFFFFFFFUL
225
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226/* IPC$ in ASCII */
227#define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
228
229/* IPC$ in Unicode */
230#define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
231
232/* Unicode Null terminate 2 bytes of 0 */
233#define UNICODE_NULL "\x00\x00"
234#define ASCII_NULL 0x00
235
236/*
237 * Server type values (returned on EnumServer API
238 */
239#define CIFS_SV_TYPE_DC 0x00000008
240#define CIFS_SV_TYPE_BACKDC 0x00000010
241
242/*
243 * Alias type flags (From EnumAlias API call
244 */
245#define CIFS_ALIAS_TYPE_FILE 0x0001
246#define CIFS_SHARE_TYPE_FILE 0x0000
247
248/*
249 * File Attribute flags
250 */
251#define ATTR_READONLY 0x0001
252#define ATTR_HIDDEN 0x0002
253#define ATTR_SYSTEM 0x0004
254#define ATTR_VOLUME 0x0008
255#define ATTR_DIRECTORY 0x0010
256#define ATTR_ARCHIVE 0x0020
257#define ATTR_DEVICE 0x0040
258#define ATTR_NORMAL 0x0080
259#define ATTR_TEMPORARY 0x0100
260#define ATTR_SPARSE 0x0200
261#define ATTR_REPARSE 0x0400
262#define ATTR_COMPRESSED 0x0800
Steve French50c2f752007-07-13 00:33:32 +0000263#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
Steve French0753ca72005-10-27 13:55:12 -0700264 on offline storage */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265#define ATTR_NOT_CONTENT_INDEXED 0x2000
266#define ATTR_ENCRYPTED 0x4000
267#define ATTR_POSIX_SEMANTICS 0x01000000
268#define ATTR_BACKUP_SEMANTICS 0x02000000
269#define ATTR_DELETE_ON_CLOSE 0x04000000
270#define ATTR_SEQUENTIAL_SCAN 0x08000000
271#define ATTR_RANDOM_ACCESS 0x10000000
272#define ATTR_NO_BUFFERING 0x20000000
273#define ATTR_WRITE_THROUGH 0x80000000
274
275/* ShareAccess flags */
276#define FILE_NO_SHARE 0x00000000
277#define FILE_SHARE_READ 0x00000001
278#define FILE_SHARE_WRITE 0x00000002
279#define FILE_SHARE_DELETE 0x00000004
280#define FILE_SHARE_ALL 0x00000007
281
282/* CreateDisposition flags */
283#define FILE_SUPERSEDE 0x00000000
284#define FILE_OPEN 0x00000001
285#define FILE_CREATE 0x00000002
286#define FILE_OPEN_IF 0x00000003
287#define FILE_OVERWRITE 0x00000004
288#define FILE_OVERWRITE_IF 0x00000005
289
290/* CreateOptions */
291#define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
292#define CREATE_WRITE_THROUGH 0x00000002
Steve Frencheda3c0292005-07-21 15:20:28 -0700293#define CREATE_SEQUENTIAL 0x00000004
294#define CREATE_SYNC_ALERT 0x00000010
295#define CREATE_ASYNC_ALERT 0x00000020
296#define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
297#define CREATE_NO_EA_KNOWLEDGE 0x00000200
298#define CREATE_EIGHT_DOT_THREE 0x00000400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299#define CREATE_RANDOM_ACCESS 0x00000800
300#define CREATE_DELETE_ON_CLOSE 0x00001000
Steve Frencheda3c0292005-07-21 15:20:28 -0700301#define CREATE_OPEN_BY_ID 0x00002000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302#define OPEN_REPARSE_POINT 0x00200000
Steve French50c2f752007-07-13 00:33:32 +0000303#define CREATE_OPTIONS_MASK 0x007FFFFF
Steve Frencheda3c0292005-07-21 15:20:28 -0700304#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306/* ImpersonationLevel flags */
307#define SECURITY_ANONYMOUS 0
308#define SECURITY_IDENTIFICATION 1
309#define SECURITY_IMPERSONATION 2
310#define SECURITY_DELEGATION 3
311
312/* SecurityFlags */
313#define SECURITY_CONTEXT_TRACKING 0x01
314#define SECURITY_EFFECTIVE_ONLY 0x02
315
316/*
317 * Default PID value, used in all SMBs where the PID is not important
318 */
319#define CIFS_DFT_PID 0x1234
320
321/*
322 * We use the same routine for Copy and Move SMBs. This flag is used to
323 * distinguish
324 */
325#define CIFS_COPY_OP 1
326#define CIFS_RENAME_OP 2
327
328#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
329#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331struct smb_hdr {
Steve French0753ca72005-10-27 13:55:12 -0700332 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two
333 or three bytes - with one or two byte type preceding it that are
334 zero - we could mask the type byte off just in case BB */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 __u8 Protocol[4];
336 __u8 Command;
337 union {
338 struct {
339 __u8 ErrorClass;
340 __u8 Reserved;
341 __le16 Error;
Steve French0753ca72005-10-27 13:55:12 -0700342 } __attribute__((packed)) DosError;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 __le32 CifsError;
Steve French0753ca72005-10-27 13:55:12 -0700344 } __attribute__((packed)) Status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 __u8 Flags;
346 __le16 Flags2; /* note: le */
347 __le16 PidHigh;
348 union {
349 struct {
350 __le32 SequenceNumber; /* le */
351 __u32 Reserved; /* zero */
Steve French0753ca72005-10-27 13:55:12 -0700352 } __attribute__((packed)) Sequence;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 __u8 SecuritySignature[8]; /* le */
Steve French0753ca72005-10-27 13:55:12 -0700354 } __attribute__((packed)) Signature;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 __u8 pad[2];
356 __u16 Tid;
357 __le16 Pid;
358 __u16 Uid;
359 __u16 Mid;
360 __u8 WordCount;
Steve French0753ca72005-10-27 13:55:12 -0700361} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362/* given a pointer to an smb_hdr retrieve the value of byte count */
Steve French26f57362007-08-30 22:09:15 +0000363#define BCC(smb_var) ( *(__u16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
364#define BCC_LE(smb_var) ( *(__le16 *)((char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
Steve French26f57362007-08-30 22:09:15 +0000366#define pByteArea(smb_var) ((unsigned char *)smb_var + sizeof(struct smb_hdr) + (2 * smb_var->WordCount) + 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367
368/*
Steve French50c2f752007-07-13 00:33:32 +0000369 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
370 * No longer as important, now that TCP names are more commonly used to
371 * resolve hosts.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 */
373#define CNLEN 15
374
375/*
Steve French50c2f752007-07-13 00:33:32 +0000376 * Share Name Length (SNLEN)
377 * Note: This length was limited by the SMB used to get
378 * the Share info. NetShareEnum only returned 13
379 * chars, including the null termination.
380 * This was removed because it no longer is limiting.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383/*
384 * Comment Length
385 */
386#define MAXCOMMENTLEN 40
387
388/*
389 * The OS/2 maximum path name
390 */
391#define MAX_PATHCONF 256
392
393/*
394 * SMB frame definitions (following must be packed structs)
395 * See the SNIA CIFS Specification for details.
396 *
397 * The Naming convention is the lower case version of the
398 * smb command code name for the struct and this is typedef to the
Steve French50c2f752007-07-13 00:33:32 +0000399 * uppercase version of the same name with the prefix SMB_ removed
400 * for brevity. Although typedefs are not commonly used for
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 * structure definitions in the Linux kernel, their use in the
402 * CIFS standards document, which this code is based on, may
403 * make this one of the cases where typedefs for structures make
404 * sense to improve readability for readers of the standards doc.
405 * Typedefs can always be removed later if they are too distracting
406 * and they are only used for the CIFSs PDUs themselves, not
407 * internal cifs vfs structures
Steve French50c2f752007-07-13 00:33:32 +0000408 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 */
410
411typedef struct negotiate_req {
412 struct smb_hdr hdr; /* wct = 0 */
413 __le16 ByteCount;
414 unsigned char DialectsArray[1];
Steve French0753ca72005-10-27 13:55:12 -0700415} __attribute__((packed)) NEGOTIATE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
Steve French39798772006-05-31 22:40:51 +0000417/* Dialect index is 13 for LANMAN */
418
Steve Frenchb815f1e52006-10-02 05:53:29 +0000419#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
420
Steve French39798772006-05-31 22:40:51 +0000421typedef struct lanman_neg_rsp {
422 struct smb_hdr hdr; /* wct = 13 */
423 __le16 DialectIndex;
424 __le16 SecurityMode;
425 __le16 MaxBufSize;
426 __le16 MaxMpxCount;
427 __le16 MaxNumberVcs;
428 __le16 RawMode;
429 __le32 SessionKey;
Steve French175ec9e2006-09-30 01:07:38 +0000430 struct {
431 __le16 Time;
432 __le16 Date;
433 } __attribute__((packed)) SrvTime;
Steve French39798772006-05-31 22:40:51 +0000434 __le16 ServerTimeZone;
435 __le16 EncryptionKeyLength;
436 __le16 Reserved;
437 __u16 ByteCount;
438 unsigned char EncryptionKey[1];
439} __attribute__((packed)) LANMAN_NEG_RSP;
440
Steve French254e55e2006-06-04 05:53:15 +0000441#define READ_RAW_ENABLE 1
442#define WRITE_RAW_ENABLE 2
443#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445typedef struct negotiate_rsp {
446 struct smb_hdr hdr; /* wct = 17 */
447 __le16 DialectIndex;
448 __u8 SecurityMode;
449 __le16 MaxMpxCount;
450 __le16 MaxNumberVcs;
451 __le32 MaxBufferSize;
452 __le32 MaxRawSize;
453 __le32 SessionKey;
454 __le32 Capabilities; /* see below */
455 __le32 SystemTimeLow;
456 __le32 SystemTimeHigh;
457 __le16 ServerTimeZone;
458 __u8 EncryptionKeyLength;
459 __u16 ByteCount;
460 union {
Steve French0753ca72005-10-27 13:55:12 -0700461 unsigned char EncryptionKey[1]; /* cap extended security off */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 /* followed by Domain name - if extended security is off */
463 /* followed by 16 bytes of server GUID */
Steve French0753ca72005-10-27 13:55:12 -0700464 /* then security blob if cap_extended_security negotiated */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 struct {
466 unsigned char GUID[16];
467 unsigned char SecurityBlob[1];
Steve French0753ca72005-10-27 13:55:12 -0700468 } __attribute__((packed)) extended_response;
469 } __attribute__((packed)) u;
470} __attribute__((packed)) NEGOTIATE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
472/* SecurityMode bits */
473#define SECMODE_USER 0x01 /* off indicates share level security */
474#define SECMODE_PW_ENCRYPT 0x02
475#define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
476#define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
477
478/* Negotiate response Capabilities */
479#define CAP_RAW_MODE 0x00000001
480#define CAP_MPX_MODE 0x00000002
481#define CAP_UNICODE 0x00000004
482#define CAP_LARGE_FILES 0x00000008
483#define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
484#define CAP_RPC_REMOTE_APIS 0x00000020
485#define CAP_STATUS32 0x00000040
486#define CAP_LEVEL_II_OPLOCKS 0x00000080
487#define CAP_LOCK_AND_READ 0x00000100
488#define CAP_NT_FIND 0x00000200
489#define CAP_DFS 0x00001000
490#define CAP_INFOLEVEL_PASSTHRU 0x00002000
491#define CAP_LARGE_READ_X 0x00004000
492#define CAP_LARGE_WRITE_X 0x00008000
493#define CAP_UNIX 0x00800000
494#define CAP_RESERVED 0x02000000
495#define CAP_BULK_TRANSFER 0x20000000
496#define CAP_COMPRESSED_DATA 0x40000000
497#define CAP_EXTENDED_SECURITY 0x80000000
498
499typedef union smb_com_session_setup_andx {
500 struct { /* request format */
501 struct smb_hdr hdr; /* wct = 12 */
502 __u8 AndXCommand;
503 __u8 AndXReserved;
504 __le16 AndXOffset;
505 __le16 MaxBufferSize;
506 __le16 MaxMpxCount;
507 __le16 VcNumber;
508 __u32 SessionKey;
509 __le16 SecurityBlobLength;
510 __u32 Reserved;
511 __le32 Capabilities; /* see below */
512 __le16 ByteCount;
513 unsigned char SecurityBlob[1]; /* followed by */
514 /* STRING NativeOS */
515 /* STRING NativeLanMan */
Steve French50c2f752007-07-13 00:33:32 +0000516 } __attribute__((packed)) req; /* NTLM request format (with
Steve French0753ca72005-10-27 13:55:12 -0700517 extended security */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518
519 struct { /* request format */
520 struct smb_hdr hdr; /* wct = 13 */
521 __u8 AndXCommand;
522 __u8 AndXReserved;
523 __le16 AndXOffset;
524 __le16 MaxBufferSize;
525 __le16 MaxMpxCount;
526 __le16 VcNumber;
527 __u32 SessionKey;
Steve French0753ca72005-10-27 13:55:12 -0700528 __le16 CaseInsensitivePasswordLength; /* ASCII password len */
529 __le16 CaseSensitivePasswordLength; /* Unicode password length*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 __u32 Reserved; /* see below */
531 __le32 Capabilities;
532 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700533 unsigned char CaseInsensitivePassword[1]; /* followed by: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 /* unsigned char * CaseSensitivePassword; */
535 /* STRING AccountName */
536 /* STRING PrimaryDomain */
537 /* STRING NativeOS */
538 /* STRING NativeLanMan */
Steve French0753ca72005-10-27 13:55:12 -0700539 } __attribute__((packed)) req_no_secext; /* NTLM request format (without
540 extended security */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541
542 struct { /* default (NTLM) response format */
543 struct smb_hdr hdr; /* wct = 4 */
544 __u8 AndXCommand;
545 __u8 AndXReserved;
546 __le16 AndXOffset;
547 __le16 Action; /* see below */
548 __le16 SecurityBlobLength;
549 __u16 ByteCount;
550 unsigned char SecurityBlob[1]; /* followed by */
551/* unsigned char * NativeOS; */
552/* unsigned char * NativeLanMan; */
553/* unsigned char * PrimaryDomain; */
Steve French50c2f752007-07-13 00:33:32 +0000554 } __attribute__((packed)) resp; /* NTLM response
Steve French87f440e2007-02-07 00:29:46 +0000555 (with or without extended sec) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556
557 struct { /* request format */
558 struct smb_hdr hdr; /* wct = 10 */
559 __u8 AndXCommand;
560 __u8 AndXReserved;
561 __le16 AndXOffset;
562 __le16 MaxBufferSize;
563 __le16 MaxMpxCount;
564 __le16 VcNumber;
565 __u32 SessionKey;
Steve French39798772006-05-31 22:40:51 +0000566 __le16 PasswordLength;
567 __u32 Reserved; /* encrypt key len and offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 __le16 ByteCount;
569 unsigned char AccountPassword[1]; /* followed by */
570 /* STRING AccountName */
571 /* STRING PrimaryDomain */
572 /* STRING NativeOS */
573 /* STRING NativeLanMan */
Steve French0a4b92c2006-01-12 15:44:21 -0800574 } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575
576 struct { /* default (NTLM) response format */
577 struct smb_hdr hdr; /* wct = 3 */
578 __u8 AndXCommand;
579 __u8 AndXReserved;
580 __le16 AndXOffset;
581 __le16 Action; /* see below */
582 __u16 ByteCount;
583 unsigned char NativeOS[1]; /* followed by */
584/* unsigned char * NativeLanMan; */
585/* unsigned char * PrimaryDomain; */
Steve French0a4b92c2006-01-12 15:44:21 -0800586 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
Steve French0753ca72005-10-27 13:55:12 -0700587} __attribute__((packed)) SESSION_SETUP_ANDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588
Steve Frenchf64b23a2006-06-05 05:27:37 +0000589/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
590
Steve French33ec32f2006-12-08 04:14:28 +0000591#define NTLMSSP_SERVER_TYPE 1
592#define NTLMSSP_DOMAIN_TYPE 2
593#define NTLMSSP_FQ_DOMAIN_TYPE 3
594#define NTLMSSP_DNS_DOMAIN_TYPE 4
595#define NTLMSSP_DNS_PARENT_TYPE 5
596
Steve Frenchf64b23a2006-06-05 05:27:37 +0000597struct ntlmssp2_name {
598 __le16 type;
599 __le16 length;
600/* char name[length]; */
601} __attribute__((packed));
602
603struct ntlmv2_resp {
604 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
Steve French6d027cf2006-06-05 16:26:05 +0000605 __le32 blob_signature;
Steve Frenchf64b23a2006-06-05 05:27:37 +0000606 __u32 reserved;
607 __le64 time;
608 __u64 client_chal; /* random */
609 __u32 reserved2;
Steve French33ec32f2006-12-08 04:14:28 +0000610 struct ntlmssp2_name names[2];
Steve Frenchf64b23a2006-06-05 05:27:37 +0000611 /* array of name entries could follow ending in minimum 4 byte struct */
612} __attribute__((packed));
613
614
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
616
617/* Capabilities bits (for NTLM SessSetup request) */
618#define CAP_UNICODE 0x00000004
619#define CAP_LARGE_FILES 0x00000008
620#define CAP_NT_SMBS 0x00000010
621#define CAP_STATUS32 0x00000040
622#define CAP_LEVEL_II_OPLOCKS 0x00000080
Steve French50c2f752007-07-13 00:33:32 +0000623#define CAP_NT_FIND 0x00000200 /* reserved should be zero
Steve French0753ca72005-10-27 13:55:12 -0700624 (because NT_SMBs implies the same thing?) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625#define CAP_BULK_TRANSFER 0x20000000
626#define CAP_EXTENDED_SECURITY 0x80000000
627
628/* Action bits */
629#define GUEST_LOGIN 1
630
631typedef struct smb_com_tconx_req {
632 struct smb_hdr hdr; /* wct = 4 */
633 __u8 AndXCommand;
634 __u8 AndXReserved;
635 __le16 AndXOffset;
636 __le16 Flags; /* see below */
637 __le16 PasswordLength;
638 __le16 ByteCount;
639 unsigned char Password[1]; /* followed by */
640/* STRING Path *//* \\server\share name */
641 /* STRING Service */
Steve French0753ca72005-10-27 13:55:12 -0700642} __attribute__((packed)) TCONX_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643
644typedef struct smb_com_tconx_rsp {
Steve Frenchf64b23a2006-06-05 05:27:37 +0000645 struct smb_hdr hdr; /* wct = 3 note that Win2000 has sent wct = 7
646 in some cases on responses. Four unspecified
647 words followed OptionalSupport */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 __u8 AndXCommand;
649 __u8 AndXReserved;
650 __le16 AndXOffset;
651 __le16 OptionalSupport; /* see below */
652 __u16 ByteCount;
653 unsigned char Service[1]; /* always ASCII, not Unicode */
654 /* STRING NativeFileSystem */
Steve French0753ca72005-10-27 13:55:12 -0700655} __attribute__((packed)) TCONX_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
657/* tree connect Flags */
658#define DISCONNECT_TID 0x0001
659#define TCON_EXTENDED_SECINFO 0x0008
660/* OptionalSupport bits */
Steve French0753ca72005-10-27 13:55:12 -0700661#define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
662 (exclusive searches supported) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663#define SMB_SHARE_IS_IN_DFS 0x0002
664
665typedef struct smb_com_logoff_andx_req {
666 struct smb_hdr hdr; /* wct = 2 */
667 __u8 AndXCommand;
668 __u8 AndXReserved;
669 __u16 AndXOffset;
670 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700671} __attribute__((packed)) LOGOFF_ANDX_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672
673typedef struct smb_com_logoff_andx_rsp {
674 struct smb_hdr hdr; /* wct = 2 */
675 __u8 AndXCommand;
676 __u8 AndXReserved;
677 __u16 AndXOffset;
678 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700679} __attribute__((packed)) LOGOFF_ANDX_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680
Steve French50c2f752007-07-13 00:33:32 +0000681typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
Steve French86c96b42005-11-18 20:25:31 -0800682 tree_connect PDU to effect disconnect */
683 /* tdis is probably simplest SMB PDU */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 struct {
685 struct smb_hdr hdr; /* wct = 0 */
686 __u16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700687 } __attribute__((packed)) req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 struct {
689 struct smb_hdr hdr; /* wct = 0 */
690 __u16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700691 } __attribute__((packed)) resp;
692} __attribute__((packed)) TREE_DISCONNECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693
694typedef struct smb_com_close_req {
695 struct smb_hdr hdr; /* wct = 3 */
696 __u16 FileID;
Steve Frenchb815f1e52006-10-02 05:53:29 +0000697 __u32 LastWriteTime; /* should be zero or -1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 __u16 ByteCount; /* 0 */
Steve French0753ca72005-10-27 13:55:12 -0700699} __attribute__((packed)) CLOSE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700
701typedef struct smb_com_close_rsp {
702 struct smb_hdr hdr; /* wct = 0 */
703 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700704} __attribute__((packed)) CLOSE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705
706typedef struct smb_com_findclose_req {
707 struct smb_hdr hdr; /* wct = 1 */
708 __u16 FileID;
709 __u16 ByteCount; /* 0 */
Steve French0753ca72005-10-27 13:55:12 -0700710} __attribute__((packed)) FINDCLOSE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711
712/* OpenFlags */
Steve Frencha9d02ad2005-08-24 23:06:05 -0700713#define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714#define REQ_OPLOCK 0x00000002
715#define REQ_BATCHOPLOCK 0x00000004
716#define REQ_OPENDIRONLY 0x00000008
Steve French75865f8c2007-06-24 18:30:48 +0000717#define REQ_EXTENDED_INFO 0x00000010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718
Steve French92ad9b92007-09-29 05:21:58 +0000719/* File type */
720#define DISK_TYPE 0x0000
721#define BYTE_PIPE_TYPE 0x0001
722#define MESSAGE_PIPE_TYPE 0x0002
723#define PRINTER_TYPE 0x0003
724#define COMM_DEV_TYPE 0x0004
725#define UNKNOWN_TYPE 0xFFFF
726
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727typedef struct smb_com_open_req { /* also handles create */
728 struct smb_hdr hdr; /* wct = 24 */
729 __u8 AndXCommand;
730 __u8 AndXReserved;
731 __le16 AndXOffset;
732 __u8 Reserved; /* Must Be Zero */
733 __le16 NameLength;
734 __le32 OpenFlags;
735 __le32 RootDirectoryFid;
736 __le32 DesiredAccess;
737 __le64 AllocationSize;
738 __le32 FileAttributes;
739 __le32 ShareAccess;
740 __le32 CreateDisposition;
741 __le32 CreateOptions;
742 __le32 ImpersonationLevel;
743 __u8 SecurityFlags;
744 __le16 ByteCount;
745 char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -0700746} __attribute__((packed)) OPEN_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747
748/* open response: oplock levels */
749#define OPLOCK_NONE 0
750#define OPLOCK_EXCLUSIVE 1
751#define OPLOCK_BATCH 2
752#define OPLOCK_READ 3 /* level 2 oplock */
753
754/* open response for CreateAction shifted left */
755#define CIFS_CREATE_ACTION 0x20000 /* file created */
756
757typedef struct smb_com_open_rsp {
758 struct smb_hdr hdr; /* wct = 34 BB */
759 __u8 AndXCommand;
760 __u8 AndXReserved;
761 __le16 AndXOffset;
762 __u8 OplockLevel;
763 __u16 Fid;
764 __le32 CreateAction;
765 __le64 CreationTime;
766 __le64 LastAccessTime;
767 __le64 LastWriteTime;
768 __le64 ChangeTime;
769 __le32 FileAttributes;
770 __le64 AllocationSize;
771 __le64 EndOfFile;
772 __le16 FileType;
773 __le16 DeviceState;
774 __u8 DirectoryFlag;
775 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700776} __attribute__((packed)) OPEN_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777
Steve Frencha9d02ad2005-08-24 23:06:05 -0700778/* format of legacy open request */
779typedef struct smb_com_openx_req {
780 struct smb_hdr hdr; /* wct = 15 */
781 __u8 AndXCommand;
782 __u8 AndXReserved;
783 __le16 AndXOffset;
784 __le16 OpenFlags;
785 __le16 Mode;
786 __le16 Sattr; /* search attributes */
787 __le16 FileAttributes; /* dos attrs */
788 __le32 CreateTime; /* os2 format */
789 __le16 OpenFunction;
790 __le32 EndOfFile;
791 __le32 Timeout;
792 __le32 Reserved;
Steve French70ca7342005-09-22 16:32:06 -0700793 __le16 ByteCount; /* file name follows */
Steve Frencha9d02ad2005-08-24 23:06:05 -0700794 char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -0700795} __attribute__((packed)) OPENX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700796
797typedef struct smb_com_openx_rsp {
798 struct smb_hdr hdr; /* wct = 15 */
799 __u8 AndXCommand;
800 __u8 AndXReserved;
801 __le16 AndXOffset;
802 __u16 Fid;
803 __le16 FileAttributes;
804 __le32 LastWriteTime; /* os2 format */
805 __le32 EndOfFile;
806 __le16 Access;
807 __le16 FileType;
808 __le16 IPCState;
809 __le16 Action;
810 __u32 FileId;
811 __u16 Reserved;
812 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000813} __attribute__((packed)) OPENX_RSP;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700814
Steve French595dcfe2007-02-08 18:11:42 +0000815/* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
816
Steve Frencha9d02ad2005-08-24 23:06:05 -0700817/* Legacy write request for older servers */
818typedef struct smb_com_writex_req {
Steve French50c2f752007-07-13 00:33:32 +0000819 struct smb_hdr hdr; /* wct = 12 */
820 __u8 AndXCommand;
821 __u8 AndXReserved;
822 __le16 AndXOffset;
823 __u16 Fid;
824 __le32 OffsetLow;
825 __u32 Reserved; /* Timeout */
826 __le16 WriteMode; /* 1 = write through */
827 __le16 Remaining;
828 __le16 Reserved2;
829 __le16 DataLengthLow;
830 __le16 DataOffset;
831 __le16 ByteCount;
832 __u8 Pad; /* BB check for whether padded to DWORD
833 boundary and optimum performance here */
834 char Data[0];
Steve French0753ca72005-10-27 13:55:12 -0700835} __attribute__((packed)) WRITEX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700836
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837typedef struct smb_com_write_req {
838 struct smb_hdr hdr; /* wct = 14 */
839 __u8 AndXCommand;
840 __u8 AndXReserved;
841 __le16 AndXOffset;
842 __u16 Fid;
843 __le32 OffsetLow;
844 __u32 Reserved;
845 __le16 WriteMode;
846 __le16 Remaining;
847 __le16 DataLengthHigh;
848 __le16 DataLengthLow;
849 __le16 DataOffset;
850 __le32 OffsetHigh;
851 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000852 __u8 Pad; /* BB check for whether padded to DWORD
853 boundary and optimum performance here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 char Data[0];
Steve French0753ca72005-10-27 13:55:12 -0700855} __attribute__((packed)) WRITE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856
857typedef struct smb_com_write_rsp {
858 struct smb_hdr hdr; /* wct = 6 */
859 __u8 AndXCommand;
860 __u8 AndXReserved;
861 __le16 AndXOffset;
862 __le16 Count;
863 __le16 Remaining;
864 __le16 CountHigh;
865 __u16 Reserved;
866 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700867} __attribute__((packed)) WRITE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868
Steve Frencha9d02ad2005-08-24 23:06:05 -0700869/* legacy read request for older servers */
870typedef struct smb_com_readx_req {
Steve French50c2f752007-07-13 00:33:32 +0000871 struct smb_hdr hdr; /* wct = 10 */
872 __u8 AndXCommand;
873 __u8 AndXReserved;
874 __le16 AndXOffset;
875 __u16 Fid;
876 __le32 OffsetLow;
877 __le16 MaxCount;
878 __le16 MinCount; /* obsolete */
879 __le32 Reserved;
880 __le16 Remaining;
881 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700882} __attribute__((packed)) READX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700883
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884typedef struct smb_com_read_req {
885 struct smb_hdr hdr; /* wct = 12 */
886 __u8 AndXCommand;
887 __u8 AndXReserved;
888 __le16 AndXOffset;
889 __u16 Fid;
890 __le32 OffsetLow;
891 __le16 MaxCount;
892 __le16 MinCount; /* obsolete */
893 __le32 MaxCountHigh;
894 __le16 Remaining;
895 __le32 OffsetHigh;
896 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700897} __attribute__((packed)) READ_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898
899typedef struct smb_com_read_rsp {
900 struct smb_hdr hdr; /* wct = 12 */
901 __u8 AndXCommand;
902 __u8 AndXReserved;
903 __le16 AndXOffset;
904 __le16 Remaining;
905 __le16 DataCompactionMode;
906 __le16 Reserved;
907 __le16 DataLength;
908 __le16 DataOffset;
909 __le16 DataLengthHigh;
910 __u64 Reserved2;
911 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000912 __u8 Pad; /* BB check for whether padded to DWORD
913 boundary and optimum performance here */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 char Data[1];
Steve French0753ca72005-10-27 13:55:12 -0700915} __attribute__((packed)) READ_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916
917typedef struct locking_andx_range {
918 __le16 Pid;
919 __le16 Pad;
920 __le32 OffsetHigh;
921 __le32 OffsetLow;
922 __le32 LengthHigh;
923 __le32 LengthLow;
Steve French0753ca72005-10-27 13:55:12 -0700924} __attribute__((packed)) LOCKING_ANDX_RANGE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925
926#define LOCKING_ANDX_SHARED_LOCK 0x01
927#define LOCKING_ANDX_OPLOCK_RELEASE 0x02
928#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
929#define LOCKING_ANDX_CANCEL_LOCK 0x08
930#define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
931
932typedef struct smb_com_lock_req {
933 struct smb_hdr hdr; /* wct = 8 */
934 __u8 AndXCommand;
935 __u8 AndXReserved;
936 __le16 AndXOffset;
937 __u16 Fid;
938 __u8 LockType;
939 __u8 OplockLevel;
940 __le32 Timeout;
941 __le16 NumberOfUnlocks;
942 __le16 NumberOfLocks;
943 __le16 ByteCount;
944 LOCKING_ANDX_RANGE Locks[1];
Steve French0753ca72005-10-27 13:55:12 -0700945} __attribute__((packed)) LOCK_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946
Steve French08547b02006-02-28 22:39:25 +0000947/* lock type */
948#define CIFS_RDLCK 0
949#define CIFS_WRLCK 1
950#define CIFS_UNLCK 2
Steve Frenchf654bac2005-04-28 22:41:04 -0700951typedef struct cifs_posix_lock {
952 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
953 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
954 __le32 pid;
955 __le64 start;
956 __le64 length;
957 /* BB what about additional owner info to identify network client */
Steve French0753ca72005-10-27 13:55:12 -0700958} __attribute__((packed)) CIFS_POSIX_LOCK;
Steve Frenchf654bac2005-04-28 22:41:04 -0700959
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960typedef struct smb_com_lock_rsp {
961 struct smb_hdr hdr; /* wct = 2 */
962 __u8 AndXCommand;
963 __u8 AndXReserved;
964 __le16 AndXOffset;
965 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700966} __attribute__((packed)) LOCK_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700967
968typedef struct smb_com_rename_req {
969 struct smb_hdr hdr; /* wct = 1 */
970 __le16 SearchAttributes; /* target file attributes */
971 __le16 ByteCount;
972 __u8 BufferFormat; /* 4 = ASCII or Unicode */
973 unsigned char OldFileName[1];
974 /* followed by __u8 BufferFormat2 */
975 /* followed by NewFileName */
Steve French0753ca72005-10-27 13:55:12 -0700976} __attribute__((packed)) RENAME_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977
978 /* copy request flags */
979#define COPY_MUST_BE_FILE 0x0001
980#define COPY_MUST_BE_DIR 0x0002
981#define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
982#define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
983#define COPY_VERIFY_WRITES 0x0010
Steve French50c2f752007-07-13 00:33:32 +0000984#define COPY_TREE 0x0020
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985
986typedef struct smb_com_copy_req {
987 struct smb_hdr hdr; /* wct = 3 */
988 __u16 Tid2;
989 __le16 OpenFunction;
990 __le16 Flags;
991 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000992 __u8 BufferFormat; /* 4 = ASCII or Unicode */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 unsigned char OldFileName[1];
994 /* followed by __u8 BufferFormat2 */
995 /* followed by NewFileName string */
Steve French0753ca72005-10-27 13:55:12 -0700996} __attribute__((packed)) COPY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997
998typedef struct smb_com_copy_rsp {
999 struct smb_hdr hdr; /* wct = 1 */
1000 __le16 CopyCount; /* number of files copied */
1001 __u16 ByteCount; /* may be zero */
1002 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
1003 unsigned char ErrorFileName[1]; /* only present if error in copy */
Steve French0753ca72005-10-27 13:55:12 -07001004} __attribute__((packed)) COPY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005
1006#define CREATE_HARD_LINK 0x103
1007#define MOVEFILE_COPY_ALLOWED 0x0002
1008#define MOVEFILE_REPLACE_EXISTING 0x0001
1009
1010typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
1011 struct smb_hdr hdr; /* wct = 4 */
1012 __le16 SearchAttributes; /* target file attributes */
1013 __le16 Flags; /* spec says Information Level */
1014 __le32 ClusterCount;
1015 __le16 ByteCount;
1016 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1017 unsigned char OldFileName[1];
1018 /* followed by __u8 BufferFormat2 */
1019 /* followed by NewFileName */
Steve French0753ca72005-10-27 13:55:12 -07001020} __attribute__((packed)) NT_RENAME_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021
1022typedef struct smb_com_rename_rsp {
1023 struct smb_hdr hdr; /* wct = 0 */
1024 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001025} __attribute__((packed)) RENAME_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026
1027typedef struct smb_com_delete_file_req {
1028 struct smb_hdr hdr; /* wct = 1 */
1029 __le16 SearchAttributes;
1030 __le16 ByteCount;
1031 __u8 BufferFormat; /* 4 = ASCII */
1032 unsigned char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001033} __attribute__((packed)) DELETE_FILE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034
1035typedef struct smb_com_delete_file_rsp {
1036 struct smb_hdr hdr; /* wct = 0 */
1037 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001038} __attribute__((packed)) DELETE_FILE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039
1040typedef struct smb_com_delete_directory_req {
1041 struct smb_hdr hdr; /* wct = 0 */
1042 __le16 ByteCount;
1043 __u8 BufferFormat; /* 4 = ASCII */
1044 unsigned char DirName[1];
Steve French0753ca72005-10-27 13:55:12 -07001045} __attribute__((packed)) DELETE_DIRECTORY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046
1047typedef struct smb_com_delete_directory_rsp {
1048 struct smb_hdr hdr; /* wct = 0 */
1049 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001050} __attribute__((packed)) DELETE_DIRECTORY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051
1052typedef struct smb_com_create_directory_req {
1053 struct smb_hdr hdr; /* wct = 0 */
1054 __le16 ByteCount;
1055 __u8 BufferFormat; /* 4 = ASCII */
1056 unsigned char DirName[1];
Steve French0753ca72005-10-27 13:55:12 -07001057} __attribute__((packed)) CREATE_DIRECTORY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058
1059typedef struct smb_com_create_directory_rsp {
1060 struct smb_hdr hdr; /* wct = 0 */
1061 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001062} __attribute__((packed)) CREATE_DIRECTORY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063
Steve French6b8edfe2005-08-23 20:26:03 -07001064typedef struct smb_com_query_information_req {
1065 struct smb_hdr hdr; /* wct = 0 */
1066 __le16 ByteCount; /* 1 + namelen + 1 */
1067 __u8 BufferFormat; /* 4 = ASCII */
1068 unsigned char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001069} __attribute__((packed)) QUERY_INFORMATION_REQ;
Steve French6b8edfe2005-08-23 20:26:03 -07001070
1071typedef struct smb_com_query_information_rsp {
1072 struct smb_hdr hdr; /* wct = 10 */
1073 __le16 attr;
1074 __le32 last_write_time;
1075 __le32 size;
1076 __u16 reserved[5];
1077 __le16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001078} __attribute__((packed)) QUERY_INFORMATION_RSP;
Steve French6b8edfe2005-08-23 20:26:03 -07001079
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080typedef struct smb_com_setattr_req {
1081 struct smb_hdr hdr; /* wct = 8 */
1082 __le16 attr;
1083 __le16 time_low;
1084 __le16 time_high;
1085 __le16 reserved[5]; /* must be zero */
1086 __u16 ByteCount;
1087 __u8 BufferFormat; /* 4 = ASCII */
1088 unsigned char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001089} __attribute__((packed)) SETATTR_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090
1091typedef struct smb_com_setattr_rsp {
1092 struct smb_hdr hdr; /* wct = 0 */
1093 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001094} __attribute__((packed)) SETATTR_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095
1096/* empty wct response to setattr */
1097
Steve French0a4b92c2006-01-12 15:44:21 -08001098/*******************************************************/
1099/* NT Transact structure defintions follow */
Steve French50c2f752007-07-13 00:33:32 +00001100/* Currently only ioctl, acl (get security descriptor) */
Steve French0a4b92c2006-01-12 15:44:21 -08001101/* and notify are implemented */
1102/*******************************************************/
1103typedef struct smb_com_ntransact_req {
Steve French50c2f752007-07-13 00:33:32 +00001104 struct smb_hdr hdr; /* wct >= 19 */
1105 __u8 MaxSetupCount;
1106 __u16 Reserved;
1107 __le32 TotalParameterCount;
1108 __le32 TotalDataCount;
1109 __le32 MaxParameterCount;
1110 __le32 MaxDataCount;
1111 __le32 ParameterCount;
1112 __le32 ParameterOffset;
1113 __le32 DataCount;
1114 __le32 DataOffset;
1115 __u8 SetupCount; /* four setup words follow subcommand */
1116 /* SNIA spec incorrectly included spurious pad here */
1117 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1118 /* SetupCount words follow then */
1119 __le16 ByteCount;
1120 __u8 Pad[3];
1121 __u8 Parms[0];
Steve French0a4b92c2006-01-12 15:44:21 -08001122} __attribute__((packed)) NTRANSACT_REQ;
1123
1124typedef struct smb_com_ntransact_rsp {
1125 struct smb_hdr hdr; /* wct = 18 */
1126 __u8 Reserved[3];
1127 __le32 TotalParameterCount;
1128 __le32 TotalDataCount;
1129 __le32 ParameterCount;
1130 __le32 ParameterOffset;
1131 __le32 ParameterDisplacement;
1132 __le32 DataCount;
1133 __le32 DataOffset;
1134 __le32 DataDisplacement;
1135 __u8 SetupCount; /* 0 */
1136 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001137 /* __u8 Pad[3]; */
Steve French0a4b92c2006-01-12 15:44:21 -08001138 /* parms and data follow */
1139} __attribute__((packed)) NTRANSACT_RSP;
1140
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141typedef struct smb_com_transaction_ioctl_req {
1142 struct smb_hdr hdr; /* wct = 23 */
1143 __u8 MaxSetupCount;
1144 __u16 Reserved;
1145 __le32 TotalParameterCount;
1146 __le32 TotalDataCount;
1147 __le32 MaxParameterCount;
1148 __le32 MaxDataCount;
1149 __le32 ParameterCount;
1150 __le32 ParameterOffset;
1151 __le32 DataCount;
1152 __le32 DataOffset;
1153 __u8 SetupCount; /* four setup words follow subcommand */
1154 /* SNIA spec incorrectly included spurious pad here */
Steve French0a4b92c2006-01-12 15:44:21 -08001155 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 __le32 FunctionCode;
1157 __u16 Fid;
Steve French0a4b92c2006-01-12 15:44:21 -08001158 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */
1159 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 __le16 ByteCount;
1161 __u8 Pad[3];
1162 __u8 Data[1];
Steve French0753ca72005-10-27 13:55:12 -07001163} __attribute__((packed)) TRANSACT_IOCTL_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164
1165typedef struct smb_com_transaction_ioctl_rsp {
1166 struct smb_hdr hdr; /* wct = 19 */
1167 __u8 Reserved[3];
1168 __le32 TotalParameterCount;
1169 __le32 TotalDataCount;
1170 __le32 ParameterCount;
1171 __le32 ParameterOffset;
1172 __le32 ParameterDisplacement;
1173 __le32 DataCount;
1174 __le32 DataOffset;
1175 __le32 DataDisplacement;
1176 __u8 SetupCount; /* 1 */
1177 __le16 ReturnedDataLen;
1178 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001179} __attribute__((packed)) TRANSACT_IOCTL_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180
Steve French0a4b92c2006-01-12 15:44:21 -08001181#define CIFS_ACL_OWNER 1
1182#define CIFS_ACL_GROUP 2
1183#define CIFS_ACL_DACL 4
1184#define CIFS_ACL_SACL 8
1185
1186typedef struct smb_com_transaction_qsec_req {
1187 struct smb_hdr hdr; /* wct = 19 */
1188 __u8 MaxSetupCount;
1189 __u16 Reserved;
1190 __le32 TotalParameterCount;
1191 __le32 TotalDataCount;
1192 __le32 MaxParameterCount;
1193 __le32 MaxDataCount;
1194 __le32 ParameterCount;
1195 __le32 ParameterOffset;
1196 __le32 DataCount;
1197 __le32 DataOffset;
1198 __u8 SetupCount; /* no setup words follow subcommand */
1199 /* SNIA spec incorrectly included spurious pad here */
1200 __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
1201 __le16 ByteCount; /* bcc = 3 + 8 */
1202 __u8 Pad[3];
1203 __u16 Fid;
1204 __u16 Reserved2;
1205 __le32 AclFlags;
1206} __attribute__((packed)) QUERY_SEC_DESC_REQ;
1207
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208typedef struct smb_com_transaction_change_notify_req {
1209 struct smb_hdr hdr; /* wct = 23 */
1210 __u8 MaxSetupCount;
1211 __u16 Reserved;
1212 __le32 TotalParameterCount;
1213 __le32 TotalDataCount;
1214 __le32 MaxParameterCount;
1215 __le32 MaxDataCount;
1216 __le32 ParameterCount;
1217 __le32 ParameterOffset;
1218 __le32 DataCount;
1219 __le32 DataOffset;
1220 __u8 SetupCount; /* four setup words follow subcommand */
1221 /* SNIA spec incorrectly included spurious pad here */
1222 __le16 SubCommand;/* 4 = Change Notify */
1223 __le32 CompletionFilter; /* operation to monitor */
1224 __u16 Fid;
1225 __u8 WatchTree; /* 1 = Monitor subdirectories */
1226 __u8 Reserved2;
1227 __le16 ByteCount;
Steve French0a4b92c2006-01-12 15:44:21 -08001228/* __u8 Pad[3];*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229/* __u8 Data[1];*/
Steve French0753ca72005-10-27 13:55:12 -07001230} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231
Steve French50c2f752007-07-13 00:33:32 +00001232/* BB eventually change to use generic ntransact rsp struct
Steve French0a4b92c2006-01-12 15:44:21 -08001233 and validation routine */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234typedef struct smb_com_transaction_change_notify_rsp {
1235 struct smb_hdr hdr; /* wct = 18 */
1236 __u8 Reserved[3];
1237 __le32 TotalParameterCount;
1238 __le32 TotalDataCount;
1239 __le32 ParameterCount;
1240 __le32 ParameterOffset;
1241 __le32 ParameterDisplacement;
1242 __le32 DataCount;
1243 __le32 DataOffset;
1244 __le32 DataDisplacement;
1245 __u8 SetupCount; /* 0 */
1246 __u16 ByteCount;
1247 /* __u8 Pad[3]; */
Steve French0753ca72005-10-27 13:55:12 -07001248} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249/* Completion Filter flags for Notify */
1250#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1251#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1252#define FILE_NOTIFY_CHANGE_NAME 0x00000003
1253#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1254#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1255#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1256#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1257#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1258#define FILE_NOTIFY_CHANGE_EA 0x00000080
1259#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1260#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1261#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1262#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1263
1264#define FILE_ACTION_ADDED 0x00000001
1265#define FILE_ACTION_REMOVED 0x00000002
1266#define FILE_ACTION_MODIFIED 0x00000003
1267#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1268#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1269#define FILE_ACTION_ADDED_STREAM 0x00000006
1270#define FILE_ACTION_REMOVED_STREAM 0x00000007
1271#define FILE_ACTION_MODIFIED_STREAM 0x00000008
1272
1273/* response contains array of the following structures */
1274struct file_notify_information {
1275 __le32 NextEntryOffset;
1276 __le32 Action;
1277 __le32 FileNameLength;
1278 __u8 FileName[0];
Steve French50c2f752007-07-13 00:33:32 +00001279} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280
1281struct reparse_data {
1282 __u32 ReparseTag;
1283 __u16 ReparseDataLength;
1284 __u16 Reserved;
1285 __u16 AltNameOffset;
1286 __u16 AltNameLen;
1287 __u16 TargetNameOffset;
1288 __u16 TargetNameLen;
1289 char LinkNamesBuf[1];
Steve French0753ca72005-10-27 13:55:12 -07001290} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001291
1292struct cifs_quota_data {
1293 __u32 rsrvd1; /* 0 */
1294 __u32 sid_size;
1295 __u64 rsrvd2; /* 0 */
1296 __u64 space_used;
1297 __u64 soft_limit;
1298 __u64 hard_limit;
1299 char sid[1]; /* variable size? */
Steve French0753ca72005-10-27 13:55:12 -07001300} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301
1302/* quota sub commands */
1303#define QUOTA_LIST_CONTINUE 0
1304#define QUOTA_LIST_START 0x100
1305#define QUOTA_FOR_SID 0x101
1306
1307struct trans2_req {
1308 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1309 __le16 TotalParameterCount;
1310 __le16 TotalDataCount;
1311 __le16 MaxParameterCount;
1312 __le16 MaxDataCount;
1313 __u8 MaxSetupCount;
1314 __u8 Reserved;
1315 __le16 Flags;
1316 __le32 Timeout;
1317 __u16 Reserved2;
1318 __le16 ParameterCount;
1319 __le16 ParameterOffset;
1320 __le16 DataCount;
1321 __le16 DataOffset;
1322 __u8 SetupCount;
1323 __u8 Reserved3;
1324 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1325 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001326} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327
1328struct smb_t2_req {
1329 struct smb_hdr hdr;
1330 struct trans2_req t2_req;
Steve French0753ca72005-10-27 13:55:12 -07001331} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332
1333struct trans2_resp {
1334 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1335 __le16 TotalParameterCount;
1336 __le16 TotalDataCount;
1337 __u16 Reserved;
1338 __le16 ParameterCount;
1339 __le16 ParameterOffset;
1340 __le16 ParameterDisplacement;
1341 __le16 DataCount;
1342 __le16 DataOffset;
1343 __le16 DataDisplacement;
1344 __u8 SetupCount;
1345 __u8 Reserved1;
1346 /* SetupWords[SetupCount];
1347 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001348 __u16 Reserved2;*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 /* data area follows */
Steve French0753ca72005-10-27 13:55:12 -07001350} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351
1352struct smb_t2_rsp {
1353 struct smb_hdr hdr;
1354 struct trans2_resp t2_rsp;
Steve French0753ca72005-10-27 13:55:12 -07001355} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356
1357/* PathInfo/FileInfo infolevels */
1358#define SMB_INFO_STANDARD 1
1359#define SMB_SET_FILE_EA 2
1360#define SMB_QUERY_FILE_EA_SIZE 2
1361#define SMB_INFO_QUERY_EAS_FROM_LIST 3
1362#define SMB_INFO_QUERY_ALL_EAS 4
1363#define SMB_INFO_IS_NAME_VALID 6
1364#define SMB_QUERY_FILE_BASIC_INFO 0x101
1365#define SMB_QUERY_FILE_STANDARD_INFO 0x102
1366#define SMB_QUERY_FILE_EA_INFO 0x103
1367#define SMB_QUERY_FILE_NAME_INFO 0x104
1368#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1369#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1370#define SMB_QUERY_FILE_ALL_INFO 0x107
1371#define SMB_QUERY_ALT_NAME_INFO 0x108
1372#define SMB_QUERY_FILE_STREAM_INFO 0x109
1373#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1374#define SMB_QUERY_FILE_UNIX_BASIC 0x200
1375#define SMB_QUERY_FILE_UNIX_LINK 0x201
1376#define SMB_QUERY_POSIX_ACL 0x204
Steve French87f440e2007-02-07 00:29:46 +00001377#define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
Steve Frenchf654bac2005-04-28 22:41:04 -07001379#define SMB_QUERY_POSIX_PERMISSION 0x207
1380#define SMB_QUERY_POSIX_LOCK 0x208
Steve French87f440e2007-02-07 00:29:46 +00001381/* #define SMB_POSIX_OPEN 0x209 */
1382/* #define SMB_POSIX_UNLINK 0x20a */
1383#define SMB_QUERY_FILE__UNIX_INFO2 0x20b
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1385#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1386#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
Steve French50c2f752007-07-13 00:33:32 +00001387#define SMB_QUERY_FILE_POSITION_INFO 0x3f6
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388#define SMB_QUERY_FILE_MODE_INFO 0x3f8
Steve French50c2f752007-07-13 00:33:32 +00001389#define SMB_QUERY_FILE_ALGN_INFO 0x3f9
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390
1391
1392#define SMB_SET_FILE_BASIC_INFO 0x101
1393#define SMB_SET_FILE_DISPOSITION_INFO 0x102
1394#define SMB_SET_FILE_ALLOCATION_INFO 0x103
1395#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1396#define SMB_SET_FILE_UNIX_BASIC 0x200
1397#define SMB_SET_FILE_UNIX_LINK 0x201
1398#define SMB_SET_FILE_UNIX_HLINK 0x203
1399#define SMB_SET_POSIX_ACL 0x204
1400#define SMB_SET_XATTR 0x205
1401#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
Steve Frenchf654bac2005-04-28 22:41:04 -07001402#define SMB_SET_POSIX_LOCK 0x208
Steve French2fe87f02006-09-21 07:02:52 +00001403#define SMB_POSIX_OPEN 0x209
Steve French87f440e2007-02-07 00:29:46 +00001404#define SMB_POSIX_UNLINK 0x20a
Steve French2dd29d32007-04-23 22:07:35 +00001405#define SMB_SET_FILE_UNIX_INFO2 0x20b
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406#define SMB_SET_FILE_BASIC_INFO2 0x3ec
Steve French87f440e2007-02-07 00:29:46 +00001407#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408#define SMB_FILE_ALL_INFO2 0x3fa
1409#define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1410#define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1411#define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1412#define SMB_FILE_QUOTA_INFO 0x408
1413#define SMB_FILE_REPARSEPOINT_INFO 0x409
1414#define SMB_FILE_MAXIMUM_INFO 0x40d
1415
1416/* Find File infolevels */
Steve French5bafd762006-06-07 00:18:43 +00001417#define SMB_FIND_FILE_INFO_STANDARD 0x001
1418#define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1419#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1421#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1422#define SMB_FIND_FILE_NAMES_INFO 0x103
1423#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1424#define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1425#define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1426#define SMB_FIND_FILE_UNIX 0x202
1427
1428typedef struct smb_com_transaction2_qpi_req {
1429 struct smb_hdr hdr; /* wct = 14+ */
1430 __le16 TotalParameterCount;
1431 __le16 TotalDataCount;
1432 __le16 MaxParameterCount;
1433 __le16 MaxDataCount;
1434 __u8 MaxSetupCount;
1435 __u8 Reserved;
1436 __le16 Flags;
1437 __le32 Timeout;
1438 __u16 Reserved2;
1439 __le16 ParameterCount;
1440 __le16 ParameterOffset;
1441 __le16 DataCount;
1442 __le16 DataOffset;
1443 __u8 SetupCount;
1444 __u8 Reserved3;
1445 __le16 SubCommand; /* one setup word */
1446 __le16 ByteCount;
1447 __u8 Pad;
1448 __le16 InformationLevel;
1449 __u32 Reserved4;
1450 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001451} __attribute__((packed)) TRANSACTION2_QPI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452
1453typedef struct smb_com_transaction2_qpi_rsp {
1454 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1455 struct trans2_resp t2;
1456 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001457 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001458} __attribute__((packed)) TRANSACTION2_QPI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459
1460typedef struct smb_com_transaction2_spi_req {
1461 struct smb_hdr hdr; /* wct = 15 */
1462 __le16 TotalParameterCount;
1463 __le16 TotalDataCount;
1464 __le16 MaxParameterCount;
1465 __le16 MaxDataCount;
1466 __u8 MaxSetupCount;
1467 __u8 Reserved;
1468 __le16 Flags;
1469 __le32 Timeout;
1470 __u16 Reserved2;
1471 __le16 ParameterCount;
1472 __le16 ParameterOffset;
1473 __le16 DataCount;
1474 __le16 DataOffset;
1475 __u8 SetupCount;
1476 __u8 Reserved3;
1477 __le16 SubCommand; /* one setup word */
1478 __le16 ByteCount;
1479 __u8 Pad;
1480 __u16 Pad1;
1481 __le16 InformationLevel;
1482 __u32 Reserved4;
1483 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001484} __attribute__((packed)) TRANSACTION2_SPI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485
1486typedef struct smb_com_transaction2_spi_rsp {
1487 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1488 struct trans2_resp t2;
1489 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001490 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001491} __attribute__((packed)) TRANSACTION2_SPI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492
1493struct set_file_rename {
1494 __le32 overwrite; /* 1 = overwrite dest */
1495 __u32 root_fid; /* zero */
1496 __le32 target_name_len;
1497 char target_name[0]; /* Must be unicode */
Steve French0753ca72005-10-27 13:55:12 -07001498} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001499
1500struct smb_com_transaction2_sfi_req {
1501 struct smb_hdr hdr; /* wct = 15 */
1502 __le16 TotalParameterCount;
1503 __le16 TotalDataCount;
1504 __le16 MaxParameterCount;
1505 __le16 MaxDataCount;
1506 __u8 MaxSetupCount;
1507 __u8 Reserved;
1508 __le16 Flags;
1509 __le32 Timeout;
1510 __u16 Reserved2;
1511 __le16 ParameterCount;
1512 __le16 ParameterOffset;
1513 __le16 DataCount;
1514 __le16 DataOffset;
1515 __u8 SetupCount;
1516 __u8 Reserved3;
1517 __le16 SubCommand; /* one setup word */
1518 __le16 ByteCount;
1519 __u8 Pad;
1520 __u16 Pad1;
1521 __u16 Fid;
1522 __le16 InformationLevel;
Steve French50c2f752007-07-13 00:33:32 +00001523 __u16 Reserved4;
Steve French0753ca72005-10-27 13:55:12 -07001524} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525
1526struct smb_com_transaction2_sfi_rsp {
1527 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1528 struct trans2_resp t2;
1529 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001530 __u16 Reserved2; /* parameter word reserved -
Steve Frenchf654bac2005-04-28 22:41:04 -07001531 present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001532} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001533
Steve Frenchf654bac2005-04-28 22:41:04 -07001534struct smb_t2_qfi_req {
Steve French50c2f752007-07-13 00:33:32 +00001535 struct smb_hdr hdr;
1536 struct trans2_req t2;
Steve Frenchf654bac2005-04-28 22:41:04 -07001537 __u8 Pad;
Steve Frenchf654bac2005-04-28 22:41:04 -07001538 __u16 Fid;
1539 __le16 InformationLevel;
Steve French0753ca72005-10-27 13:55:12 -07001540} __attribute__((packed));
Steve Frenchf654bac2005-04-28 22:41:04 -07001541
1542struct smb_t2_qfi_rsp {
Steve French50c2f752007-07-13 00:33:32 +00001543 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1544 struct trans2_resp t2;
1545 __u16 ByteCount;
1546 __u16 Reserved2; /* parameter word reserved -
1547 present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001548} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549
1550/*
Steve French50c2f752007-07-13 00:33:32 +00001551 * Flags on T2 FINDFIRST and FINDNEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 */
1553#define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1554#define CIFS_SEARCH_CLOSE_AT_END 0x0002
1555#define CIFS_SEARCH_RETURN_RESUME 0x0004
1556#define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1557#define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1558
1559/*
1560 * Size of the resume key on FINDFIRST and FINDNEXT calls
1561 */
1562#define CIFS_SMB_RESUME_KEY_SIZE 4
1563
1564typedef struct smb_com_transaction2_ffirst_req {
1565 struct smb_hdr hdr; /* wct = 15 */
1566 __le16 TotalParameterCount;
1567 __le16 TotalDataCount;
1568 __le16 MaxParameterCount;
1569 __le16 MaxDataCount;
1570 __u8 MaxSetupCount;
1571 __u8 Reserved;
1572 __le16 Flags;
1573 __le32 Timeout;
1574 __u16 Reserved2;
1575 __le16 ParameterCount;
1576 __le16 ParameterOffset;
1577 __le16 DataCount;
1578 __le16 DataOffset;
1579 __u8 SetupCount; /* one */
1580 __u8 Reserved3;
1581 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1582 __le16 ByteCount;
1583 __u8 Pad;
1584 __le16 SearchAttributes;
1585 __le16 SearchCount;
1586 __le16 SearchFlags;
1587 __le16 InformationLevel;
1588 __le32 SearchStorageType;
1589 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001590} __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591
1592typedef struct smb_com_transaction2_ffirst_rsp {
1593 struct smb_hdr hdr; /* wct = 10 */
1594 struct trans2_resp t2;
1595 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001596} __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597
1598typedef struct smb_com_transaction2_ffirst_rsp_parms {
1599 __u16 SearchHandle;
1600 __le16 SearchCount;
1601 __le16 EndofSearch;
1602 __le16 EAErrorOffset;
1603 __le16 LastNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001604} __attribute__((packed)) T2_FFIRST_RSP_PARMS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605
1606typedef struct smb_com_transaction2_fnext_req {
1607 struct smb_hdr hdr; /* wct = 15 */
1608 __le16 TotalParameterCount;
1609 __le16 TotalDataCount;
1610 __le16 MaxParameterCount;
1611 __le16 MaxDataCount;
1612 __u8 MaxSetupCount;
1613 __u8 Reserved;
1614 __le16 Flags;
1615 __le32 Timeout;
1616 __u16 Reserved2;
1617 __le16 ParameterCount;
1618 __le16 ParameterOffset;
1619 __le16 DataCount;
1620 __le16 DataOffset;
1621 __u8 SetupCount; /* one */
1622 __u8 Reserved3;
1623 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1624 __le16 ByteCount;
1625 __u8 Pad;
1626 __u16 SearchHandle;
1627 __le16 SearchCount;
1628 __le16 InformationLevel;
1629 __u32 ResumeKey;
1630 __le16 SearchFlags;
1631 char ResumeFileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001632} __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001633
1634typedef struct smb_com_transaction2_fnext_rsp {
1635 struct smb_hdr hdr; /* wct = 10 */
1636 struct trans2_resp t2;
1637 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001638} __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639
1640typedef struct smb_com_transaction2_fnext_rsp_parms {
1641 __le16 SearchCount;
1642 __le16 EndofSearch;
1643 __le16 EAErrorOffset;
1644 __le16 LastNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001645} __attribute__((packed)) T2_FNEXT_RSP_PARMS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646
1647/* QFSInfo Levels */
1648#define SMB_INFO_ALLOCATION 1
1649#define SMB_INFO_VOLUME 2
1650#define SMB_QUERY_FS_VOLUME_INFO 0x102
1651#define SMB_QUERY_FS_SIZE_INFO 0x103
1652#define SMB_QUERY_FS_DEVICE_INFO 0x104
1653#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1654#define SMB_QUERY_CIFS_UNIX_INFO 0x200
1655#define SMB_QUERY_POSIX_FS_INFO 0x201
Steve French87f440e2007-02-07 00:29:46 +00001656#define SMB_QUERY_POSIX_WHO_AM_I 0x202
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657#define SMB_QUERY_LABEL_INFO 0x3ea
1658#define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1659#define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1660#define SMB_QUERY_OBJECTID_INFO 0x3f0
1661
1662typedef struct smb_com_transaction2_qfsi_req {
1663 struct smb_hdr hdr; /* wct = 14+ */
1664 __le16 TotalParameterCount;
1665 __le16 TotalDataCount;
1666 __le16 MaxParameterCount;
1667 __le16 MaxDataCount;
1668 __u8 MaxSetupCount;
1669 __u8 Reserved;
1670 __le16 Flags;
1671 __le32 Timeout;
1672 __u16 Reserved2;
1673 __le16 ParameterCount;
1674 __le16 ParameterOffset;
1675 __le16 DataCount;
1676 __le16 DataOffset;
1677 __u8 SetupCount;
1678 __u8 Reserved3;
1679 __le16 SubCommand; /* one setup word */
1680 __le16 ByteCount;
1681 __u8 Pad;
1682 __le16 InformationLevel;
Steve French0753ca72005-10-27 13:55:12 -07001683} __attribute__((packed)) TRANSACTION2_QFSI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684
1685typedef struct smb_com_transaction_qfsi_rsp {
1686 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1687 struct trans2_resp t2;
1688 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001689 __u8 Pad; /* may be three bytes? *//* followed by data area */
Steve French0753ca72005-10-27 13:55:12 -07001690} __attribute__((packed)) TRANSACTION2_QFSI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691
Steve French87f440e2007-02-07 00:29:46 +00001692typedef struct whoami_rsp_data { /* Query level 0x202 */
1693 __u32 flags; /* 0 = Authenticated user 1 = GUEST */
1694 __u32 mask; /* which flags bits server understands ie 0x0001 */
1695 __u64 unix_user_id;
1696 __u64 unix_user_gid;
1697 __u32 number_of_supplementary_gids; /* may be zero */
1698 __u32 number_of_sids; /* may be zero */
1699 __u32 length_of_sid_array; /* in bytes - may be zero */
1700 __u32 pad; /* reserved - MBZ */
1701 /* __u64 gid_array[0]; */ /* may be empty */
1702 /* __u8 * psid_list */ /* may be empty */
1703} __attribute__((packed)) WHOAMI_RSP_DATA;
Jeremy Allisonac670552005-06-22 17:26:35 -07001704
1705/* SETFSInfo Levels */
1706#define SMB_SET_CIFS_UNIX_INFO 0x200
1707typedef struct smb_com_transaction2_setfsi_req {
1708 struct smb_hdr hdr; /* wct = 15 */
1709 __le16 TotalParameterCount;
1710 __le16 TotalDataCount;
1711 __le16 MaxParameterCount;
1712 __le16 MaxDataCount;
1713 __u8 MaxSetupCount;
1714 __u8 Reserved;
1715 __le16 Flags;
1716 __le32 Timeout;
1717 __u16 Reserved2;
1718 __le16 ParameterCount; /* 4 */
1719 __le16 ParameterOffset;
1720 __le16 DataCount; /* 12 */
1721 __le16 DataOffset;
1722 __u8 SetupCount; /* one */
1723 __u8 Reserved3;
1724 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1725 __le16 ByteCount;
1726 __u8 Pad;
1727 __u16 FileNum; /* Parameters start. */
1728 __le16 InformationLevel;/* Parameters end. */
1729 __le16 ClientUnixMajor; /* Data start. */
1730 __le16 ClientUnixMinor;
1731 __le64 ClientUnixCap; /* Data end */
Steve French0753ca72005-10-27 13:55:12 -07001732} __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
Jeremy Allisonac670552005-06-22 17:26:35 -07001733
1734typedef struct smb_com_transaction2_setfsi_rsp {
1735 struct smb_hdr hdr; /* wct = 10 */
1736 struct trans2_resp t2;
1737 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001738} __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
Jeremy Allisonac670552005-06-22 17:26:35 -07001739
1740
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741typedef struct smb_com_transaction2_get_dfs_refer_req {
1742 struct smb_hdr hdr; /* wct = 15 */
1743 __le16 TotalParameterCount;
1744 __le16 TotalDataCount;
1745 __le16 MaxParameterCount;
1746 __le16 MaxDataCount;
1747 __u8 MaxSetupCount;
1748 __u8 Reserved;
1749 __le16 Flags;
1750 __le32 Timeout;
1751 __u16 Reserved2;
1752 __le16 ParameterCount;
1753 __le16 ParameterOffset;
1754 __le16 DataCount;
1755 __le16 DataOffset;
1756 __u8 SetupCount;
1757 __u8 Reserved3;
1758 __le16 SubCommand; /* one setup word */
1759 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001760 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max response length
1761 perhaps?) followed by one byte pad - doesn't
1762 seem to matter though */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763 __le16 MaxReferralLevel;
1764 char RequestFileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001765} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766
1767typedef struct dfs_referral_level_3 {
1768 __le16 VersionNumber;
1769 __le16 ReferralSize;
1770 __le16 ServerType; /* 0x0001 = CIFS server */
Steve French50c2f752007-07-13 00:33:32 +00001771 __le16 ReferralFlags; /* or proximity - not clear which since it is
1772 always set to zero - SNIA spec says 0x01
1773 means strip off PathConsumed chars before
1774 submitting RequestFileName to remote node */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775 __le16 TimeToLive;
1776 __le16 Proximity;
1777 __le16 DfsPathOffset;
1778 __le16 DfsAlternatePathOffset;
1779 __le16 NetworkAddressOffset;
Steve French0753ca72005-10-27 13:55:12 -07001780} __attribute__((packed)) REFERRAL3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781
1782typedef struct smb_com_transaction_get_dfs_refer_rsp {
1783 struct smb_hdr hdr; /* wct = 10 */
1784 struct trans2_resp t2;
1785 __u16 ByteCount;
1786 __u8 Pad;
1787 __le16 PathConsumed;
1788 __le16 NumberOfReferrals;
1789 __le16 DFSFlags;
1790 __u16 Pad2;
1791 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1792 /* followed by the strings pointed to by the referral structures */
Steve French0753ca72005-10-27 13:55:12 -07001793} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794
1795/* DFS Flags */
1796#define DFSREF_REFERRAL_SERVER 0x0001
1797#define DFSREF_STORAGE_SERVER 0x0002
1798
1799/* IOCTL information */
Steve French50c2f752007-07-13 00:33:32 +00001800/*
1801 * List of ioctl function codes that look to be of interest to remote clients
1802 * like this one. Need to do some experimentation to make sure they all work
1803 * remotely. Some of the following, such as the encryption/compression ones
1804 * would be invoked from tools via a specialized hook into the VFS rather
1805 * than via the standard vfs entry points
1806 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807#define FSCTL_REQUEST_OPLOCK_LEVEL_1 0x00090000
1808#define FSCTL_REQUEST_OPLOCK_LEVEL_2 0x00090004
1809#define FSCTL_REQUEST_BATCH_OPLOCK 0x00090008
1810#define FSCTL_LOCK_VOLUME 0x00090018
1811#define FSCTL_UNLOCK_VOLUME 0x0009001C
1812#define FSCTL_GET_COMPRESSION 0x0009003C
1813#define FSCTL_SET_COMPRESSION 0x0009C040
1814#define FSCTL_REQUEST_FILTER_OPLOCK 0x0009008C
1815#define FSCTL_FILESYS_GET_STATISTICS 0x00090090
1816#define FSCTL_SET_REPARSE_POINT 0x000900A4
1817#define FSCTL_GET_REPARSE_POINT 0x000900A8
1818#define FSCTL_DELETE_REPARSE_POINT 0x000900AC
1819#define FSCTL_SET_SPARSE 0x000900C4
1820#define FSCTL_SET_ZERO_DATA 0x000900C8
1821#define FSCTL_SET_ENCRYPTION 0x000900D7
1822#define FSCTL_ENCRYPTION_FSCTL_IO 0x000900DB
1823#define FSCTL_WRITE_RAW_ENCRYPTED 0x000900DF
1824#define FSCTL_READ_RAW_ENCRYPTED 0x000900E3
1825#define FSCTL_SIS_COPYFILE 0x00090100
1826#define FSCTL_SIS_LINK_FILES 0x0009C104
1827
1828#define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003
1829#define IO_REPARSE_TAG_HSM 0xC0000004
1830#define IO_REPARSE_TAG_SIS 0x80000007
1831
1832/*
1833 ************************************************************************
1834 * All structs for everything above the SMB PDUs themselves
Steve French50c2f752007-07-13 00:33:32 +00001835 * (such as the T2 level specific data) go here
Linus Torvalds1da177e2005-04-16 15:20:36 -07001836 ************************************************************************
1837 */
1838
1839/*
1840 * Information on a server
1841 */
1842
1843struct serverInfo {
1844 char name[16];
1845 unsigned char versionMajor;
1846 unsigned char versionMinor;
1847 unsigned long type;
1848 unsigned int commentOffset;
Steve French0753ca72005-10-27 13:55:12 -07001849} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850
1851/*
1852 * The following structure is the format of the data returned on a NetShareEnum
1853 * with level "90" (x5A)
1854 */
1855
1856struct shareInfo {
1857 char shareName[13];
1858 char pad;
1859 unsigned short type;
1860 unsigned int commentOffset;
Steve French0753ca72005-10-27 13:55:12 -07001861} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862
1863struct aliasInfo {
1864 char aliasName[9];
1865 char pad;
1866 unsigned int commentOffset;
1867 unsigned char type[2];
Steve French0753ca72005-10-27 13:55:12 -07001868} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869
1870struct aliasInfo92 {
1871 int aliasNameOffset;
1872 int serverNameOffset;
1873 int shareNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001874} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875
1876typedef struct {
1877 __le64 TotalAllocationUnits;
1878 __le64 FreeAllocationUnits;
1879 __le32 SectorsPerAllocationUnit;
1880 __le32 BytesPerSector;
Steve French50c2f752007-07-13 00:33:32 +00001881} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882
1883typedef struct {
Steve French20962432005-09-21 22:05:57 -07001884 __le32 fsid;
1885 __le32 SectorsPerAllocationUnit;
1886 __le32 TotalAllocationUnits;
1887 __le32 FreeAllocationUnits;
1888 __le16 BytesPerSector;
Steve French0753ca72005-10-27 13:55:12 -07001889} __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
Steve French20962432005-09-21 22:05:57 -07001890
1891typedef struct {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001892 __le16 MajorVersionNumber;
1893 __le16 MinorVersionNumber;
1894 __le64 Capability;
Steve French50c2f752007-07-13 00:33:32 +00001895} __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/
Jeremy Allisonac670552005-06-22 17:26:35 -07001896
1897/* Version numbers for CIFS UNIX major and minor. */
1898#define CIFS_UNIX_MAJOR_VERSION 1
1899#define CIFS_UNIX_MINOR_VERSION 0
1900
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901/* Linux/Unix extensions capability flags */
1902#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
Steve Frenchf654bac2005-04-28 22:41:04 -07001903#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
1904#define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
1905#define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
Steve French82940a42006-03-02 03:24:57 +00001906#define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
Steve French87f440e2007-02-07 00:29:46 +00001907#define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
1908 calls including posix open
Steve French75865f8c2007-06-24 18:30:48 +00001909 and posix unlink */
1910#define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
Steve French50c2f752007-07-13 00:33:32 +00001911 to 0xFFFF00 */
Steve French75865f8c2007-06-24 18:30:48 +00001912#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
1913
Steve French82940a42006-03-02 03:24:57 +00001914#ifdef CONFIG_CIFS_POSIX
Steve French38e2aff2007-03-16 05:12:53 +00001915/* Can not set pathnames cap yet until we send new posix create SMB since
1916 otherwise server can treat such handles opened with older ntcreatex
1917 (by a new client which knows how to send posix path ops)
1918 as non-posix handles (can affect write behavior with byte range locks.
1919 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
Steve French75865f8c2007-06-24 18:30:48 +00001920/* #define CIFS_UNIX_CAP_MASK 0x000000fb */
Steve French50c2f752007-07-13 00:33:32 +00001921#define CIFS_UNIX_CAP_MASK 0x000000db
1922#else
Steve French82940a42006-03-02 03:24:57 +00001923#define CIFS_UNIX_CAP_MASK 0x00000013
1924#endif /* CONFIG_CIFS_POSIX */
1925
Jeremy Allisonac670552005-06-22 17:26:35 -07001926
Steve Frenchf28ac912005-04-28 22:41:07 -07001927#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
Jeremy Allisonac670552005-06-22 17:26:35 -07001928
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929typedef struct {
1930 /* For undefined recommended transfer size return -1 in that field */
1931 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
Steve French50c2f752007-07-13 00:33:32 +00001932 __le32 BlockSize;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001933 /* The next three fields are in terms of the block size.
1934 (above). If block size is unknown, 4096 would be a
Steve French50c2f752007-07-13 00:33:32 +00001935 reasonable block size for a server to report.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001936 Note that returning the blocks/blocksavail removes need
1937 to make a second call (to QFSInfo level 0x103 to get this info.
1938 UserBlockAvail is typically less than or equal to BlocksAvail,
1939 if no distinction is made return the same value in each */
1940 __le64 TotalBlocks;
1941 __le64 BlocksAvail; /* bfree */
1942 __le64 UserBlocksAvail; /* bavail */
1943 /* For undefined Node fields or FSID return -1 */
1944 __le64 TotalFileNodes;
1945 __le64 FreeFileNodes;
1946 __le64 FileSysIdentifier; /* fsid */
1947 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
1948 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
Steve French0753ca72005-10-27 13:55:12 -07001949} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950
1951/* DeviceType Flags */
1952#define FILE_DEVICE_CD_ROM 0x00000002
1953#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
1954#define FILE_DEVICE_DFS 0x00000006
1955#define FILE_DEVICE_DISK 0x00000007
1956#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
1957#define FILE_DEVICE_FILE_SYSTEM 0x00000009
1958#define FILE_DEVICE_NAMED_PIPE 0x00000011
1959#define FILE_DEVICE_NETWORK 0x00000012
1960#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
1961#define FILE_DEVICE_NULL 0x00000015
1962#define FILE_DEVICE_PARALLEL_PORT 0x00000016
1963#define FILE_DEVICE_PRINTER 0x00000018
1964#define FILE_DEVICE_SERIAL_PORT 0x0000001b
1965#define FILE_DEVICE_STREAMS 0x0000001e
1966#define FILE_DEVICE_TAPE 0x0000001f
1967#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
1968#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
1969#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
1970
1971typedef struct {
1972 __le32 DeviceType;
1973 __le32 DeviceCharacteristics;
Steve French39798772006-05-31 22:40:51 +00001974} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975
1976typedef struct {
1977 __le32 Attributes;
1978 __le32 MaxPathNameComponentLength;
1979 __le32 FileSystemNameLen;
Steve French39798772006-05-31 22:40:51 +00001980 char FileSystemName[52]; /* do not have to save this - get subset? */
Steve French0753ca72005-10-27 13:55:12 -07001981} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982
1983/******************************************************************************/
1984/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
1985/******************************************************************************/
1986typedef struct { /* data block encoding of response to level 263 QPathInfo */
1987 __le64 CreationTime;
1988 __le64 LastAccessTime;
1989 __le64 LastWriteTime;
1990 __le64 ChangeTime;
1991 __le32 Attributes;
1992 __u32 Pad1;
1993 __le64 AllocationSize;
1994 __le64 EndOfFile; /* size ie offset to first free byte in file */
1995 __le32 NumberOfLinks; /* hard links */
1996 __u8 DeletePending;
1997 __u8 Directory;
1998 __u16 Pad2;
1999 __u64 IndexNumber;
2000 __le32 EASize;
2001 __le32 AccessFlags;
2002 __u64 IndexNumber1;
2003 __le64 CurrentByteOffset;
2004 __le32 Mode;
2005 __le32 AlignmentRequirement;
2006 __le32 FileNameLength;
2007 char FileName[1];
Steve French87f440e2007-02-07 00:29:46 +00002008} __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009
2010/* defines for enumerating possible values of the Unix type field below */
2011#define UNIX_FILE 0
2012#define UNIX_DIR 1
2013#define UNIX_SYMLINK 2
2014#define UNIX_CHARDEV 3
2015#define UNIX_BLOCKDEV 4
2016#define UNIX_FIFO 5
2017#define UNIX_SOCKET 6
2018typedef struct {
2019 __le64 EndOfFile;
2020 __le64 NumOfBytes;
2021 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2022 __le64 LastAccessTime;
2023 __le64 LastModificationTime;
2024 __le64 Uid;
2025 __le64 Gid;
2026 __le32 Type;
2027 __le64 DevMajor;
2028 __le64 DevMinor;
2029 __u64 UniqueId;
2030 __le64 Permissions;
2031 __le64 Nlinks;
Steve French87f440e2007-02-07 00:29:46 +00002032} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033
2034typedef struct {
2035 char LinkDest[1];
Steve French87f440e2007-02-07 00:29:46 +00002036} __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002037
2038/* The following three structures are needed only for
2039 setting time to NT4 and some older servers via
2040 the primitive DOS time format */
2041typedef struct {
2042 __u16 Day:5;
2043 __u16 Month:4;
2044 __u16 Year:7;
Steve French0753ca72005-10-27 13:55:12 -07002045} __attribute__((packed)) SMB_DATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046
2047typedef struct {
2048 __u16 TwoSeconds:5;
2049 __u16 Minutes:6;
2050 __u16 Hours:5;
Steve French0753ca72005-10-27 13:55:12 -07002051} __attribute__((packed)) SMB_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052
2053typedef struct {
2054 __le16 CreationDate; /* SMB Date see above */
2055 __le16 CreationTime; /* SMB Time */
2056 __le16 LastAccessDate;
2057 __le16 LastAccessTime;
2058 __le16 LastWriteDate;
2059 __le16 LastWriteTime;
2060 __le32 DataSize; /* File Size (EOF) */
2061 __le32 AllocationSize;
2062 __le16 Attributes; /* verify not u32 */
2063 __le32 EASize;
Steve French0753ca72005-10-27 13:55:12 -07002064} __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065
2066typedef struct {
2067 __le64 CreationTime;
2068 __le64 LastAccessTime;
2069 __le64 LastWriteTime;
2070 __le64 ChangeTime;
2071 __le32 Attributes;
2072 __u32 Pad;
Steve French87f440e2007-02-07 00:29:46 +00002073} __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074
2075struct file_allocation_info {
2076 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
Steve French5bafd762006-06-07 00:18:43 +00002077} __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2078 0x105 for query */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079
2080struct file_end_of_file_info {
2081 __le64 FileSize; /* offset to end of file */
Steve French87f440e2007-02-07 00:29:46 +00002082} __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002083
2084struct file_alt_name_info {
2085 __u8 alt_name[1];
Steve French0753ca72005-10-27 13:55:12 -07002086} __attribute__((packed)); /* level 0x0108 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087
2088struct file_stream_info {
2089 __le32 number_of_streams; /* BB check sizes and verify location */
Steve French50c2f752007-07-13 00:33:32 +00002090 /* followed by info on streams themselves
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091 u64 size;
Steve French50c2f752007-07-13 00:33:32 +00002092 u64 allocation_size
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 stream info */
2094}; /* level 0x109 */
2095
2096struct file_compression_info {
2097 __le64 compressed_size;
2098 __le16 format;
2099 __u8 unit_shift;
2100 __u8 ch_shift;
2101 __u8 cl_shift;
2102 __u8 pad[3];
Steve French0753ca72005-10-27 13:55:12 -07002103} __attribute__((packed)); /* level 0x10b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002104
2105/* POSIX ACL set/query path info structures */
2106#define CIFS_ACL_VERSION 1
2107struct cifs_posix_ace { /* access control entry (ACE) */
2108 __u8 cifs_e_tag;
2109 __u8 cifs_e_perm;
2110 __le64 cifs_uid; /* or gid */
Steve French50c2f752007-07-13 00:33:32 +00002111} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112
2113struct cifs_posix_acl { /* access conrol list (ACL) */
2114 __le16 version;
2115 __le16 access_entry_count; /* access ACL - count of entries */
2116 __le16 default_entry_count; /* default ACL - count of entries */
2117 struct cifs_posix_ace ace_array[0];
2118 /* followed by
2119 struct cifs_posix_ace default_ace_arraay[] */
Steve French0753ca72005-10-27 13:55:12 -07002120} __attribute__((packed)); /* level 0x204 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121
2122/* types of access control entries already defined in posix_acl.h */
2123/* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2124#define CIFS_POSIX_ACL_USER 0x02
2125#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2126#define CIFS_POSIX_ACL_GROUP 0x08
2127#define CIFS_POSIX_ACL_MASK 0x10
2128#define CIFS_POSIX_ACL_OTHER 0x20 */
2129
2130/* types of perms */
2131/* #define CIFS_POSIX_ACL_EXECUTE 0x01
2132#define CIFS_POSIX_ACL_WRITE 0x02
2133#define CIFS_POSIX_ACL_READ 0x04 */
2134
2135/* end of POSIX ACL definitions */
2136
Steve French2dd29d32007-04-23 22:07:35 +00002137/* POSIX Open Flags */
2138#define SMB_O_RDONLY 0x1
2139#define SMB_O_WRONLY 0x2
2140#define SMB_O_RDWR 0x4
2141#define SMB_O_CREAT 0x10
2142#define SMB_O_EXCL 0x20
2143#define SMB_O_TRUNC 0x40
2144#define SMB_O_APPEND 0x80
2145#define SMB_O_SYNC 0x100
2146#define SMB_O_DIRECTORY 0x200
2147#define SMB_O_NOFOLLOW 0x400
2148#define SMB_O_DIRECT 0x800
2149
Steve French595dcfe2007-02-08 18:11:42 +00002150typedef struct {
Steve French2dd29d32007-04-23 22:07:35 +00002151 __le32 OpenFlags; /* same as NT CreateX */
2152 __le32 PosixOpenFlags;
2153 __le64 Permissions;
2154 __le16 Level; /* reply level requested (see QPathInfo levels) */
Steve French595dcfe2007-02-08 18:11:42 +00002155} __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
2156
2157typedef struct {
Steve French2dd29d32007-04-23 22:07:35 +00002158 __le16 OplockFlags;
2159 __u16 Fid;
2160 __le32 CreateAction;
2161 __le16 ReturnedLevel;
2162 __le16 Pad;
2163 /* struct following varies based on requested level */
Steve French8af18972007-02-14 04:42:51 +00002164} __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
Steve French595dcfe2007-02-08 18:11:42 +00002165
Steve French2d785a52007-07-15 01:48:57 +00002166#define SMB_POSIX_UNLINK_FILE_TARGET 0
2167#define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2168
2169struct unlink_psx_rq { /* level 0x20a SetPathInfo */
2170 __le16 type;
2171} __attribute__((packed));
Steve French595dcfe2007-02-08 18:11:42 +00002172
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173struct file_internal_info {
2174 __u64 UniqueId; /* inode number */
Steve French0753ca72005-10-27 13:55:12 -07002175} __attribute__((packed)); /* level 0x3ee */
Steve French2dd29d32007-04-23 22:07:35 +00002176
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177struct file_mode_info {
2178 __le32 Mode;
Steve French0753ca72005-10-27 13:55:12 -07002179} __attribute__((packed)); /* level 0x3f8 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002180
2181struct file_attrib_tag {
2182 __le32 Attribute;
2183 __le32 ReparseTag;
Steve French0753ca72005-10-27 13:55:12 -07002184} __attribute__((packed)); /* level 0x40b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185
2186
2187/********************************************************/
Steve French50c2f752007-07-13 00:33:32 +00002188/* FindFirst/FindNext transact2 data buffer formats */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002189/********************************************************/
2190
2191typedef struct {
2192 __le32 NextEntryOffset;
2193 __u32 ResumeKey; /* as with FileIndex - no need to convert */
2194 __le64 EndOfFile;
2195 __le64 NumOfBytes;
2196 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2197 __le64 LastAccessTime;
2198 __le64 LastModificationTime;
2199 __le64 Uid;
2200 __le64 Gid;
2201 __le32 Type;
2202 __le64 DevMajor;
2203 __le64 DevMinor;
2204 __u64 UniqueId;
2205 __le64 Permissions;
2206 __le64 Nlinks;
2207 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07002208} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209
2210typedef struct {
2211 __le32 NextEntryOffset;
2212 __u32 FileIndex;
2213 __le64 CreationTime;
2214 __le64 LastAccessTime;
2215 __le64 LastWriteTime;
2216 __le64 ChangeTime;
2217 __le64 EndOfFile;
2218 __le64 AllocationSize;
2219 __le32 ExtFileAttributes;
2220 __le32 FileNameLength;
2221 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002222} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223
2224typedef struct {
2225 __le32 NextEntryOffset;
2226 __u32 FileIndex;
2227 __le64 CreationTime;
2228 __le64 LastAccessTime;
2229 __le64 LastWriteTime;
2230 __le64 ChangeTime;
2231 __le64 EndOfFile;
2232 __le64 AllocationSize;
2233 __le32 ExtFileAttributes;
2234 __le32 FileNameLength;
2235 __le32 EaSize; /* length of the xattrs */
2236 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002237} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238
2239typedef struct {
2240 __le32 NextEntryOffset;
2241 __u32 FileIndex;
2242 __le64 CreationTime;
2243 __le64 LastAccessTime;
2244 __le64 LastWriteTime;
2245 __le64 ChangeTime;
2246 __le64 EndOfFile;
2247 __le64 AllocationSize;
2248 __le32 ExtFileAttributes;
2249 __le32 FileNameLength;
2250 __le32 EaSize; /* EA size */
2251 __le32 Reserved;
2252 __u64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
2253 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002254} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255
2256typedef struct {
2257 __le32 NextEntryOffset;
2258 __u32 FileIndex;
2259 __le64 CreationTime;
2260 __le64 LastAccessTime;
2261 __le64 LastWriteTime;
2262 __le64 ChangeTime;
2263 __le64 EndOfFile;
2264 __le64 AllocationSize;
2265 __le32 ExtFileAttributes;
Steve French50c2f752007-07-13 00:33:32 +00002266 __le32 FileNameLength;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 __le32 EaSize; /* length of the xattrs */
2268 __u8 ShortNameLength;
2269 __u8 Reserved;
2270 __u8 ShortName[12];
2271 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002272} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2273
2274typedef struct {
2275 __u32 ResumeKey;
2276 __le16 CreationDate; /* SMB Date */
2277 __le16 CreationTime; /* SMB Time */
2278 __le16 LastAccessDate;
2279 __le16 LastAccessTime;
2280 __le16 LastWriteDate;
2281 __le16 LastWriteTime;
2282 __le32 DataSize; /* File Size (EOF) */
2283 __le32 AllocationSize;
2284 __le16 Attributes; /* verify not u32 */
2285 __u8 FileNameLength;
2286 char FileName[1];
2287} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288
2289
Steve French86c96b42005-11-18 20:25:31 -08002290struct win_dev {
2291 unsigned char type[8]; /* IntxCHR or IntxBLK */
2292 __le64 major;
Steve French50c2f752007-07-13 00:33:32 +00002293 __le64 minor;
Steve French86c96b42005-11-18 20:25:31 -08002294} __attribute__((packed));
2295
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296struct gea {
2297 unsigned char name_len;
2298 char name[1];
Steve French0753ca72005-10-27 13:55:12 -07002299} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300
2301struct gealist {
2302 unsigned long list_len;
2303 struct gea list[1];
Steve French0753ca72005-10-27 13:55:12 -07002304} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305
2306struct fea {
2307 unsigned char EA_flags;
2308 __u8 name_len;
2309 __le16 value_len;
2310 char name[1];
2311 /* optionally followed by value */
Steve French0753ca72005-10-27 13:55:12 -07002312} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313/* flags for _FEA.fEA */
2314#define FEA_NEEDEA 0x80 /* need EA bit */
2315
2316struct fealist {
2317 __le32 list_len;
2318 struct fea list[1];
Steve French0753ca72005-10-27 13:55:12 -07002319} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320
2321/* used to hold an arbitrary blob of data */
2322struct data_blob {
2323 __u8 *data;
2324 size_t length;
Steve French50c2f752007-07-13 00:33:32 +00002325 void (*free) (struct data_blob *data_blob);
Steve French0753ca72005-10-27 13:55:12 -07002326} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002327
2328
2329#ifdef CONFIG_CIFS_POSIX
Steve French50c2f752007-07-13 00:33:32 +00002330/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 For better POSIX semantics from Linux client, (even better
2332 than the existing CIFS Unix Extensions) we need updated PDUs for:
Steve French50c2f752007-07-13 00:33:32 +00002333
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 1) PosixCreateX - to set and return the mode, inode#, device info and
2335 perhaps add a CreateDevice - to create Pipes and other special .inodes
2336 Also note POSIX open flags
Steve French50c2f752007-07-13 00:33:32 +00002337 2) Close - to return the last write time to do cache across close
Steve French87f440e2007-02-07 00:29:46 +00002338 more safely
Steve French50c2f752007-07-13 00:33:32 +00002339 3) FindFirst return unique inode number - what about resume key, two
Steve French1982c342005-08-17 12:38:22 -07002340 forms short (matches readdir) and full (enough info to cache inodes)
2341 4) Mkdir - set mode
Steve French50c2f752007-07-13 00:33:32 +00002342
2343 And under consideration:
Steve French1982c342005-08-17 12:38:22 -07002344 5) FindClose2 (return nanosecond timestamp ??)
Steve French50c2f752007-07-13 00:33:32 +00002345 6) Use nanosecond timestamps throughout all time fields if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002346 corresponding attribute flag is set
Steve French1982c342005-08-17 12:38:22 -07002347 7) sendfile - handle based copy
2348 8) Direct i/o
2349 9) Misc fcntls?
Steve French50c2f752007-07-13 00:33:32 +00002350
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 what about fixing 64 bit alignment
Steve French50c2f752007-07-13 00:33:32 +00002352
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 There are also various legacy SMB/CIFS requests used as is
Steve French50c2f752007-07-13 00:33:32 +00002354
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355 From existing Lanman and NTLM dialects:
2356 --------------------------------------
2357 NEGOTIATE
2358 SESSION_SETUP_ANDX (BB which?)
2359 TREE_CONNECT_ANDX (BB which wct?)
2360 TREE_DISCONNECT (BB add volume timestamp on response)
2361 LOGOFF_ANDX
2362 DELETE (note delete open file behavior)
2363 DELETE_DIRECTORY
2364 READ_AND_X
2365 WRITE_AND_X
2366 LOCKING_AND_X (note posix lock semantics)
2367 RENAME (note rename across dirs and open file rename posix behaviors)
2368 NT_RENAME (for hardlinks) Is this good enough for all features?
2369 FIND_CLOSE2
2370 TRANSACTION2 (18 cases)
2371 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2372 (BB verify that never need to set allocation size)
Steve French87f440e2007-02-07 00:29:46 +00002373 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2374 Unix ext?)
Steve French50c2f752007-07-13 00:33:32 +00002375
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2377 setting/getting OS/2 EAs - FUTURE (BB can this handle
2378 setting Linux xattrs perfectly) - OPTIONAL
2379 dnotify - FUTURE, OPTIONAL
2380 quota - FUTURE, OPTIONAL
Steve French50c2f752007-07-13 00:33:32 +00002381
2382 Note that various requests implemented for NT interop such as
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 NT_TRANSACT (IOCTL) QueryReparseInfo
2384 are unneeded to servers compliant with the CIFS POSIX extensions
Steve French50c2f752007-07-13 00:33:32 +00002385
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 From CIFS Unix Extensions:
2387 -------------------------
2388 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2389 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2390 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
Steve French50c2f752007-07-13 00:33:32 +00002391 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2392 inode fields
2393 Actually a need QUERY_FILE_UNIX_INFO
2394 since has inode num
2395 BB what about a) blksize/blkbits/blocks
Steve French87f440e2007-02-07 00:29:46 +00002396 b) i_version
2397 c) i_rdev
2398 d) notify mask?
2399 e) generation
2400 f) size_seqcount
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
Steve French50c2f752007-07-13 00:33:32 +00002402 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 */
2405
Steve French1982c342005-08-17 12:38:22 -07002406/* xsymlink is a symlink format (used by MacOS) that can be used
Steve French50c2f752007-07-13 00:33:32 +00002407 to save symlink info in a regular file when
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 mounted to operating systems that do not
2409 support the cifs Unix extensions or EAs (for xattr
2410 based symlinks). For such a file to be recognized
Steve French50c2f752007-07-13 00:33:32 +00002411 as containing symlink data:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412
Steve French50c2f752007-07-13 00:33:32 +00002413 1) file size must be 1067,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 2) signature must begin file data,
2415 3) length field must be set to ASCII representation
Steve French50c2f752007-07-13 00:33:32 +00002416 of a number which is less than or equal to 1024,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 4) md5 must match that of the path data */
2418
2419struct xsymlink {
2420 /* 1067 bytes */
2421 char signature[4]; /* XSym */ /* not null terminated */
2422 char cr0; /* \n */
2423/* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2424 char length[4];
2425 char cr1; /* \n */
2426/* md5 of valid subset of path ie path[0] through path[length-1] */
Steve French50c2f752007-07-13 00:33:32 +00002427 __u8 md5[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 char cr2; /* \n */
2429/* if room left, then end with \n then 0x20s by convention but not required */
Steve French50c2f752007-07-13 00:33:32 +00002430 char path[1024];
Steve French0753ca72005-10-27 13:55:12 -07002431} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002432
Steve Frenchf654bac2005-04-28 22:41:04 -07002433typedef struct file_xattr_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 /* BB do we need another field for flags? BB */
2435 __u32 xattr_name_len;
2436 __u32 xattr_value_len;
2437 char xattr_name[0];
2438 /* followed by xattr_value[xattr_value_len], no pad */
Steve French50c2f752007-07-13 00:33:32 +00002439} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
2440 level 0x205 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441
2442
Steve Frenchf654bac2005-04-28 22:41:04 -07002443/* flags for chattr command */
2444#define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2445#define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2446/* Reserved for compress file 0x4 */
2447#define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2448#define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2449#define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2450#define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2451#define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2452/* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2453#define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2454/* 0x2000 reserved for IMAGIC_FL */
2455#define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2456/* 0x8000 reserved for EXT3_NOTAIL_FL */
2457#define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2458#define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2459
2460#define EXT_SET_MASK 0x000300FF
2461#define EXT_GET_MASK 0x0003DFFF
2462
2463typedef struct file_chattr_info {
2464 __le64 mask; /* list of all possible attribute bits */
2465 __le64 mode; /* list of actual attribute bits on this inode */
Steve French50c2f752007-07-13 00:33:32 +00002466} __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes
2467 (chattr, chflags) level 0x206 */
Steve Frenchf654bac2005-04-28 22:41:04 -07002468
Steve French50c2f752007-07-13 00:33:32 +00002469#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471#endif /* _CIFSPDU_H */