blob: ea205b4fcad25eea51c7fa70b4458299934e15cb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/cifs/cifspdu.h
3 *
Steve French03824572009-02-25 16:24:04 +00004 * Copyright (c) International Business Machines Corp., 2002,2009
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>
Steve French03824572009-02-25 16:24:04 +000026#include "smbfsctl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Steve French39798772006-05-31 22:40:51 +000028#ifdef CONFIG_CIFS_WEAK_PW_HASH
29#define LANMAN_PROT 0
Steve French9ac00b72006-09-30 04:13:17 +000030#define LANMAN2_PROT 1
31#define CIFS_PROT 2
Steve French39798772006-05-31 22:40:51 +000032#else
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define CIFS_PROT 0
Steve French39798772006-05-31 22:40:51 +000034#endif
Shirish Pargaonkaref571ca2008-07-24 15:56:05 +000035#define POSIX_PROT (CIFS_PROT+1)
Steve French39798772006-05-31 22:40:51 +000036#define BAD_PROT 0xFFFF
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Steve French03824572009-02-25 16:24:04 +000038/* SMB command codes:
39 * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
Steve Frenchc14e8942007-02-15 01:33:18 +000040 * (ie which include no useful data other than the SMB error code itself).
Steve French03824572009-02-25 16:24:04 +000041 * This can allow us to avoid response buffer allocations and copy in some cases
Steve Frenchc14e8942007-02-15 01:33:18 +000042 */
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 */
Steve Frenchb298f222009-02-21 21:17:43 +000046#define SMB_COM_FLUSH 0x05 /* triv req/rsp */
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define SMB_COM_DELETE 0x06 /* trivial response */
48#define SMB_COM_RENAME 0x07 /* trivial response */
Steve French6b8edfe2005-08-23 20:26:03 -070049#define SMB_COM_QUERY_INFORMATION 0x08 /* aka getattr */
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#define SMB_COM_SETATTR 0x09 /* trivial response */
51#define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
52#define SMB_COM_COPY 0x29 /* trivial rsp, fail filename ignrd*/
Jeff Layton766fdbb2011-01-11 07:24:21 -050053#define SMB_COM_ECHO 0x2B /* echo request */
Steve Frencha9d02ad2005-08-24 23:06:05 -070054#define SMB_COM_OPEN_ANDX 0x2D /* Legacy open for old servers */
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define SMB_COM_READ_ANDX 0x2E
56#define SMB_COM_WRITE_ANDX 0x2F
57#define SMB_COM_TRANSACTION2 0x32
58#define SMB_COM_TRANSACTION2_SECONDARY 0x33
59#define SMB_COM_FIND_CLOSE2 0x34 /* trivial response */
60#define SMB_COM_TREE_DISCONNECT 0x71 /* trivial response */
61#define SMB_COM_NEGOTIATE 0x72
62#define SMB_COM_SESSION_SETUP_ANDX 0x73
63#define SMB_COM_LOGOFF_ANDX 0x74 /* trivial response */
64#define SMB_COM_TREE_CONNECT_ANDX 0x75
65#define SMB_COM_NT_TRANSACT 0xA0
66#define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
67#define SMB_COM_NT_CREATE_ANDX 0xA2
Steve Frenchff5dbd92005-08-24 17:10:36 -070068#define SMB_COM_NT_CANCEL 0xA4 /* no response */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069#define SMB_COM_NT_RENAME 0xA5 /* trivial response */
70
71/* Transact2 subcommand codes */
72#define TRANS2_OPEN 0x00
73#define TRANS2_FIND_FIRST 0x01
74#define TRANS2_FIND_NEXT 0x02
75#define TRANS2_QUERY_FS_INFORMATION 0x03
Jeremy Allisonac670552005-06-22 17:26:35 -070076#define TRANS2_SET_FS_INFORMATION 0x04
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define TRANS2_QUERY_PATH_INFORMATION 0x05
78#define TRANS2_SET_PATH_INFORMATION 0x06
79#define TRANS2_QUERY_FILE_INFORMATION 0x07
80#define TRANS2_SET_FILE_INFORMATION 0x08
81#define TRANS2_GET_DFS_REFERRAL 0x10
82#define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
83
Steve Frenchb7206152008-05-23 20:35:07 +000084/* SMB Transact (Named Pipe) subcommand codes */
85#define TRANS_SET_NMPIPE_STATE 0x0001
86#define TRANS_RAW_READ_NMPIPE 0x0011
87#define TRANS_QUERY_NMPIPE_STATE 0x0021
88#define TRANS_QUERY_NMPIPE_INFO 0x0022
89#define TRANS_PEEK_NMPIPE 0x0023
90#define TRANS_TRANSACT_NMPIPE 0x0026
91#define TRANS_RAW_WRITE_NMPIPE 0x0031
92#define TRANS_READ_NMPIPE 0x0036
93#define TRANS_WRITE_NMPIPE 0x0037
94#define TRANS_WAIT_NMPIPE 0x0053
95#define TRANS_CALL_NMPIPE 0x0054
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097/* NT Transact subcommand codes */
98#define NT_TRANSACT_CREATE 0x01
99#define NT_TRANSACT_IOCTL 0x02
100#define NT_TRANSACT_SET_SECURITY_DESC 0x03
101#define NT_TRANSACT_NOTIFY_CHANGE 0x04
102#define NT_TRANSACT_RENAME 0x05
103#define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
104#define NT_TRANSACT_GET_USER_QUOTA 0x07
105#define NT_TRANSACT_SET_USER_QUOTA 0x08
106
Steve Frenchec637e32005-12-12 20:53:18 -0800107#define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
108/* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
109/* among the requests (NTCreateX response is bigger with wct of 34) */
110#define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
111#define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113/* internal cifs vfs structures */
114/*****************************************************************
115 * All constants go here
116 *****************************************************************
117 */
118
119/*
120 * Starting value for maximum SMB size negotiation
121 */
122#define CIFS_MAX_MSGSIZE (4*4096)
123
124/*
125 * Size of encrypted user password in bytes
126 */
127#define CIFS_ENCPWD_SIZE (16)
128
129/*
130 * Size of the crypto key returned on the negotiate SMB in bytes
131 */
132#define CIFS_CRYPTO_KEY_SIZE (8)
133
134/*
Shirish Pargaonkar21e73392010-10-21 06:42:55 -0500135 * Size of the ntlm client response
136 */
137#define CIFS_AUTH_RESP_SIZE (24)
138
139/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 * Size of the session key (crypto key encrypted with the password
141 */
Shirish Pargaonkar21e73392010-10-21 06:42:55 -0500142#define CIFS_SESS_KEY_SIZE (16)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Shirish Pargaonkard2b91522010-10-21 14:25:08 -0500144#define CIFS_CLIENT_CHALLENGE_SIZE (8)
145#define CIFS_SERVER_CHALLENGE_SIZE (8)
146#define CIFS_HMAC_MD5_HASH_SIZE (16)
147#define CIFS_CPHTXT_SIZE (16)
148#define CIFS_NTHASH_SIZE (16)
149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150/*
151 * Maximum user name length
152 */
153#define CIFS_UNLEN (20)
154
155/*
156 * Flags on SMB open
157 */
158#define SMBOPEN_WRITE_THROUGH 0x4000
159#define SMBOPEN_DENY_ALL 0x0010
160#define SMBOPEN_DENY_WRITE 0x0020
161#define SMBOPEN_DENY_READ 0x0030
162#define SMBOPEN_DENY_NONE 0x0040
163#define SMBOPEN_READ 0x0000
164#define SMBOPEN_WRITE 0x0001
165#define SMBOPEN_READWRITE 0x0002
166#define SMBOPEN_EXECUTE 0x0003
167
168#define SMBOPEN_OCREATE 0x0010
169#define SMBOPEN_OTRUNC 0x0002
170#define SMBOPEN_OAPPEND 0x0001
171
172/*
Steve French50c2f752007-07-13 00:33:32 +0000173 * SMB flag definitions
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 */
Steve French0753ca72005-10-27 13:55:12 -0700175#define SMBFLG_EXTD_LOCK 0x01 /* server supports lock-read write-unlock smb */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176#define SMBFLG_RCV_POSTED 0x02 /* obsolete */
177#define SMBFLG_RSVD 0x04
Steve French0753ca72005-10-27 13:55:12 -0700178#define SMBFLG_CASELESS 0x08 /* all pathnames treated as caseless (off
179 implies case sensitive file handling request) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180#define SMBFLG_CANONICAL_PATH_FORMAT 0x10 /* obsolete */
181#define SMBFLG_OLD_OPLOCK 0x20 /* obsolete */
182#define SMBFLG_OLD_OPLOCK_NOTIFY 0x40 /* obsolete */
183#define SMBFLG_RESPONSE 0x80 /* this PDU is a response from server */
184
185/*
Steve French50c2f752007-07-13 00:33:32 +0000186 * SMB flag2 definitions
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 */
Steve French50c2f752007-07-13 00:33:32 +0000188#define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1) /* can send long (non-8.3)
Steve French0753ca72005-10-27 13:55:12 -0700189 path names in response */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190#define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
191#define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
Steve French675c4672008-04-17 23:41:01 +0000192#define SMBFLG2_COMPRESSED (8)
193#define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
Steve French675c4672008-04-17 23:41:01 +0000195#define SMBFLG2_REPARSE_PATH (0x400)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196#define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
197#define SMBFLG2_DFS cpu_to_le16(0x1000)
198#define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
199#define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
200#define SMBFLG2_UNICODE cpu_to_le16(0x8000)
201
202/*
203 * These are the file access permission bits defined in CIFS for the
204 * NTCreateAndX as well as the level 0x107
205 * TRANS2_QUERY_PATH_INFORMATION API. The level 0x107, SMB_QUERY_FILE_ALL_INFO
206 * responds with the AccessFlags.
207 * The AccessFlags specifies the access permissions a caller has to the
208 * file and can have any suitable combination of the following values:
209 */
210
Steve French0753ca72005-10-27 13:55:12 -0700211#define FILE_READ_DATA 0x00000001 /* Data can be read from the file */
212#define FILE_WRITE_DATA 0x00000002 /* Data can be written to the file */
213#define FILE_APPEND_DATA 0x00000004 /* Data can be appended to the file */
214#define FILE_READ_EA 0x00000008 /* Extended attributes associated */
215 /* with the file can be read */
216#define FILE_WRITE_EA 0x00000010 /* Extended attributes associated */
217 /* with the file can be written */
218#define FILE_EXECUTE 0x00000020 /*Data can be read into memory from */
219 /* the file using system paging I/O */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220#define FILE_DELETE_CHILD 0x00000040
Steve French0753ca72005-10-27 13:55:12 -0700221#define FILE_READ_ATTRIBUTES 0x00000080 /* Attributes associated with the */
222 /* file can be read */
223#define FILE_WRITE_ATTRIBUTES 0x00000100 /* Attributes associated with the */
224 /* file can be written */
225#define DELETE 0x00010000 /* The file can be deleted */
226#define READ_CONTROL 0x00020000 /* The access control list and */
227 /* ownership associated with the */
228 /* file can be read */
229#define WRITE_DAC 0x00040000 /* The access control list and */
230 /* ownership associated with the */
231 /* file can be written. */
232#define WRITE_OWNER 0x00080000 /* Ownership information associated */
233 /* with the file can be written */
234#define SYNCHRONIZE 0x00100000 /* The file handle can waited on to */
235 /* synchronize with the completion */
236 /* of an input/output request */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237#define GENERIC_ALL 0x10000000
238#define GENERIC_EXECUTE 0x20000000
239#define GENERIC_WRITE 0x40000000
240#define GENERIC_READ 0x80000000
241 /* In summary - Relevant file */
242 /* access flags from CIFS are */
243 /* file_read_data, file_write_data */
Steve French0753ca72005-10-27 13:55:12 -0700244 /* file_execute, file_read_attributes*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 /* write_dac, and delete. */
246
Steve Frencha750e772007-10-17 22:50:39 +0000247#define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)
248#define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
249 | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
250#define FILE_EXEC_RIGHTS (FILE_EXECUTE)
251
Steve French953f8682007-10-31 04:54:42 +0000252#define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
253 | FILE_READ_ATTRIBUTES \
254 | FILE_WRITE_ATTRIBUTES \
255 | DELETE | READ_CONTROL | WRITE_DAC \
256 | WRITE_OWNER | SYNCHRONIZE)
257#define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
258 | FILE_READ_EA | FILE_WRITE_EA \
259 | FILE_DELETE_CHILD | FILE_READ_ATTRIBUTES \
260 | FILE_WRITE_ATTRIBUTES \
261 | DELETE | READ_CONTROL | WRITE_DAC \
262 | WRITE_OWNER | SYNCHRONIZE)
263#define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
264 | FILE_READ_ATTRIBUTES \
265 | FILE_WRITE_ATTRIBUTES \
266 | DELETE | READ_CONTROL | WRITE_DAC \
267 | WRITE_OWNER | SYNCHRONIZE)
268
Steve French97837582007-12-31 07:47:21 +0000269#define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
270 | READ_CONTROL | SYNCHRONIZE)
271
Steve Frencha750e772007-10-17 22:50:39 +0000272
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273/*
274 * Invalid readdir handle
275 */
276#define CIFS_NO_HANDLE 0xFFFF
277
Jeff Layton4e1e7fb2008-08-02 07:26:12 -0400278#define NO_CHANGE_64 0xFFFFFFFFFFFFFFFFULL
Steve Frenchc7af1852007-03-01 04:11:22 +0000279#define NO_CHANGE_32 0xFFFFFFFFUL
280
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281/* IPC$ in ASCII */
282#define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
283
284/* IPC$ in Unicode */
285#define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
286
287/* Unicode Null terminate 2 bytes of 0 */
288#define UNICODE_NULL "\x00\x00"
289#define ASCII_NULL 0x00
290
291/*
292 * Server type values (returned on EnumServer API
293 */
294#define CIFS_SV_TYPE_DC 0x00000008
295#define CIFS_SV_TYPE_BACKDC 0x00000010
296
297/*
298 * Alias type flags (From EnumAlias API call
299 */
300#define CIFS_ALIAS_TYPE_FILE 0x0001
301#define CIFS_SHARE_TYPE_FILE 0x0000
302
303/*
304 * File Attribute flags
305 */
306#define ATTR_READONLY 0x0001
307#define ATTR_HIDDEN 0x0002
308#define ATTR_SYSTEM 0x0004
309#define ATTR_VOLUME 0x0008
310#define ATTR_DIRECTORY 0x0010
311#define ATTR_ARCHIVE 0x0020
312#define ATTR_DEVICE 0x0040
313#define ATTR_NORMAL 0x0080
314#define ATTR_TEMPORARY 0x0100
315#define ATTR_SPARSE 0x0200
316#define ATTR_REPARSE 0x0400
317#define ATTR_COMPRESSED 0x0800
Steve French50c2f752007-07-13 00:33:32 +0000318#define ATTR_OFFLINE 0x1000 /* ie file not immediately available -
Steve French0753ca72005-10-27 13:55:12 -0700319 on offline storage */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320#define ATTR_NOT_CONTENT_INDEXED 0x2000
321#define ATTR_ENCRYPTED 0x4000
322#define ATTR_POSIX_SEMANTICS 0x01000000
323#define ATTR_BACKUP_SEMANTICS 0x02000000
324#define ATTR_DELETE_ON_CLOSE 0x04000000
325#define ATTR_SEQUENTIAL_SCAN 0x08000000
326#define ATTR_RANDOM_ACCESS 0x10000000
327#define ATTR_NO_BUFFERING 0x20000000
328#define ATTR_WRITE_THROUGH 0x80000000
329
330/* ShareAccess flags */
331#define FILE_NO_SHARE 0x00000000
332#define FILE_SHARE_READ 0x00000001
333#define FILE_SHARE_WRITE 0x00000002
334#define FILE_SHARE_DELETE 0x00000004
335#define FILE_SHARE_ALL 0x00000007
336
Steve French675c4672008-04-17 23:41:01 +0000337/* CreateDisposition flags, similar to CreateAction as well */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338#define FILE_SUPERSEDE 0x00000000
339#define FILE_OPEN 0x00000001
340#define FILE_CREATE 0x00000002
341#define FILE_OPEN_IF 0x00000003
342#define FILE_OVERWRITE 0x00000004
343#define FILE_OVERWRITE_IF 0x00000005
344
345/* CreateOptions */
346#define CREATE_NOT_FILE 0x00000001 /* if set must not be file */
347#define CREATE_WRITE_THROUGH 0x00000002
Steve Frencheda3c0292005-07-21 15:20:28 -0700348#define CREATE_SEQUENTIAL 0x00000004
Steve French675c4672008-04-17 23:41:01 +0000349#define CREATE_NO_BUFFER 0x00000008 /* should not buffer on srv */
350#define CREATE_SYNC_ALERT 0x00000010 /* MBZ */
351#define CREATE_ASYNC_ALERT 0x00000020 /* MBZ */
Steve Frencheda3c0292005-07-21 15:20:28 -0700352#define CREATE_NOT_DIR 0x00000040 /* if set must not be directory */
Steve French675c4672008-04-17 23:41:01 +0000353#define CREATE_TREE_CONNECTION 0x00000080 /* should be zero */
354#define CREATE_COMPLETE_IF_OPLK 0x00000100 /* should be zero */
Steve Frencheda3c0292005-07-21 15:20:28 -0700355#define CREATE_NO_EA_KNOWLEDGE 0x00000200
Steve French675c4672008-04-17 23:41:01 +0000356#define CREATE_EIGHT_DOT_THREE 0x00000400 /* doc says this is obsolete
Shirish Pargaonkaref571ca2008-07-24 15:56:05 +0000357 "open for recovery" flag should
Steve Frenchb7206152008-05-23 20:35:07 +0000358 be zero in any case */
359#define CREATE_OPEN_FOR_RECOVERY 0x00000400
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360#define CREATE_RANDOM_ACCESS 0x00000800
361#define CREATE_DELETE_ON_CLOSE 0x00001000
Steve Frencheda3c0292005-07-21 15:20:28 -0700362#define CREATE_OPEN_BY_ID 0x00002000
Steve Frenchb7206152008-05-23 20:35:07 +0000363#define CREATE_OPEN_BACKUP_INTENT 0x00004000
Steve French675c4672008-04-17 23:41:01 +0000364#define CREATE_NO_COMPRESSION 0x00008000
365#define CREATE_RESERVE_OPFILTER 0x00100000 /* should be zero */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366#define OPEN_REPARSE_POINT 0x00200000
Steve French675c4672008-04-17 23:41:01 +0000367#define OPEN_NO_RECALL 0x00400000
368#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */
Steve French50c2f752007-07-13 00:33:32 +0000369#define CREATE_OPTIONS_MASK 0x007FFFFF
Jeff Layton67750fb2008-05-09 22:28:02 +0000370#define CREATE_OPTION_READONLY 0x10000000
Steve Frencheda3c0292005-07-21 15:20:28 -0700371#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372
373/* ImpersonationLevel flags */
374#define SECURITY_ANONYMOUS 0
375#define SECURITY_IDENTIFICATION 1
376#define SECURITY_IMPERSONATION 2
377#define SECURITY_DELEGATION 3
378
379/* SecurityFlags */
380#define SECURITY_CONTEXT_TRACKING 0x01
381#define SECURITY_EFFECTIVE_ONLY 0x02
382
383/*
384 * Default PID value, used in all SMBs where the PID is not important
385 */
386#define CIFS_DFT_PID 0x1234
387
388/*
389 * We use the same routine for Copy and Move SMBs. This flag is used to
390 * distinguish
391 */
392#define CIFS_COPY_OP 1
393#define CIFS_RENAME_OP 2
394
395#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
396#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
397
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398struct smb_hdr {
Steve French0753ca72005-10-27 13:55:12 -0700399 __u32 smb_buf_length; /* big endian on wire *//* BB length is only two
400 or three bytes - with one or two byte type preceding it that are
401 zero - we could mask the type byte off just in case BB */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 __u8 Protocol[4];
403 __u8 Command;
404 union {
405 struct {
406 __u8 ErrorClass;
407 __u8 Reserved;
408 __le16 Error;
Steve French0753ca72005-10-27 13:55:12 -0700409 } __attribute__((packed)) DosError;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 __le32 CifsError;
Steve French0753ca72005-10-27 13:55:12 -0700411 } __attribute__((packed)) Status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 __u8 Flags;
413 __le16 Flags2; /* note: le */
414 __le16 PidHigh;
415 union {
416 struct {
417 __le32 SequenceNumber; /* le */
418 __u32 Reserved; /* zero */
Steve French0753ca72005-10-27 13:55:12 -0700419 } __attribute__((packed)) Sequence;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 __u8 SecuritySignature[8]; /* le */
Steve French0753ca72005-10-27 13:55:12 -0700421 } __attribute__((packed)) Signature;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 __u8 pad[2];
423 __u16 Tid;
424 __le16 Pid;
425 __u16 Uid;
426 __u16 Mid;
427 __u8 WordCount;
Steve French0753ca72005-10-27 13:55:12 -0700428} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429/* given a pointer to an smb_hdr retrieve the value of byte count */
Jeff Layton370b4192010-02-10 16:18:25 -0500430#define BCC(smb_var) (*(__u16 *)((char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount)))
431#define BCC_LE(smb_var) (*(__le16 *)((char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
Jeff Layton370b4192010-02-10 16:18:25 -0500433#define pByteArea(smb_var) ((unsigned char *)(smb_var) + sizeof(struct smb_hdr) + (2 * (smb_var)->WordCount) + 2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434
435/*
Steve French50c2f752007-07-13 00:33:32 +0000436 * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
437 * No longer as important, now that TCP names are more commonly used to
438 * resolve hosts.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 */
440#define CNLEN 15
441
442/*
Steve French50c2f752007-07-13 00:33:32 +0000443 * Share Name Length (SNLEN)
444 * Note: This length was limited by the SMB used to get
445 * the Share info. NetShareEnum only returned 13
446 * chars, including the null termination.
447 * This was removed because it no longer is limiting.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
450/*
451 * Comment Length
452 */
453#define MAXCOMMENTLEN 40
454
455/*
456 * The OS/2 maximum path name
457 */
458#define MAX_PATHCONF 256
459
460/*
461 * SMB frame definitions (following must be packed structs)
462 * See the SNIA CIFS Specification for details.
463 *
464 * The Naming convention is the lower case version of the
465 * smb command code name for the struct and this is typedef to the
Steve French50c2f752007-07-13 00:33:32 +0000466 * uppercase version of the same name with the prefix SMB_ removed
467 * for brevity. Although typedefs are not commonly used for
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 * structure definitions in the Linux kernel, their use in the
469 * CIFS standards document, which this code is based on, may
470 * make this one of the cases where typedefs for structures make
471 * sense to improve readability for readers of the standards doc.
472 * Typedefs can always be removed later if they are too distracting
473 * and they are only used for the CIFSs PDUs themselves, not
474 * internal cifs vfs structures
Steve French50c2f752007-07-13 00:33:32 +0000475 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 */
477
478typedef struct negotiate_req {
479 struct smb_hdr hdr; /* wct = 0 */
480 __le16 ByteCount;
481 unsigned char DialectsArray[1];
Steve French0753ca72005-10-27 13:55:12 -0700482} __attribute__((packed)) NEGOTIATE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Steve French39798772006-05-31 22:40:51 +0000484/* Dialect index is 13 for LANMAN */
485
Steve Frenchb815f1e52006-10-02 05:53:29 +0000486#define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
487
Steve French39798772006-05-31 22:40:51 +0000488typedef struct lanman_neg_rsp {
489 struct smb_hdr hdr; /* wct = 13 */
490 __le16 DialectIndex;
491 __le16 SecurityMode;
492 __le16 MaxBufSize;
493 __le16 MaxMpxCount;
494 __le16 MaxNumberVcs;
495 __le16 RawMode;
496 __le32 SessionKey;
Steve French175ec9e2006-09-30 01:07:38 +0000497 struct {
498 __le16 Time;
499 __le16 Date;
500 } __attribute__((packed)) SrvTime;
Steve French39798772006-05-31 22:40:51 +0000501 __le16 ServerTimeZone;
502 __le16 EncryptionKeyLength;
503 __le16 Reserved;
504 __u16 ByteCount;
505 unsigned char EncryptionKey[1];
506} __attribute__((packed)) LANMAN_NEG_RSP;
507
Steve French254e55e2006-06-04 05:53:15 +0000508#define READ_RAW_ENABLE 1
509#define WRITE_RAW_ENABLE 2
510#define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
511
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512typedef struct negotiate_rsp {
513 struct smb_hdr hdr; /* wct = 17 */
Steve French675c4672008-04-17 23:41:01 +0000514 __le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 __u8 SecurityMode;
516 __le16 MaxMpxCount;
517 __le16 MaxNumberVcs;
518 __le32 MaxBufferSize;
519 __le32 MaxRawSize;
520 __le32 SessionKey;
521 __le32 Capabilities; /* see below */
522 __le32 SystemTimeLow;
523 __le32 SystemTimeHigh;
524 __le16 ServerTimeZone;
525 __u8 EncryptionKeyLength;
526 __u16 ByteCount;
527 union {
Steve French0753ca72005-10-27 13:55:12 -0700528 unsigned char EncryptionKey[1]; /* cap extended security off */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 /* followed by Domain name - if extended security is off */
530 /* followed by 16 bytes of server GUID */
Steve French0753ca72005-10-27 13:55:12 -0700531 /* then security blob if cap_extended_security negotiated */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 struct {
533 unsigned char GUID[16];
534 unsigned char SecurityBlob[1];
Steve French0753ca72005-10-27 13:55:12 -0700535 } __attribute__((packed)) extended_response;
536 } __attribute__((packed)) u;
537} __attribute__((packed)) NEGOTIATE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538
539/* SecurityMode bits */
540#define SECMODE_USER 0x01 /* off indicates share level security */
541#define SECMODE_PW_ENCRYPT 0x02
542#define SECMODE_SIGN_ENABLED 0x04 /* SMB security signatures enabled */
543#define SECMODE_SIGN_REQUIRED 0x08 /* SMB security signatures required */
544
545/* Negotiate response Capabilities */
546#define CAP_RAW_MODE 0x00000001
547#define CAP_MPX_MODE 0x00000002
548#define CAP_UNICODE 0x00000004
549#define CAP_LARGE_FILES 0x00000008
550#define CAP_NT_SMBS 0x00000010 /* implies CAP_NT_FIND */
551#define CAP_RPC_REMOTE_APIS 0x00000020
552#define CAP_STATUS32 0x00000040
553#define CAP_LEVEL_II_OPLOCKS 0x00000080
554#define CAP_LOCK_AND_READ 0x00000100
555#define CAP_NT_FIND 0x00000200
556#define CAP_DFS 0x00001000
557#define CAP_INFOLEVEL_PASSTHRU 0x00002000
558#define CAP_LARGE_READ_X 0x00004000
559#define CAP_LARGE_WRITE_X 0x00008000
Steve French675c4672008-04-17 23:41:01 +0000560#define CAP_LWIO 0x00010000 /* support fctl_srv_req_resume_key */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561#define CAP_UNIX 0x00800000
Steve French675c4672008-04-17 23:41:01 +0000562#define CAP_COMPRESSED_DATA 0x02000000
563#define CAP_DYNAMIC_REAUTH 0x20000000
564#define CAP_PERSISTENT_HANDLES 0x40000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565#define CAP_EXTENDED_SECURITY 0x80000000
566
567typedef union smb_com_session_setup_andx {
568 struct { /* request format */
569 struct smb_hdr hdr; /* wct = 12 */
570 __u8 AndXCommand;
571 __u8 AndXReserved;
572 __le16 AndXOffset;
573 __le16 MaxBufferSize;
574 __le16 MaxMpxCount;
575 __le16 VcNumber;
576 __u32 SessionKey;
577 __le16 SecurityBlobLength;
578 __u32 Reserved;
579 __le32 Capabilities; /* see below */
580 __le16 ByteCount;
581 unsigned char SecurityBlob[1]; /* followed by */
582 /* STRING NativeOS */
583 /* STRING NativeLanMan */
Steve French50c2f752007-07-13 00:33:32 +0000584 } __attribute__((packed)) req; /* NTLM request format (with
Steve French0753ca72005-10-27 13:55:12 -0700585 extended security */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
587 struct { /* request format */
588 struct smb_hdr hdr; /* wct = 13 */
589 __u8 AndXCommand;
590 __u8 AndXReserved;
591 __le16 AndXOffset;
592 __le16 MaxBufferSize;
593 __le16 MaxMpxCount;
594 __le16 VcNumber;
595 __u32 SessionKey;
Steve French0753ca72005-10-27 13:55:12 -0700596 __le16 CaseInsensitivePasswordLength; /* ASCII password len */
597 __le16 CaseSensitivePasswordLength; /* Unicode password length*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 __u32 Reserved; /* see below */
599 __le32 Capabilities;
600 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700601 unsigned char CaseInsensitivePassword[1]; /* followed by: */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 /* unsigned char * CaseSensitivePassword; */
603 /* STRING AccountName */
604 /* STRING PrimaryDomain */
605 /* STRING NativeOS */
606 /* STRING NativeLanMan */
Steve French0753ca72005-10-27 13:55:12 -0700607 } __attribute__((packed)) req_no_secext; /* NTLM request format (without
608 extended security */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609
610 struct { /* default (NTLM) response format */
611 struct smb_hdr hdr; /* wct = 4 */
612 __u8 AndXCommand;
613 __u8 AndXReserved;
614 __le16 AndXOffset;
615 __le16 Action; /* see below */
616 __le16 SecurityBlobLength;
617 __u16 ByteCount;
618 unsigned char SecurityBlob[1]; /* followed by */
619/* unsigned char * NativeOS; */
620/* unsigned char * NativeLanMan; */
621/* unsigned char * PrimaryDomain; */
Steve French50c2f752007-07-13 00:33:32 +0000622 } __attribute__((packed)) resp; /* NTLM response
Steve French87f440e2007-02-07 00:29:46 +0000623 (with or without extended sec) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
625 struct { /* request format */
626 struct smb_hdr hdr; /* wct = 10 */
627 __u8 AndXCommand;
628 __u8 AndXReserved;
629 __le16 AndXOffset;
630 __le16 MaxBufferSize;
631 __le16 MaxMpxCount;
632 __le16 VcNumber;
633 __u32 SessionKey;
Steve French39798772006-05-31 22:40:51 +0000634 __le16 PasswordLength;
635 __u32 Reserved; /* encrypt key len and offset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 __le16 ByteCount;
637 unsigned char AccountPassword[1]; /* followed by */
638 /* STRING AccountName */
639 /* STRING PrimaryDomain */
640 /* STRING NativeOS */
641 /* STRING NativeLanMan */
Steve French0a4b92c2006-01-12 15:44:21 -0800642 } __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643
644 struct { /* default (NTLM) response format */
645 struct smb_hdr hdr; /* wct = 3 */
646 __u8 AndXCommand;
647 __u8 AndXReserved;
648 __le16 AndXOffset;
649 __le16 Action; /* see below */
650 __u16 ByteCount;
651 unsigned char NativeOS[1]; /* followed by */
652/* unsigned char * NativeLanMan; */
653/* unsigned char * PrimaryDomain; */
Steve French0a4b92c2006-01-12 15:44:21 -0800654 } __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
Steve French0753ca72005-10-27 13:55:12 -0700655} __attribute__((packed)) SESSION_SETUP_ANDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656
Steve Frenchf64b23a2006-06-05 05:27:37 +0000657/* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
658
Steve French33ec32f2006-12-08 04:14:28 +0000659#define NTLMSSP_SERVER_TYPE 1
660#define NTLMSSP_DOMAIN_TYPE 2
661#define NTLMSSP_FQ_DOMAIN_TYPE 3
662#define NTLMSSP_DNS_DOMAIN_TYPE 4
663#define NTLMSSP_DNS_PARENT_TYPE 5
664
Steve Frenchf64b23a2006-06-05 05:27:37 +0000665struct ntlmssp2_name {
666 __le16 type;
667 __le16 length;
668/* char name[length]; */
669} __attribute__((packed));
670
671struct ntlmv2_resp {
672 char ntlmv2_hash[CIFS_ENCPWD_SIZE];
Steve French6d027cf2006-06-05 16:26:05 +0000673 __le32 blob_signature;
Steve Frenchf64b23a2006-06-05 05:27:37 +0000674 __u32 reserved;
675 __le64 time;
676 __u64 client_chal; /* random */
677 __u32 reserved2;
Steve Frenchf64b23a2006-06-05 05:27:37 +0000678 /* array of name entries could follow ending in minimum 4 byte struct */
679} __attribute__((packed));
680
681
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682#define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
683
684/* Capabilities bits (for NTLM SessSetup request) */
685#define CAP_UNICODE 0x00000004
686#define CAP_LARGE_FILES 0x00000008
687#define CAP_NT_SMBS 0x00000010
688#define CAP_STATUS32 0x00000040
689#define CAP_LEVEL_II_OPLOCKS 0x00000080
Steve French50c2f752007-07-13 00:33:32 +0000690#define CAP_NT_FIND 0x00000200 /* reserved should be zero
Steve French0753ca72005-10-27 13:55:12 -0700691 (because NT_SMBs implies the same thing?) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692#define CAP_BULK_TRANSFER 0x20000000
693#define CAP_EXTENDED_SECURITY 0x80000000
694
695/* Action bits */
696#define GUEST_LOGIN 1
697
698typedef struct smb_com_tconx_req {
699 struct smb_hdr hdr; /* wct = 4 */
700 __u8 AndXCommand;
701 __u8 AndXReserved;
702 __le16 AndXOffset;
703 __le16 Flags; /* see below */
704 __le16 PasswordLength;
705 __le16 ByteCount;
706 unsigned char Password[1]; /* followed by */
707/* STRING Path *//* \\server\share name */
708 /* STRING Service */
Steve French0753ca72005-10-27 13:55:12 -0700709} __attribute__((packed)) TCONX_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710
711typedef struct smb_com_tconx_rsp {
Steve French675c4672008-04-17 23:41:01 +0000712 struct smb_hdr hdr; /* wct = 3 , not extended response */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 __u8 AndXCommand;
714 __u8 AndXReserved;
715 __le16 AndXOffset;
716 __le16 OptionalSupport; /* see below */
717 __u16 ByteCount;
718 unsigned char Service[1]; /* always ASCII, not Unicode */
719 /* STRING NativeFileSystem */
Steve French0753ca72005-10-27 13:55:12 -0700720} __attribute__((packed)) TCONX_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721
Steve French675c4672008-04-17 23:41:01 +0000722typedef struct smb_com_tconx_rsp_ext {
723 struct smb_hdr hdr; /* wct = 7, extended response */
724 __u8 AndXCommand;
725 __u8 AndXReserved;
726 __le16 AndXOffset;
727 __le16 OptionalSupport; /* see below */
728 __le32 MaximalShareAccessRights;
729 __le32 GuestMaximalShareAccessRights;
730 __u16 ByteCount;
731 unsigned char Service[1]; /* always ASCII, not Unicode */
732 /* STRING NativeFileSystem */
733} __attribute__((packed)) TCONX_RSP_EXT;
734
735
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736/* tree connect Flags */
737#define DISCONNECT_TID 0x0001
Steve French675c4672008-04-17 23:41:01 +0000738#define TCON_EXTENDED_SIGNATURES 0x0004
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739#define TCON_EXTENDED_SECINFO 0x0008
Steve French675c4672008-04-17 23:41:01 +0000740
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741/* OptionalSupport bits */
Steve French0753ca72005-10-27 13:55:12 -0700742#define SMB_SUPPORT_SEARCH_BITS 0x0001 /* "must have" directory search bits
743 (exclusive searches supported) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744#define SMB_SHARE_IS_IN_DFS 0x0002
Steve French675c4672008-04-17 23:41:01 +0000745#define SMB_CSC_MASK 0x000C
746/* CSC flags defined as follows */
747#define SMB_CSC_CACHE_MANUAL_REINT 0x0000
748#define SMB_CSC_CACHE_AUTO_REINT 0x0004
749#define SMB_CSC_CACHE_VDO 0x0008
750#define SMB_CSC_NO_CACHING 0x000C
Steve French675c4672008-04-17 23:41:01 +0000751#define SMB_UNIQUE_FILE_NAME 0x0010
752#define SMB_EXTENDED_SIGNATURES 0x0020
753
754/* services
755 *
756 * A: ie disk
757 * LPT1: ie printer
758 * IPC ie named pipe
759 * COMM
760 * ????? ie any type
761 *
762 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763
Jeff Layton766fdbb2011-01-11 07:24:21 -0500764typedef struct smb_com_echo_req {
765 struct smb_hdr hdr;
766 __le16 EchoCount;
767 __le16 ByteCount;
768 char Data[1];
769} __attribute__((packed)) ECHO_REQ;
770
771typedef struct smb_com_echo_rsp {
772 struct smb_hdr hdr;
773 __le16 SequenceNumber;
774 __le16 ByteCount;
775 char Data[1];
776} __attribute__((packed)) ECHO_RSP;
777
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778typedef struct smb_com_logoff_andx_req {
779 struct smb_hdr hdr; /* wct = 2 */
780 __u8 AndXCommand;
781 __u8 AndXReserved;
782 __u16 AndXOffset;
783 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700784} __attribute__((packed)) LOGOFF_ANDX_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785
786typedef struct smb_com_logoff_andx_rsp {
787 struct smb_hdr hdr; /* wct = 2 */
788 __u8 AndXCommand;
789 __u8 AndXReserved;
790 __u16 AndXOffset;
791 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -0700792} __attribute__((packed)) LOGOFF_ANDX_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793
Steve French50c2f752007-07-13 00:33:32 +0000794typedef union smb_com_tree_disconnect { /* as an altetnative can use flag on
Steve French86c96b42005-11-18 20:25:31 -0800795 tree_connect PDU to effect disconnect */
796 /* tdis is probably simplest SMB PDU */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 struct {
798 struct smb_hdr hdr; /* wct = 0 */
799 __u16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700800 } __attribute__((packed)) req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 struct {
802 struct smb_hdr hdr; /* wct = 0 */
803 __u16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700804 } __attribute__((packed)) resp;
805} __attribute__((packed)) TREE_DISCONNECT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806
807typedef struct smb_com_close_req {
808 struct smb_hdr hdr; /* wct = 3 */
809 __u16 FileID;
Steve Frenchb815f1e52006-10-02 05:53:29 +0000810 __u32 LastWriteTime; /* should be zero or -1 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 __u16 ByteCount; /* 0 */
Steve French0753ca72005-10-27 13:55:12 -0700812} __attribute__((packed)) CLOSE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813
814typedef struct smb_com_close_rsp {
815 struct smb_hdr hdr; /* wct = 0 */
816 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700817} __attribute__((packed)) CLOSE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818
Steve Frenchb298f222009-02-21 21:17:43 +0000819typedef struct smb_com_flush_req {
820 struct smb_hdr hdr; /* wct = 1 */
821 __u16 FileID;
822 __u16 ByteCount; /* 0 */
823} __attribute__((packed)) FLUSH_REQ;
824
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825typedef struct smb_com_findclose_req {
826 struct smb_hdr hdr; /* wct = 1 */
827 __u16 FileID;
828 __u16 ByteCount; /* 0 */
Steve French0753ca72005-10-27 13:55:12 -0700829} __attribute__((packed)) FINDCLOSE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830
831/* OpenFlags */
Steve Frencha9d02ad2005-08-24 23:06:05 -0700832#define REQ_MORE_INFO 0x00000001 /* legacy (OPEN_AND_X) only */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833#define REQ_OPLOCK 0x00000002
834#define REQ_BATCHOPLOCK 0x00000004
835#define REQ_OPENDIRONLY 0x00000008
Steve French75865f8c2007-06-24 18:30:48 +0000836#define REQ_EXTENDED_INFO 0x00000010
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837
Steve French92ad9b92007-09-29 05:21:58 +0000838/* File type */
839#define DISK_TYPE 0x0000
840#define BYTE_PIPE_TYPE 0x0001
841#define MESSAGE_PIPE_TYPE 0x0002
842#define PRINTER_TYPE 0x0003
843#define COMM_DEV_TYPE 0x0004
844#define UNKNOWN_TYPE 0xFFFF
845
Steve French675c4672008-04-17 23:41:01 +0000846/* Device Type or File Status Flags */
847#define NO_EAS 0x0001
848#define NO_SUBSTREAMS 0x0002
849#define NO_REPARSETAG 0x0004
850/* following flags can apply if pipe */
851#define ICOUNT_MASK 0x00FF
852#define PIPE_READ_MODE 0x0100
853#define NAMED_PIPE_TYPE 0x0400
Steve Frenchb7206152008-05-23 20:35:07 +0000854#define PIPE_END_POINT 0x4000
Steve French675c4672008-04-17 23:41:01 +0000855#define BLOCKING_NAMED_PIPE 0x8000
856
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857typedef struct smb_com_open_req { /* also handles create */
858 struct smb_hdr hdr; /* wct = 24 */
859 __u8 AndXCommand;
860 __u8 AndXReserved;
861 __le16 AndXOffset;
862 __u8 Reserved; /* Must Be Zero */
863 __le16 NameLength;
864 __le32 OpenFlags;
Steve French675c4672008-04-17 23:41:01 +0000865 __u32 RootDirectoryFid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 __le32 DesiredAccess;
867 __le64 AllocationSize;
868 __le32 FileAttributes;
869 __le32 ShareAccess;
870 __le32 CreateDisposition;
871 __le32 CreateOptions;
872 __le32 ImpersonationLevel;
873 __u8 SecurityFlags;
874 __le16 ByteCount;
875 char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -0700876} __attribute__((packed)) OPEN_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877
878/* open response: oplock levels */
879#define OPLOCK_NONE 0
880#define OPLOCK_EXCLUSIVE 1
881#define OPLOCK_BATCH 2
882#define OPLOCK_READ 3 /* level 2 oplock */
883
884/* open response for CreateAction shifted left */
885#define CIFS_CREATE_ACTION 0x20000 /* file created */
886
887typedef struct smb_com_open_rsp {
888 struct smb_hdr hdr; /* wct = 34 BB */
889 __u8 AndXCommand;
890 __u8 AndXReserved;
891 __le16 AndXOffset;
892 __u8 OplockLevel;
893 __u16 Fid;
894 __le32 CreateAction;
895 __le64 CreationTime;
896 __le64 LastAccessTime;
897 __le64 LastWriteTime;
898 __le64 ChangeTime;
899 __le32 FileAttributes;
900 __le64 AllocationSize;
901 __le64 EndOfFile;
902 __le16 FileType;
903 __le16 DeviceState;
904 __u8 DirectoryFlag;
905 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -0700906} __attribute__((packed)) OPEN_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907
Steve French675c4672008-04-17 23:41:01 +0000908typedef struct smb_com_open_rsp_ext {
909 struct smb_hdr hdr; /* wct = 42 but meaningless due to MS bug? */
910 __u8 AndXCommand;
911 __u8 AndXReserved;
912 __le16 AndXOffset;
913 __u8 OplockLevel;
914 __u16 Fid;
915 __le32 CreateAction;
916 __le64 CreationTime;
917 __le64 LastAccessTime;
918 __le64 LastWriteTime;
919 __le64 ChangeTime;
920 __le32 FileAttributes;
921 __le64 AllocationSize;
922 __le64 EndOfFile;
923 __le16 FileType;
924 __le16 DeviceState;
925 __u8 DirectoryFlag;
926 __u8 VolumeGUID[16];
927 __u64 FileId; /* note no endian conversion - is opaque UniqueID */
928 __le32 MaximalAccessRights;
929 __le32 GuestMaximalAccessRights;
930 __u16 ByteCount; /* bct = 0 */
931} __attribute__((packed)) OPEN_RSP_EXT;
932
933
Steve Frencha9d02ad2005-08-24 23:06:05 -0700934/* format of legacy open request */
935typedef struct smb_com_openx_req {
936 struct smb_hdr hdr; /* wct = 15 */
937 __u8 AndXCommand;
938 __u8 AndXReserved;
939 __le16 AndXOffset;
940 __le16 OpenFlags;
941 __le16 Mode;
942 __le16 Sattr; /* search attributes */
943 __le16 FileAttributes; /* dos attrs */
944 __le32 CreateTime; /* os2 format */
945 __le16 OpenFunction;
946 __le32 EndOfFile;
947 __le32 Timeout;
948 __le32 Reserved;
Steve French70ca7342005-09-22 16:32:06 -0700949 __le16 ByteCount; /* file name follows */
Steve Frencha9d02ad2005-08-24 23:06:05 -0700950 char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -0700951} __attribute__((packed)) OPENX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700952
953typedef struct smb_com_openx_rsp {
954 struct smb_hdr hdr; /* wct = 15 */
955 __u8 AndXCommand;
956 __u8 AndXReserved;
957 __le16 AndXOffset;
958 __u16 Fid;
959 __le16 FileAttributes;
960 __le32 LastWriteTime; /* os2 format */
961 __le32 EndOfFile;
962 __le16 Access;
963 __le16 FileType;
964 __le16 IPCState;
965 __le16 Action;
966 __u32 FileId;
967 __u16 Reserved;
968 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +0000969} __attribute__((packed)) OPENX_RSP;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700970
Steve French595dcfe2007-02-08 18:11:42 +0000971/* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
972
Steve Frencha9d02ad2005-08-24 23:06:05 -0700973/* Legacy write request for older servers */
974typedef struct smb_com_writex_req {
Steve French50c2f752007-07-13 00:33:32 +0000975 struct smb_hdr hdr; /* wct = 12 */
976 __u8 AndXCommand;
977 __u8 AndXReserved;
978 __le16 AndXOffset;
979 __u16 Fid;
980 __le32 OffsetLow;
981 __u32 Reserved; /* Timeout */
982 __le16 WriteMode; /* 1 = write through */
983 __le16 Remaining;
984 __le16 Reserved2;
985 __le16 DataLengthLow;
986 __le16 DataOffset;
987 __le16 ByteCount;
988 __u8 Pad; /* BB check for whether padded to DWORD
989 boundary and optimum performance here */
990 char Data[0];
Steve French0753ca72005-10-27 13:55:12 -0700991} __attribute__((packed)) WRITEX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -0700992
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993typedef struct smb_com_write_req {
994 struct smb_hdr hdr; /* wct = 14 */
995 __u8 AndXCommand;
996 __u8 AndXReserved;
997 __le16 AndXOffset;
998 __u16 Fid;
999 __le32 OffsetLow;
1000 __u32 Reserved;
1001 __le16 WriteMode;
1002 __le16 Remaining;
1003 __le16 DataLengthHigh;
1004 __le16 DataLengthLow;
1005 __le16 DataOffset;
1006 __le32 OffsetHigh;
1007 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001008 __u8 Pad; /* BB check for whether padded to DWORD
1009 boundary and optimum performance here */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 char Data[0];
Steve French0753ca72005-10-27 13:55:12 -07001011} __attribute__((packed)) WRITE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012
1013typedef struct smb_com_write_rsp {
1014 struct smb_hdr hdr; /* wct = 6 */
1015 __u8 AndXCommand;
1016 __u8 AndXReserved;
1017 __le16 AndXOffset;
1018 __le16 Count;
1019 __le16 Remaining;
1020 __le16 CountHigh;
1021 __u16 Reserved;
1022 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001023} __attribute__((packed)) WRITE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024
Steve Frencha9d02ad2005-08-24 23:06:05 -07001025/* legacy read request for older servers */
1026typedef struct smb_com_readx_req {
Steve French50c2f752007-07-13 00:33:32 +00001027 struct smb_hdr hdr; /* wct = 10 */
1028 __u8 AndXCommand;
1029 __u8 AndXReserved;
1030 __le16 AndXOffset;
1031 __u16 Fid;
1032 __le32 OffsetLow;
1033 __le16 MaxCount;
1034 __le16 MinCount; /* obsolete */
1035 __le32 Reserved;
1036 __le16 Remaining;
1037 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001038} __attribute__((packed)) READX_REQ;
Steve Frencha9d02ad2005-08-24 23:06:05 -07001039
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040typedef struct smb_com_read_req {
1041 struct smb_hdr hdr; /* wct = 12 */
1042 __u8 AndXCommand;
1043 __u8 AndXReserved;
1044 __le16 AndXOffset;
1045 __u16 Fid;
1046 __le32 OffsetLow;
1047 __le16 MaxCount;
1048 __le16 MinCount; /* obsolete */
1049 __le32 MaxCountHigh;
1050 __le16 Remaining;
1051 __le32 OffsetHigh;
1052 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001053} __attribute__((packed)) READ_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054
1055typedef struct smb_com_read_rsp {
1056 struct smb_hdr hdr; /* wct = 12 */
1057 __u8 AndXCommand;
1058 __u8 AndXReserved;
1059 __le16 AndXOffset;
1060 __le16 Remaining;
1061 __le16 DataCompactionMode;
1062 __le16 Reserved;
1063 __le16 DataLength;
1064 __le16 DataOffset;
1065 __le16 DataLengthHigh;
1066 __u64 Reserved2;
1067 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001068 __u8 Pad; /* BB check for whether padded to DWORD
1069 boundary and optimum performance here */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 char Data[1];
Steve French0753ca72005-10-27 13:55:12 -07001071} __attribute__((packed)) READ_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072
1073typedef struct locking_andx_range {
1074 __le16 Pid;
1075 __le16 Pad;
1076 __le32 OffsetHigh;
1077 __le32 OffsetLow;
1078 __le32 LengthHigh;
1079 __le32 LengthLow;
Steve French0753ca72005-10-27 13:55:12 -07001080} __attribute__((packed)) LOCKING_ANDX_RANGE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081
1082#define LOCKING_ANDX_SHARED_LOCK 0x01
1083#define LOCKING_ANDX_OPLOCK_RELEASE 0x02
1084#define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
1085#define LOCKING_ANDX_CANCEL_LOCK 0x08
1086#define LOCKING_ANDX_LARGE_FILES 0x10 /* always on for us */
1087
1088typedef struct smb_com_lock_req {
1089 struct smb_hdr hdr; /* wct = 8 */
1090 __u8 AndXCommand;
1091 __u8 AndXReserved;
1092 __le16 AndXOffset;
1093 __u16 Fid;
1094 __u8 LockType;
1095 __u8 OplockLevel;
1096 __le32 Timeout;
1097 __le16 NumberOfUnlocks;
1098 __le16 NumberOfLocks;
1099 __le16 ByteCount;
1100 LOCKING_ANDX_RANGE Locks[1];
Steve French0753ca72005-10-27 13:55:12 -07001101} __attribute__((packed)) LOCK_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102
Steve French08547b02006-02-28 22:39:25 +00001103/* lock type */
1104#define CIFS_RDLCK 0
1105#define CIFS_WRLCK 1
1106#define CIFS_UNLCK 2
Steve Frenchf654bac2005-04-28 22:41:04 -07001107typedef struct cifs_posix_lock {
1108 __le16 lock_type; /* 0 = Read, 1 = Write, 2 = Unlock */
1109 __le16 lock_flags; /* 1 = Wait (only valid for setlock) */
1110 __le32 pid;
1111 __le64 start;
1112 __le64 length;
1113 /* BB what about additional owner info to identify network client */
Steve French0753ca72005-10-27 13:55:12 -07001114} __attribute__((packed)) CIFS_POSIX_LOCK;
Steve Frenchf654bac2005-04-28 22:41:04 -07001115
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116typedef struct smb_com_lock_rsp {
1117 struct smb_hdr hdr; /* wct = 2 */
1118 __u8 AndXCommand;
1119 __u8 AndXReserved;
1120 __le16 AndXOffset;
1121 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001122} __attribute__((packed)) LOCK_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123
1124typedef struct smb_com_rename_req {
1125 struct smb_hdr hdr; /* wct = 1 */
1126 __le16 SearchAttributes; /* target file attributes */
1127 __le16 ByteCount;
1128 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1129 unsigned char OldFileName[1];
1130 /* followed by __u8 BufferFormat2 */
1131 /* followed by NewFileName */
Steve French0753ca72005-10-27 13:55:12 -07001132} __attribute__((packed)) RENAME_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133
1134 /* copy request flags */
1135#define COPY_MUST_BE_FILE 0x0001
1136#define COPY_MUST_BE_DIR 0x0002
1137#define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
1138#define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
1139#define COPY_VERIFY_WRITES 0x0010
Steve French50c2f752007-07-13 00:33:32 +00001140#define COPY_TREE 0x0020
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141
1142typedef struct smb_com_copy_req {
1143 struct smb_hdr hdr; /* wct = 3 */
1144 __u16 Tid2;
1145 __le16 OpenFunction;
1146 __le16 Flags;
1147 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001148 __u8 BufferFormat; /* 4 = ASCII or Unicode */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 unsigned char OldFileName[1];
1150 /* followed by __u8 BufferFormat2 */
1151 /* followed by NewFileName string */
Steve French0753ca72005-10-27 13:55:12 -07001152} __attribute__((packed)) COPY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153
1154typedef struct smb_com_copy_rsp {
1155 struct smb_hdr hdr; /* wct = 1 */
1156 __le16 CopyCount; /* number of files copied */
1157 __u16 ByteCount; /* may be zero */
1158 __u8 BufferFormat; /* 0x04 - only present if errored file follows */
1159 unsigned char ErrorFileName[1]; /* only present if error in copy */
Steve French0753ca72005-10-27 13:55:12 -07001160} __attribute__((packed)) COPY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161
1162#define CREATE_HARD_LINK 0x103
1163#define MOVEFILE_COPY_ALLOWED 0x0002
1164#define MOVEFILE_REPLACE_EXISTING 0x0001
1165
1166typedef struct smb_com_nt_rename_req { /* A5 - also used for create hardlink */
1167 struct smb_hdr hdr; /* wct = 4 */
1168 __le16 SearchAttributes; /* target file attributes */
1169 __le16 Flags; /* spec says Information Level */
1170 __le32 ClusterCount;
1171 __le16 ByteCount;
1172 __u8 BufferFormat; /* 4 = ASCII or Unicode */
1173 unsigned char OldFileName[1];
1174 /* followed by __u8 BufferFormat2 */
1175 /* followed by NewFileName */
Steve French0753ca72005-10-27 13:55:12 -07001176} __attribute__((packed)) NT_RENAME_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177
1178typedef struct smb_com_rename_rsp {
1179 struct smb_hdr hdr; /* wct = 0 */
1180 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001181} __attribute__((packed)) RENAME_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182
1183typedef struct smb_com_delete_file_req {
1184 struct smb_hdr hdr; /* wct = 1 */
1185 __le16 SearchAttributes;
1186 __le16 ByteCount;
1187 __u8 BufferFormat; /* 4 = ASCII */
1188 unsigned char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001189} __attribute__((packed)) DELETE_FILE_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190
1191typedef struct smb_com_delete_file_rsp {
1192 struct smb_hdr hdr; /* wct = 0 */
1193 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001194} __attribute__((packed)) DELETE_FILE_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195
1196typedef struct smb_com_delete_directory_req {
1197 struct smb_hdr hdr; /* wct = 0 */
1198 __le16 ByteCount;
1199 __u8 BufferFormat; /* 4 = ASCII */
1200 unsigned char DirName[1];
Steve French0753ca72005-10-27 13:55:12 -07001201} __attribute__((packed)) DELETE_DIRECTORY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202
1203typedef struct smb_com_delete_directory_rsp {
1204 struct smb_hdr hdr; /* wct = 0 */
1205 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001206} __attribute__((packed)) DELETE_DIRECTORY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207
1208typedef struct smb_com_create_directory_req {
1209 struct smb_hdr hdr; /* wct = 0 */
1210 __le16 ByteCount;
1211 __u8 BufferFormat; /* 4 = ASCII */
1212 unsigned char DirName[1];
Steve French0753ca72005-10-27 13:55:12 -07001213} __attribute__((packed)) CREATE_DIRECTORY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214
1215typedef struct smb_com_create_directory_rsp {
1216 struct smb_hdr hdr; /* wct = 0 */
1217 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001218} __attribute__((packed)) CREATE_DIRECTORY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219
Steve French6b8edfe2005-08-23 20:26:03 -07001220typedef struct smb_com_query_information_req {
1221 struct smb_hdr hdr; /* wct = 0 */
1222 __le16 ByteCount; /* 1 + namelen + 1 */
1223 __u8 BufferFormat; /* 4 = ASCII */
1224 unsigned char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001225} __attribute__((packed)) QUERY_INFORMATION_REQ;
Steve French6b8edfe2005-08-23 20:26:03 -07001226
1227typedef struct smb_com_query_information_rsp {
1228 struct smb_hdr hdr; /* wct = 10 */
1229 __le16 attr;
1230 __le32 last_write_time;
1231 __le32 size;
1232 __u16 reserved[5];
1233 __le16 ByteCount; /* bcc = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001234} __attribute__((packed)) QUERY_INFORMATION_RSP;
Steve French6b8edfe2005-08-23 20:26:03 -07001235
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236typedef struct smb_com_setattr_req {
1237 struct smb_hdr hdr; /* wct = 8 */
1238 __le16 attr;
1239 __le16 time_low;
1240 __le16 time_high;
1241 __le16 reserved[5]; /* must be zero */
1242 __u16 ByteCount;
1243 __u8 BufferFormat; /* 4 = ASCII */
1244 unsigned char fileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001245} __attribute__((packed)) SETATTR_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246
1247typedef struct smb_com_setattr_rsp {
1248 struct smb_hdr hdr; /* wct = 0 */
1249 __u16 ByteCount; /* bct = 0 */
Steve French0753ca72005-10-27 13:55:12 -07001250} __attribute__((packed)) SETATTR_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001251
1252/* empty wct response to setattr */
1253
Steve French0a4b92c2006-01-12 15:44:21 -08001254/*******************************************************/
Adam Buchbinder6070d812009-12-04 15:47:01 -05001255/* NT Transact structure definitions follow */
Steve French50c2f752007-07-13 00:33:32 +00001256/* Currently only ioctl, acl (get security descriptor) */
Steve French0a4b92c2006-01-12 15:44:21 -08001257/* and notify are implemented */
1258/*******************************************************/
1259typedef struct smb_com_ntransact_req {
Steve French50c2f752007-07-13 00:33:32 +00001260 struct smb_hdr hdr; /* wct >= 19 */
1261 __u8 MaxSetupCount;
1262 __u16 Reserved;
1263 __le32 TotalParameterCount;
1264 __le32 TotalDataCount;
1265 __le32 MaxParameterCount;
1266 __le32 MaxDataCount;
1267 __le32 ParameterCount;
1268 __le32 ParameterOffset;
1269 __le32 DataCount;
1270 __le32 DataOffset;
1271 __u8 SetupCount; /* four setup words follow subcommand */
1272 /* SNIA spec incorrectly included spurious pad here */
1273 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
1274 /* SetupCount words follow then */
1275 __le16 ByteCount;
1276 __u8 Pad[3];
1277 __u8 Parms[0];
Steve French0a4b92c2006-01-12 15:44:21 -08001278} __attribute__((packed)) NTRANSACT_REQ;
1279
1280typedef struct smb_com_ntransact_rsp {
1281 struct smb_hdr hdr; /* wct = 18 */
1282 __u8 Reserved[3];
1283 __le32 TotalParameterCount;
1284 __le32 TotalDataCount;
1285 __le32 ParameterCount;
1286 __le32 ParameterOffset;
1287 __le32 ParameterDisplacement;
1288 __le32 DataCount;
1289 __le32 DataOffset;
1290 __le32 DataDisplacement;
1291 __u8 SetupCount; /* 0 */
1292 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001293 /* __u8 Pad[3]; */
Steve French0a4b92c2006-01-12 15:44:21 -08001294 /* parms and data follow */
1295} __attribute__((packed)) NTRANSACT_RSP;
1296
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297typedef struct smb_com_transaction_ioctl_req {
1298 struct smb_hdr hdr; /* wct = 23 */
1299 __u8 MaxSetupCount;
1300 __u16 Reserved;
1301 __le32 TotalParameterCount;
1302 __le32 TotalDataCount;
1303 __le32 MaxParameterCount;
1304 __le32 MaxDataCount;
1305 __le32 ParameterCount;
1306 __le32 ParameterOffset;
1307 __le32 DataCount;
1308 __le32 DataOffset;
1309 __u8 SetupCount; /* four setup words follow subcommand */
1310 /* SNIA spec incorrectly included spurious pad here */
Steve French0a4b92c2006-01-12 15:44:21 -08001311 __le16 SubCommand; /* 2 = IOCTL/FSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 __le32 FunctionCode;
1313 __u16 Fid;
Steve French0a4b92c2006-01-12 15:44:21 -08001314 __u8 IsFsctl; /* 1 = File System Control 0 = device control (IOCTL) */
1315 __u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 __le16 ByteCount;
1317 __u8 Pad[3];
1318 __u8 Data[1];
Steve French0753ca72005-10-27 13:55:12 -07001319} __attribute__((packed)) TRANSACT_IOCTL_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320
1321typedef struct smb_com_transaction_ioctl_rsp {
1322 struct smb_hdr hdr; /* wct = 19 */
1323 __u8 Reserved[3];
1324 __le32 TotalParameterCount;
1325 __le32 TotalDataCount;
1326 __le32 ParameterCount;
1327 __le32 ParameterOffset;
1328 __le32 ParameterDisplacement;
1329 __le32 DataCount;
1330 __le32 DataOffset;
1331 __le32 DataDisplacement;
1332 __u8 SetupCount; /* 1 */
1333 __le16 ReturnedDataLen;
1334 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001335} __attribute__((packed)) TRANSACT_IOCTL_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336
Steve French0a4b92c2006-01-12 15:44:21 -08001337#define CIFS_ACL_OWNER 1
1338#define CIFS_ACL_GROUP 2
1339#define CIFS_ACL_DACL 4
1340#define CIFS_ACL_SACL 8
1341
1342typedef struct smb_com_transaction_qsec_req {
1343 struct smb_hdr hdr; /* wct = 19 */
1344 __u8 MaxSetupCount;
1345 __u16 Reserved;
1346 __le32 TotalParameterCount;
1347 __le32 TotalDataCount;
1348 __le32 MaxParameterCount;
1349 __le32 MaxDataCount;
1350 __le32 ParameterCount;
1351 __le32 ParameterOffset;
1352 __le32 DataCount;
1353 __le32 DataOffset;
1354 __u8 SetupCount; /* no setup words follow subcommand */
1355 /* SNIA spec incorrectly included spurious pad here */
1356 __le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
1357 __le16 ByteCount; /* bcc = 3 + 8 */
1358 __u8 Pad[3];
1359 __u16 Fid;
1360 __u16 Reserved2;
1361 __le32 AclFlags;
1362} __attribute__((packed)) QUERY_SEC_DESC_REQ;
1363
Steve French7505e052007-11-01 18:03:01 +00001364
1365typedef struct smb_com_transaction_ssec_req {
1366 struct smb_hdr hdr; /* wct = 19 */
1367 __u8 MaxSetupCount;
1368 __u16 Reserved;
1369 __le32 TotalParameterCount;
1370 __le32 TotalDataCount;
1371 __le32 MaxParameterCount;
1372 __le32 MaxDataCount;
1373 __le32 ParameterCount;
1374 __le32 ParameterOffset;
1375 __le32 DataCount;
1376 __le32 DataOffset;
1377 __u8 SetupCount; /* no setup words follow subcommand */
1378 /* SNIA spec incorrectly included spurious pad here */
1379 __le16 SubCommand; /* 3 = SET_SECURITY_DESC */
1380 __le16 ByteCount; /* bcc = 3 + 8 */
1381 __u8 Pad[3];
1382 __u16 Fid;
1383 __u16 Reserved2;
1384 __le32 AclFlags;
1385} __attribute__((packed)) SET_SEC_DESC_REQ;
1386
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387typedef struct smb_com_transaction_change_notify_req {
1388 struct smb_hdr hdr; /* wct = 23 */
1389 __u8 MaxSetupCount;
1390 __u16 Reserved;
1391 __le32 TotalParameterCount;
1392 __le32 TotalDataCount;
1393 __le32 MaxParameterCount;
1394 __le32 MaxDataCount;
1395 __le32 ParameterCount;
1396 __le32 ParameterOffset;
1397 __le32 DataCount;
1398 __le32 DataOffset;
1399 __u8 SetupCount; /* four setup words follow subcommand */
1400 /* SNIA spec incorrectly included spurious pad here */
1401 __le16 SubCommand;/* 4 = Change Notify */
1402 __le32 CompletionFilter; /* operation to monitor */
1403 __u16 Fid;
1404 __u8 WatchTree; /* 1 = Monitor subdirectories */
1405 __u8 Reserved2;
1406 __le16 ByteCount;
Steve French0a4b92c2006-01-12 15:44:21 -08001407/* __u8 Pad[3];*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408/* __u8 Data[1];*/
Steve French0753ca72005-10-27 13:55:12 -07001409} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410
Steve French50c2f752007-07-13 00:33:32 +00001411/* BB eventually change to use generic ntransact rsp struct
Steve French0a4b92c2006-01-12 15:44:21 -08001412 and validation routine */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413typedef struct smb_com_transaction_change_notify_rsp {
1414 struct smb_hdr hdr; /* wct = 18 */
1415 __u8 Reserved[3];
1416 __le32 TotalParameterCount;
1417 __le32 TotalDataCount;
1418 __le32 ParameterCount;
1419 __le32 ParameterOffset;
1420 __le32 ParameterDisplacement;
1421 __le32 DataCount;
1422 __le32 DataOffset;
1423 __le32 DataDisplacement;
1424 __u8 SetupCount; /* 0 */
1425 __u16 ByteCount;
1426 /* __u8 Pad[3]; */
Steve French0753ca72005-10-27 13:55:12 -07001427} __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428/* Completion Filter flags for Notify */
1429#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001
1430#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002
1431#define FILE_NOTIFY_CHANGE_NAME 0x00000003
1432#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004
1433#define FILE_NOTIFY_CHANGE_SIZE 0x00000008
1434#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010
1435#define FILE_NOTIFY_CHANGE_LAST_ACCESS 0x00000020
1436#define FILE_NOTIFY_CHANGE_CREATION 0x00000040
1437#define FILE_NOTIFY_CHANGE_EA 0x00000080
1438#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100
1439#define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200
1440#define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400
1441#define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
1442
1443#define FILE_ACTION_ADDED 0x00000001
1444#define FILE_ACTION_REMOVED 0x00000002
1445#define FILE_ACTION_MODIFIED 0x00000003
1446#define FILE_ACTION_RENAMED_OLD_NAME 0x00000004
1447#define FILE_ACTION_RENAMED_NEW_NAME 0x00000005
1448#define FILE_ACTION_ADDED_STREAM 0x00000006
1449#define FILE_ACTION_REMOVED_STREAM 0x00000007
1450#define FILE_ACTION_MODIFIED_STREAM 0x00000008
1451
1452/* response contains array of the following structures */
1453struct file_notify_information {
1454 __le32 NextEntryOffset;
1455 __le32 Action;
1456 __le32 FileNameLength;
1457 __u8 FileName[0];
Steve French50c2f752007-07-13 00:33:32 +00001458} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459
1460struct reparse_data {
1461 __u32 ReparseTag;
1462 __u16 ReparseDataLength;
1463 __u16 Reserved;
1464 __u16 AltNameOffset;
1465 __u16 AltNameLen;
1466 __u16 TargetNameOffset;
1467 __u16 TargetNameLen;
1468 char LinkNamesBuf[1];
Steve French0753ca72005-10-27 13:55:12 -07001469} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470
1471struct cifs_quota_data {
1472 __u32 rsrvd1; /* 0 */
1473 __u32 sid_size;
1474 __u64 rsrvd2; /* 0 */
1475 __u64 space_used;
1476 __u64 soft_limit;
1477 __u64 hard_limit;
1478 char sid[1]; /* variable size? */
Steve French0753ca72005-10-27 13:55:12 -07001479} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480
1481/* quota sub commands */
1482#define QUOTA_LIST_CONTINUE 0
1483#define QUOTA_LIST_START 0x100
1484#define QUOTA_FOR_SID 0x101
1485
1486struct trans2_req {
1487 /* struct smb_hdr hdr precedes. Set wct = 14+ */
1488 __le16 TotalParameterCount;
1489 __le16 TotalDataCount;
1490 __le16 MaxParameterCount;
1491 __le16 MaxDataCount;
1492 __u8 MaxSetupCount;
1493 __u8 Reserved;
1494 __le16 Flags;
1495 __le32 Timeout;
1496 __u16 Reserved2;
1497 __le16 ParameterCount;
1498 __le16 ParameterOffset;
1499 __le16 DataCount;
1500 __le16 DataOffset;
1501 __u8 SetupCount;
1502 __u8 Reserved3;
1503 __le16 SubCommand; /* 1st setup word - SetupCount words follow */
1504 __le16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001505} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506
1507struct smb_t2_req {
1508 struct smb_hdr hdr;
1509 struct trans2_req t2_req;
Steve French0753ca72005-10-27 13:55:12 -07001510} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511
1512struct trans2_resp {
1513 /* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
1514 __le16 TotalParameterCount;
1515 __le16 TotalDataCount;
1516 __u16 Reserved;
1517 __le16 ParameterCount;
1518 __le16 ParameterOffset;
1519 __le16 ParameterDisplacement;
1520 __le16 DataCount;
1521 __le16 DataOffset;
1522 __le16 DataDisplacement;
1523 __u8 SetupCount;
1524 __u8 Reserved1;
1525 /* SetupWords[SetupCount];
1526 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001527 __u16 Reserved2;*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528 /* data area follows */
Steve French0753ca72005-10-27 13:55:12 -07001529} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530
1531struct smb_t2_rsp {
1532 struct smb_hdr hdr;
1533 struct trans2_resp t2_rsp;
Steve French0753ca72005-10-27 13:55:12 -07001534} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535
1536/* PathInfo/FileInfo infolevels */
1537#define SMB_INFO_STANDARD 1
1538#define SMB_SET_FILE_EA 2
1539#define SMB_QUERY_FILE_EA_SIZE 2
1540#define SMB_INFO_QUERY_EAS_FROM_LIST 3
1541#define SMB_INFO_QUERY_ALL_EAS 4
1542#define SMB_INFO_IS_NAME_VALID 6
1543#define SMB_QUERY_FILE_BASIC_INFO 0x101
1544#define SMB_QUERY_FILE_STANDARD_INFO 0x102
1545#define SMB_QUERY_FILE_EA_INFO 0x103
1546#define SMB_QUERY_FILE_NAME_INFO 0x104
1547#define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
1548#define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
1549#define SMB_QUERY_FILE_ALL_INFO 0x107
1550#define SMB_QUERY_ALT_NAME_INFO 0x108
1551#define SMB_QUERY_FILE_STREAM_INFO 0x109
1552#define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
1553#define SMB_QUERY_FILE_UNIX_BASIC 0x200
1554#define SMB_QUERY_FILE_UNIX_LINK 0x201
1555#define SMB_QUERY_POSIX_ACL 0x204
Steve French87f440e2007-02-07 00:29:46 +00001556#define SMB_QUERY_XATTR 0x205 /* e.g. system EA name space */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557#define SMB_QUERY_ATTR_FLAGS 0x206 /* append,immutable etc. */
Steve Frenchf654bac2005-04-28 22:41:04 -07001558#define SMB_QUERY_POSIX_PERMISSION 0x207
1559#define SMB_QUERY_POSIX_LOCK 0x208
Steve French87f440e2007-02-07 00:29:46 +00001560/* #define SMB_POSIX_OPEN 0x209 */
1561/* #define SMB_POSIX_UNLINK 0x20a */
1562#define SMB_QUERY_FILE__UNIX_INFO2 0x20b
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563#define SMB_QUERY_FILE_INTERNAL_INFO 0x3ee
1564#define SMB_QUERY_FILE_ACCESS_INFO 0x3f0
1565#define SMB_QUERY_FILE_NAME_INFO2 0x3f1 /* 0x30 bytes */
Steve French50c2f752007-07-13 00:33:32 +00001566#define SMB_QUERY_FILE_POSITION_INFO 0x3f6
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567#define SMB_QUERY_FILE_MODE_INFO 0x3f8
Steve French50c2f752007-07-13 00:33:32 +00001568#define SMB_QUERY_FILE_ALGN_INFO 0x3f9
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569
1570
1571#define SMB_SET_FILE_BASIC_INFO 0x101
1572#define SMB_SET_FILE_DISPOSITION_INFO 0x102
1573#define SMB_SET_FILE_ALLOCATION_INFO 0x103
1574#define SMB_SET_FILE_END_OF_FILE_INFO 0x104
1575#define SMB_SET_FILE_UNIX_BASIC 0x200
1576#define SMB_SET_FILE_UNIX_LINK 0x201
1577#define SMB_SET_FILE_UNIX_HLINK 0x203
1578#define SMB_SET_POSIX_ACL 0x204
1579#define SMB_SET_XATTR 0x205
1580#define SMB_SET_ATTR_FLAGS 0x206 /* append, immutable etc. */
Steve Frenchf654bac2005-04-28 22:41:04 -07001581#define SMB_SET_POSIX_LOCK 0x208
Steve French2fe87f02006-09-21 07:02:52 +00001582#define SMB_POSIX_OPEN 0x209
Steve French87f440e2007-02-07 00:29:46 +00001583#define SMB_POSIX_UNLINK 0x20a
Steve French2dd29d32007-04-23 22:07:35 +00001584#define SMB_SET_FILE_UNIX_INFO2 0x20b
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585#define SMB_SET_FILE_BASIC_INFO2 0x3ec
Steve French87f440e2007-02-07 00:29:46 +00001586#define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587#define SMB_FILE_ALL_INFO2 0x3fa
1588#define SMB_SET_FILE_ALLOCATION_INFO2 0x3fb
1589#define SMB_SET_FILE_END_OF_FILE_INFO2 0x3fc
1590#define SMB_FILE_MOVE_CLUSTER_INFO 0x407
1591#define SMB_FILE_QUOTA_INFO 0x408
1592#define SMB_FILE_REPARSEPOINT_INFO 0x409
1593#define SMB_FILE_MAXIMUM_INFO 0x40d
1594
1595/* Find File infolevels */
Steve French5bafd762006-06-07 00:18:43 +00001596#define SMB_FIND_FILE_INFO_STANDARD 0x001
1597#define SMB_FIND_FILE_QUERY_EA_SIZE 0x002
1598#define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
Linus Torvalds1da177e2005-04-16 15:20:36 -07001599#define SMB_FIND_FILE_DIRECTORY_INFO 0x101
1600#define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
1601#define SMB_FIND_FILE_NAMES_INFO 0x103
1602#define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
1603#define SMB_FIND_FILE_ID_FULL_DIR_INFO 0x105
1604#define SMB_FIND_FILE_ID_BOTH_DIR_INFO 0x106
1605#define SMB_FIND_FILE_UNIX 0x202
1606
1607typedef struct smb_com_transaction2_qpi_req {
1608 struct smb_hdr hdr; /* wct = 14+ */
1609 __le16 TotalParameterCount;
1610 __le16 TotalDataCount;
1611 __le16 MaxParameterCount;
1612 __le16 MaxDataCount;
1613 __u8 MaxSetupCount;
1614 __u8 Reserved;
1615 __le16 Flags;
1616 __le32 Timeout;
1617 __u16 Reserved2;
1618 __le16 ParameterCount;
1619 __le16 ParameterOffset;
1620 __le16 DataCount;
1621 __le16 DataOffset;
1622 __u8 SetupCount;
1623 __u8 Reserved3;
1624 __le16 SubCommand; /* one setup word */
1625 __le16 ByteCount;
1626 __u8 Pad;
1627 __le16 InformationLevel;
1628 __u32 Reserved4;
1629 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001630} __attribute__((packed)) TRANSACTION2_QPI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631
1632typedef struct smb_com_transaction2_qpi_rsp {
1633 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1634 struct trans2_resp t2;
1635 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001636 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001637} __attribute__((packed)) TRANSACTION2_QPI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001638
1639typedef struct smb_com_transaction2_spi_req {
1640 struct smb_hdr hdr; /* wct = 15 */
1641 __le16 TotalParameterCount;
1642 __le16 TotalDataCount;
1643 __le16 MaxParameterCount;
1644 __le16 MaxDataCount;
1645 __u8 MaxSetupCount;
1646 __u8 Reserved;
1647 __le16 Flags;
1648 __le32 Timeout;
1649 __u16 Reserved2;
1650 __le16 ParameterCount;
1651 __le16 ParameterOffset;
1652 __le16 DataCount;
1653 __le16 DataOffset;
1654 __u8 SetupCount;
1655 __u8 Reserved3;
1656 __le16 SubCommand; /* one setup word */
1657 __le16 ByteCount;
1658 __u8 Pad;
1659 __u16 Pad1;
1660 __le16 InformationLevel;
1661 __u32 Reserved4;
1662 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001663} __attribute__((packed)) TRANSACTION2_SPI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664
1665typedef struct smb_com_transaction2_spi_rsp {
1666 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1667 struct trans2_resp t2;
1668 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001669 __u16 Reserved2; /* parameter word is present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001670} __attribute__((packed)) TRANSACTION2_SPI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671
1672struct set_file_rename {
1673 __le32 overwrite; /* 1 = overwrite dest */
1674 __u32 root_fid; /* zero */
1675 __le32 target_name_len;
1676 char target_name[0]; /* Must be unicode */
Steve French0753ca72005-10-27 13:55:12 -07001677} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678
1679struct smb_com_transaction2_sfi_req {
1680 struct smb_hdr hdr; /* wct = 15 */
1681 __le16 TotalParameterCount;
1682 __le16 TotalDataCount;
1683 __le16 MaxParameterCount;
1684 __le16 MaxDataCount;
1685 __u8 MaxSetupCount;
1686 __u8 Reserved;
1687 __le16 Flags;
1688 __le32 Timeout;
1689 __u16 Reserved2;
1690 __le16 ParameterCount;
1691 __le16 ParameterOffset;
1692 __le16 DataCount;
1693 __le16 DataOffset;
1694 __u8 SetupCount;
1695 __u8 Reserved3;
1696 __le16 SubCommand; /* one setup word */
1697 __le16 ByteCount;
1698 __u8 Pad;
1699 __u16 Pad1;
1700 __u16 Fid;
1701 __le16 InformationLevel;
Steve French50c2f752007-07-13 00:33:32 +00001702 __u16 Reserved4;
Steve French0753ca72005-10-27 13:55:12 -07001703} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704
1705struct smb_com_transaction2_sfi_rsp {
1706 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1707 struct trans2_resp t2;
1708 __u16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001709 __u16 Reserved2; /* parameter word reserved -
Steve Frenchf654bac2005-04-28 22:41:04 -07001710 present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001711} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712
Steve Frenchf654bac2005-04-28 22:41:04 -07001713struct smb_t2_qfi_req {
Steve French50c2f752007-07-13 00:33:32 +00001714 struct smb_hdr hdr;
1715 struct trans2_req t2;
Steve Frenchf654bac2005-04-28 22:41:04 -07001716 __u8 Pad;
Steve Frenchf654bac2005-04-28 22:41:04 -07001717 __u16 Fid;
1718 __le16 InformationLevel;
Steve French0753ca72005-10-27 13:55:12 -07001719} __attribute__((packed));
Steve Frenchf654bac2005-04-28 22:41:04 -07001720
1721struct smb_t2_qfi_rsp {
Steve French50c2f752007-07-13 00:33:32 +00001722 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1723 struct trans2_resp t2;
1724 __u16 ByteCount;
1725 __u16 Reserved2; /* parameter word reserved -
1726 present for infolevels > 100 */
Steve French0753ca72005-10-27 13:55:12 -07001727} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728
1729/*
Steve French50c2f752007-07-13 00:33:32 +00001730 * Flags on T2 FINDFIRST and FINDNEXT
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 */
1732#define CIFS_SEARCH_CLOSE_ALWAYS 0x0001
1733#define CIFS_SEARCH_CLOSE_AT_END 0x0002
1734#define CIFS_SEARCH_RETURN_RESUME 0x0004
1735#define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
1736#define CIFS_SEARCH_BACKUP_SEARCH 0x0010
1737
1738/*
1739 * Size of the resume key on FINDFIRST and FINDNEXT calls
1740 */
1741#define CIFS_SMB_RESUME_KEY_SIZE 4
1742
1743typedef struct smb_com_transaction2_ffirst_req {
1744 struct smb_hdr hdr; /* wct = 15 */
1745 __le16 TotalParameterCount;
1746 __le16 TotalDataCount;
1747 __le16 MaxParameterCount;
1748 __le16 MaxDataCount;
1749 __u8 MaxSetupCount;
1750 __u8 Reserved;
1751 __le16 Flags;
1752 __le32 Timeout;
1753 __u16 Reserved2;
1754 __le16 ParameterCount;
1755 __le16 ParameterOffset;
1756 __le16 DataCount;
1757 __le16 DataOffset;
1758 __u8 SetupCount; /* one */
1759 __u8 Reserved3;
1760 __le16 SubCommand; /* TRANS2_FIND_FIRST */
1761 __le16 ByteCount;
1762 __u8 Pad;
1763 __le16 SearchAttributes;
1764 __le16 SearchCount;
1765 __le16 SearchFlags;
1766 __le16 InformationLevel;
1767 __le32 SearchStorageType;
1768 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001769} __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770
1771typedef struct smb_com_transaction2_ffirst_rsp {
1772 struct smb_hdr hdr; /* wct = 10 */
1773 struct trans2_resp t2;
1774 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001775} __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001776
1777typedef struct smb_com_transaction2_ffirst_rsp_parms {
1778 __u16 SearchHandle;
1779 __le16 SearchCount;
1780 __le16 EndofSearch;
1781 __le16 EAErrorOffset;
1782 __le16 LastNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001783} __attribute__((packed)) T2_FFIRST_RSP_PARMS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784
1785typedef struct smb_com_transaction2_fnext_req {
1786 struct smb_hdr hdr; /* wct = 15 */
1787 __le16 TotalParameterCount;
1788 __le16 TotalDataCount;
1789 __le16 MaxParameterCount;
1790 __le16 MaxDataCount;
1791 __u8 MaxSetupCount;
1792 __u8 Reserved;
1793 __le16 Flags;
1794 __le32 Timeout;
1795 __u16 Reserved2;
1796 __le16 ParameterCount;
1797 __le16 ParameterOffset;
1798 __le16 DataCount;
1799 __le16 DataOffset;
1800 __u8 SetupCount; /* one */
1801 __u8 Reserved3;
1802 __le16 SubCommand; /* TRANS2_FIND_NEXT */
1803 __le16 ByteCount;
1804 __u8 Pad;
1805 __u16 SearchHandle;
1806 __le16 SearchCount;
1807 __le16 InformationLevel;
1808 __u32 ResumeKey;
1809 __le16 SearchFlags;
1810 char ResumeFileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001811} __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812
1813typedef struct smb_com_transaction2_fnext_rsp {
1814 struct smb_hdr hdr; /* wct = 10 */
1815 struct trans2_resp t2;
1816 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001817} __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818
1819typedef struct smb_com_transaction2_fnext_rsp_parms {
1820 __le16 SearchCount;
1821 __le16 EndofSearch;
1822 __le16 EAErrorOffset;
1823 __le16 LastNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07001824} __attribute__((packed)) T2_FNEXT_RSP_PARMS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825
1826/* QFSInfo Levels */
1827#define SMB_INFO_ALLOCATION 1
1828#define SMB_INFO_VOLUME 2
1829#define SMB_QUERY_FS_VOLUME_INFO 0x102
1830#define SMB_QUERY_FS_SIZE_INFO 0x103
1831#define SMB_QUERY_FS_DEVICE_INFO 0x104
1832#define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
1833#define SMB_QUERY_CIFS_UNIX_INFO 0x200
1834#define SMB_QUERY_POSIX_FS_INFO 0x201
Steve French87f440e2007-02-07 00:29:46 +00001835#define SMB_QUERY_POSIX_WHO_AM_I 0x202
Steve Frenchee4987a2008-04-24 16:31:12 +00001836#define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
1837#define SMB_QUERY_FS_PROXY 0x204 /* WAFS enabled. Returns structure
Steve French2302aca2008-04-18 16:40:32 +00001838 FILE_SYSTEM__UNIX_INFO to tell
1839 whether new NTIOCTL available
1840 (0xACE) for WAN friendly SMB
1841 operations to be carried */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842#define SMB_QUERY_LABEL_INFO 0x3ea
1843#define SMB_QUERY_FS_QUOTA_INFO 0x3ee
1844#define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
1845#define SMB_QUERY_OBJECTID_INFO 0x3f0
1846
1847typedef struct smb_com_transaction2_qfsi_req {
1848 struct smb_hdr hdr; /* wct = 14+ */
1849 __le16 TotalParameterCount;
1850 __le16 TotalDataCount;
1851 __le16 MaxParameterCount;
1852 __le16 MaxDataCount;
1853 __u8 MaxSetupCount;
1854 __u8 Reserved;
1855 __le16 Flags;
1856 __le32 Timeout;
1857 __u16 Reserved2;
1858 __le16 ParameterCount;
1859 __le16 ParameterOffset;
1860 __le16 DataCount;
1861 __le16 DataOffset;
1862 __u8 SetupCount;
1863 __u8 Reserved3;
1864 __le16 SubCommand; /* one setup word */
1865 __le16 ByteCount;
1866 __u8 Pad;
1867 __le16 InformationLevel;
Steve French0753ca72005-10-27 13:55:12 -07001868} __attribute__((packed)) TRANSACTION2_QFSI_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869
1870typedef struct smb_com_transaction_qfsi_rsp {
1871 struct smb_hdr hdr; /* wct = 10 + SetupCount */
1872 struct trans2_resp t2;
1873 __u16 ByteCount;
Steve French87f440e2007-02-07 00:29:46 +00001874 __u8 Pad; /* may be three bytes? *//* followed by data area */
Steve French0753ca72005-10-27 13:55:12 -07001875} __attribute__((packed)) TRANSACTION2_QFSI_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876
Steve French87f440e2007-02-07 00:29:46 +00001877typedef struct whoami_rsp_data { /* Query level 0x202 */
1878 __u32 flags; /* 0 = Authenticated user 1 = GUEST */
1879 __u32 mask; /* which flags bits server understands ie 0x0001 */
1880 __u64 unix_user_id;
1881 __u64 unix_user_gid;
1882 __u32 number_of_supplementary_gids; /* may be zero */
1883 __u32 number_of_sids; /* may be zero */
1884 __u32 length_of_sid_array; /* in bytes - may be zero */
1885 __u32 pad; /* reserved - MBZ */
1886 /* __u64 gid_array[0]; */ /* may be empty */
1887 /* __u8 * psid_list */ /* may be empty */
1888} __attribute__((packed)) WHOAMI_RSP_DATA;
Jeremy Allisonac670552005-06-22 17:26:35 -07001889
1890/* SETFSInfo Levels */
1891#define SMB_SET_CIFS_UNIX_INFO 0x200
1892typedef struct smb_com_transaction2_setfsi_req {
1893 struct smb_hdr hdr; /* wct = 15 */
1894 __le16 TotalParameterCount;
1895 __le16 TotalDataCount;
1896 __le16 MaxParameterCount;
1897 __le16 MaxDataCount;
1898 __u8 MaxSetupCount;
1899 __u8 Reserved;
1900 __le16 Flags;
1901 __le32 Timeout;
1902 __u16 Reserved2;
1903 __le16 ParameterCount; /* 4 */
1904 __le16 ParameterOffset;
1905 __le16 DataCount; /* 12 */
1906 __le16 DataOffset;
1907 __u8 SetupCount; /* one */
1908 __u8 Reserved3;
1909 __le16 SubCommand; /* TRANS2_SET_FS_INFORMATION */
1910 __le16 ByteCount;
1911 __u8 Pad;
1912 __u16 FileNum; /* Parameters start. */
1913 __le16 InformationLevel;/* Parameters end. */
1914 __le16 ClientUnixMajor; /* Data start. */
1915 __le16 ClientUnixMinor;
1916 __le64 ClientUnixCap; /* Data end */
Steve French0753ca72005-10-27 13:55:12 -07001917} __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
Jeremy Allisonac670552005-06-22 17:26:35 -07001918
1919typedef struct smb_com_transaction2_setfsi_rsp {
1920 struct smb_hdr hdr; /* wct = 10 */
1921 struct trans2_resp t2;
1922 __u16 ByteCount;
Steve French0753ca72005-10-27 13:55:12 -07001923} __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
Jeremy Allisonac670552005-06-22 17:26:35 -07001924
1925
Linus Torvalds1da177e2005-04-16 15:20:36 -07001926typedef struct smb_com_transaction2_get_dfs_refer_req {
1927 struct smb_hdr hdr; /* wct = 15 */
1928 __le16 TotalParameterCount;
1929 __le16 TotalDataCount;
1930 __le16 MaxParameterCount;
1931 __le16 MaxDataCount;
1932 __u8 MaxSetupCount;
1933 __u8 Reserved;
1934 __le16 Flags;
1935 __le32 Timeout;
1936 __u16 Reserved2;
1937 __le16 ParameterCount;
1938 __le16 ParameterOffset;
1939 __le16 DataCount;
1940 __le16 DataOffset;
1941 __u8 SetupCount;
1942 __u8 Reserved3;
1943 __le16 SubCommand; /* one setup word */
1944 __le16 ByteCount;
Steve French50c2f752007-07-13 00:33:32 +00001945 __u8 Pad[3]; /* Win2K has sent 0x0F01 (max response length
1946 perhaps?) followed by one byte pad - doesn't
1947 seem to matter though */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001948 __le16 MaxReferralLevel;
1949 char RequestFileName[1];
Steve French0753ca72005-10-27 13:55:12 -07001950} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001951
Steve Frencha1fe78f2008-05-16 18:48:38 +00001952#define DFS_VERSION cpu_to_le16(0x0003)
1953
1954/* DFS server target type */
1955#define DFS_TYPE_LINK 0x0000 /* also for sysvol targets */
1956#define DFS_TYPE_ROOT 0x0001
Steve French61e74802008-12-03 00:57:54 +00001957
Steve Frencha1fe78f2008-05-16 18:48:38 +00001958/* Referral Entry Flags */
Steve French10e70af2009-02-22 01:33:07 +00001959#define DFS_NAME_LIST_REF 0x0200 /* set for domain or DC referral responses */
1960#define DFS_TARGET_SET_BOUNDARY 0x0400 /* only valid with version 4 dfs req */
Steve Frencha1fe78f2008-05-16 18:48:38 +00001961
Steve French10e70af2009-02-22 01:33:07 +00001962typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */
1963 __le16 VersionNumber; /* must be 3 or 4 */
Igor Mammedovfec45852008-05-16 13:06:30 +04001964 __le16 Size;
1965 __le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */
Steve French10e70af2009-02-22 01:33:07 +00001966 __le16 ReferralEntryFlags;
Igor Mammedovfec45852008-05-16 13:06:30 +04001967 __le32 TimeToLive;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 __le16 DfsPathOffset;
1969 __le16 DfsAlternatePathOffset;
Igor Mammedovfec45852008-05-16 13:06:30 +04001970 __le16 NetworkAddressOffset; /* offset of the link target */
Steve French10e70af2009-02-22 01:33:07 +00001971 __u8 ServiceSiteGuid[16]; /* MBZ, ignored */
Steve French0753ca72005-10-27 13:55:12 -07001972} __attribute__((packed)) REFERRAL3;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973
1974typedef struct smb_com_transaction_get_dfs_refer_rsp {
1975 struct smb_hdr hdr; /* wct = 10 */
1976 struct trans2_resp t2;
1977 __u16 ByteCount;
1978 __u8 Pad;
1979 __le16 PathConsumed;
1980 __le16 NumberOfReferrals;
Steve French10e70af2009-02-22 01:33:07 +00001981 __le32 DFSFlags;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001982 REFERRAL3 referrals[1]; /* array of level 3 dfs_referral structures */
1983 /* followed by the strings pointed to by the referral structures */
Steve French0753ca72005-10-27 13:55:12 -07001984} __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985
1986/* DFS Flags */
Steve French10e70af2009-02-22 01:33:07 +00001987#define DFSREF_REFERRAL_SERVER 0x00000001 /* all targets are DFS roots */
1988#define DFSREF_STORAGE_SERVER 0x00000002 /* no further ref requests needed */
1989#define DFSREF_TARGET_FAILBACK 0x00000004 /* only for DFS referral version 4 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991/*
1992 ************************************************************************
1993 * All structs for everything above the SMB PDUs themselves
Steve French50c2f752007-07-13 00:33:32 +00001994 * (such as the T2 level specific data) go here
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995 ************************************************************************
1996 */
1997
1998/*
1999 * Information on a server
2000 */
2001
2002struct serverInfo {
2003 char name[16];
2004 unsigned char versionMajor;
2005 unsigned char versionMinor;
2006 unsigned long type;
2007 unsigned int commentOffset;
Steve French0753ca72005-10-27 13:55:12 -07002008} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009
2010/*
2011 * The following structure is the format of the data returned on a NetShareEnum
2012 * with level "90" (x5A)
2013 */
2014
2015struct shareInfo {
2016 char shareName[13];
2017 char pad;
2018 unsigned short type;
2019 unsigned int commentOffset;
Steve French0753ca72005-10-27 13:55:12 -07002020} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021
2022struct aliasInfo {
2023 char aliasName[9];
2024 char pad;
2025 unsigned int commentOffset;
2026 unsigned char type[2];
Steve French0753ca72005-10-27 13:55:12 -07002027} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028
2029struct aliasInfo92 {
2030 int aliasNameOffset;
2031 int serverNameOffset;
2032 int shareNameOffset;
Steve French0753ca72005-10-27 13:55:12 -07002033} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034
2035typedef struct {
2036 __le64 TotalAllocationUnits;
2037 __le64 FreeAllocationUnits;
2038 __le32 SectorsPerAllocationUnit;
2039 __le32 BytesPerSector;
Steve French50c2f752007-07-13 00:33:32 +00002040} __attribute__((packed)) FILE_SYSTEM_INFO; /* size info, level 0x103 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002041
2042typedef struct {
Steve French20962432005-09-21 22:05:57 -07002043 __le32 fsid;
2044 __le32 SectorsPerAllocationUnit;
2045 __le32 TotalAllocationUnits;
2046 __le32 FreeAllocationUnits;
2047 __le16 BytesPerSector;
Steve French0753ca72005-10-27 13:55:12 -07002048} __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
Steve French20962432005-09-21 22:05:57 -07002049
2050typedef struct {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051 __le16 MajorVersionNumber;
2052 __le16 MinorVersionNumber;
2053 __le64 Capability;
Steve French50c2f752007-07-13 00:33:32 +00002054} __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/
Jeremy Allisonac670552005-06-22 17:26:35 -07002055
2056/* Version numbers for CIFS UNIX major and minor. */
2057#define CIFS_UNIX_MAJOR_VERSION 1
2058#define CIFS_UNIX_MINOR_VERSION 0
2059
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060/* Linux/Unix extensions capability flags */
2061#define CIFS_UNIX_FCNTL_CAP 0x00000001 /* support for fcntl locks */
Steve Frenchf654bac2005-04-28 22:41:04 -07002062#define CIFS_UNIX_POSIX_ACL_CAP 0x00000002 /* support getfacl/setfacl */
2063#define CIFS_UNIX_XATTR_CAP 0x00000004 /* support new namespace */
2064#define CIFS_UNIX_EXTATTR_CAP 0x00000008 /* support chattr/chflag */
Steve French82940a42006-03-02 03:24:57 +00002065#define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x00000010 /* Allow POSIX path chars */
Steve French87f440e2007-02-07 00:29:46 +00002066#define CIFS_UNIX_POSIX_PATH_OPS_CAP 0x00000020 /* Allow new POSIX path based
2067 calls including posix open
Steve French75865f8c2007-06-24 18:30:48 +00002068 and posix unlink */
2069#define CIFS_UNIX_LARGE_READ_CAP 0x00000040 /* support reads >128K (up
Steve French50c2f752007-07-13 00:33:32 +00002070 to 0xFFFF00 */
Steve French75865f8c2007-06-24 18:30:48 +00002071#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
Steve Frencha7f796a2008-04-24 16:39:07 +00002072#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
Steve French0206e612008-04-25 18:19:40 +00002073#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */
Steve Frenchee4987a2008-04-24 16:31:12 +00002074#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and
Steve French2302aca2008-04-18 16:40:32 +00002075 QFS PROXY call */
Steve French82940a42006-03-02 03:24:57 +00002076#ifdef CONFIG_CIFS_POSIX
Steve French38e2aff2007-03-16 05:12:53 +00002077/* Can not set pathnames cap yet until we send new posix create SMB since
2078 otherwise server can treat such handles opened with older ntcreatex
2079 (by a new client which knows how to send posix path ops)
2080 as non-posix handles (can affect write behavior with byte range locks.
2081 We can add back in POSIX_PATH_OPS cap when Posix Create/Mkdir finished */
Steve French75865f8c2007-06-24 18:30:48 +00002082/* #define CIFS_UNIX_CAP_MASK 0x000000fb */
Steve French50c2f752007-07-13 00:33:32 +00002083#define CIFS_UNIX_CAP_MASK 0x000000db
2084#else
Steve French82940a42006-03-02 03:24:57 +00002085#define CIFS_UNIX_CAP_MASK 0x00000013
2086#endif /* CONFIG_CIFS_POSIX */
2087
Jeremy Allisonac670552005-06-22 17:26:35 -07002088
Steve Frenchf28ac912005-04-28 22:41:07 -07002089#define CIFS_POSIX_EXTENSIONS 0x00000010 /* support for new QFSInfo */
Jeremy Allisonac670552005-06-22 17:26:35 -07002090
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091typedef struct {
2092 /* For undefined recommended transfer size return -1 in that field */
2093 __le32 OptimalTransferSize; /* bsize on some os, iosize on other os */
Steve French50c2f752007-07-13 00:33:32 +00002094 __le32 BlockSize;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 /* The next three fields are in terms of the block size.
2096 (above). If block size is unknown, 4096 would be a
Steve French50c2f752007-07-13 00:33:32 +00002097 reasonable block size for a server to report.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 Note that returning the blocks/blocksavail removes need
2099 to make a second call (to QFSInfo level 0x103 to get this info.
2100 UserBlockAvail is typically less than or equal to BlocksAvail,
2101 if no distinction is made return the same value in each */
2102 __le64 TotalBlocks;
2103 __le64 BlocksAvail; /* bfree */
2104 __le64 UserBlocksAvail; /* bavail */
2105 /* For undefined Node fields or FSID return -1 */
2106 __le64 TotalFileNodes;
2107 __le64 FreeFileNodes;
2108 __le64 FileSysIdentifier; /* fsid */
2109 /* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
2110 /* NB flags can come from FILE_SYSTEM_DEVICE_INFO call */
Steve French0753ca72005-10-27 13:55:12 -07002111} __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112
2113/* DeviceType Flags */
2114#define FILE_DEVICE_CD_ROM 0x00000002
2115#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
2116#define FILE_DEVICE_DFS 0x00000006
2117#define FILE_DEVICE_DISK 0x00000007
2118#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
2119#define FILE_DEVICE_FILE_SYSTEM 0x00000009
2120#define FILE_DEVICE_NAMED_PIPE 0x00000011
2121#define FILE_DEVICE_NETWORK 0x00000012
2122#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
2123#define FILE_DEVICE_NULL 0x00000015
2124#define FILE_DEVICE_PARALLEL_PORT 0x00000016
2125#define FILE_DEVICE_PRINTER 0x00000018
2126#define FILE_DEVICE_SERIAL_PORT 0x0000001b
2127#define FILE_DEVICE_STREAMS 0x0000001e
2128#define FILE_DEVICE_TAPE 0x0000001f
2129#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
2130#define FILE_DEVICE_VIRTUAL_DISK 0x00000024
2131#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
2132
2133typedef struct {
2134 __le32 DeviceType;
2135 __le32 DeviceCharacteristics;
Steve French39798772006-05-31 22:40:51 +00002136} __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137
2138typedef struct {
2139 __le32 Attributes;
2140 __le32 MaxPathNameComponentLength;
2141 __le32 FileSystemNameLen;
Steve French39798772006-05-31 22:40:51 +00002142 char FileSystemName[52]; /* do not have to save this - get subset? */
Steve French0753ca72005-10-27 13:55:12 -07002143} __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144
2145/******************************************************************************/
2146/* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
2147/******************************************************************************/
2148typedef struct { /* data block encoding of response to level 263 QPathInfo */
2149 __le64 CreationTime;
2150 __le64 LastAccessTime;
2151 __le64 LastWriteTime;
2152 __le64 ChangeTime;
2153 __le32 Attributes;
2154 __u32 Pad1;
2155 __le64 AllocationSize;
2156 __le64 EndOfFile; /* size ie offset to first free byte in file */
2157 __le32 NumberOfLinks; /* hard links */
2158 __u8 DeletePending;
2159 __u8 Directory;
2160 __u16 Pad2;
2161 __u64 IndexNumber;
2162 __le32 EASize;
2163 __le32 AccessFlags;
2164 __u64 IndexNumber1;
2165 __le64 CurrentByteOffset;
2166 __le32 Mode;
2167 __le32 AlignmentRequirement;
2168 __le32 FileNameLength;
2169 char FileName[1];
Steve French87f440e2007-02-07 00:29:46 +00002170} __attribute__((packed)) FILE_ALL_INFO; /* level 0x107 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171
2172/* defines for enumerating possible values of the Unix type field below */
2173#define UNIX_FILE 0
2174#define UNIX_DIR 1
2175#define UNIX_SYMLINK 2
2176#define UNIX_CHARDEV 3
2177#define UNIX_BLOCKDEV 4
2178#define UNIX_FIFO 5
2179#define UNIX_SOCKET 6
2180typedef struct {
2181 __le64 EndOfFile;
2182 __le64 NumOfBytes;
2183 __le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
2184 __le64 LastAccessTime;
2185 __le64 LastModificationTime;
2186 __le64 Uid;
2187 __le64 Gid;
2188 __le32 Type;
2189 __le64 DevMajor;
2190 __le64 DevMinor;
Steve French85a6dac2009-04-01 05:22:00 +00002191 __le64 UniqueId;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192 __le64 Permissions;
2193 __le64 Nlinks;
Steve French87f440e2007-02-07 00:29:46 +00002194} __attribute__((packed)) FILE_UNIX_BASIC_INFO; /* level 0x200 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195
2196typedef struct {
2197 char LinkDest[1];
Steve French87f440e2007-02-07 00:29:46 +00002198} __attribute__((packed)) FILE_UNIX_LINK_INFO; /* level 0x201 QPathInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199
2200/* The following three structures are needed only for
2201 setting time to NT4 and some older servers via
2202 the primitive DOS time format */
2203typedef struct {
2204 __u16 Day:5;
2205 __u16 Month:4;
2206 __u16 Year:7;
Steve French0753ca72005-10-27 13:55:12 -07002207} __attribute__((packed)) SMB_DATE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208
2209typedef struct {
2210 __u16 TwoSeconds:5;
2211 __u16 Minutes:6;
2212 __u16 Hours:5;
Steve French0753ca72005-10-27 13:55:12 -07002213} __attribute__((packed)) SMB_TIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002214
2215typedef struct {
2216 __le16 CreationDate; /* SMB Date see above */
2217 __le16 CreationTime; /* SMB Time */
2218 __le16 LastAccessDate;
2219 __le16 LastAccessTime;
2220 __le16 LastWriteDate;
2221 __le16 LastWriteTime;
2222 __le32 DataSize; /* File Size (EOF) */
2223 __le32 AllocationSize;
2224 __le16 Attributes; /* verify not u32 */
2225 __le32 EASize;
Steve French0753ca72005-10-27 13:55:12 -07002226} __attribute__((packed)) FILE_INFO_STANDARD; /* level 1 SetPath/FileInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227
2228typedef struct {
2229 __le64 CreationTime;
2230 __le64 LastAccessTime;
2231 __le64 LastWriteTime;
2232 __le64 ChangeTime;
2233 __le32 Attributes;
2234 __u32 Pad;
Steve French87f440e2007-02-07 00:29:46 +00002235} __attribute__((packed)) FILE_BASIC_INFO; /* size info, level 0x101 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236
2237struct file_allocation_info {
2238 __le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
Steve French5bafd762006-06-07 00:18:43 +00002239} __attribute__((packed)); /* size used on disk, for level 0x103 for set,
2240 0x105 for query */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241
2242struct file_end_of_file_info {
2243 __le64 FileSize; /* offset to end of file */
Steve French87f440e2007-02-07 00:29:46 +00002244} __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245
2246struct file_alt_name_info {
2247 __u8 alt_name[1];
Steve French0753ca72005-10-27 13:55:12 -07002248} __attribute__((packed)); /* level 0x0108 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249
2250struct file_stream_info {
2251 __le32 number_of_streams; /* BB check sizes and verify location */
Steve French50c2f752007-07-13 00:33:32 +00002252 /* followed by info on streams themselves
Linus Torvalds1da177e2005-04-16 15:20:36 -07002253 u64 size;
Steve French50c2f752007-07-13 00:33:32 +00002254 u64 allocation_size
Linus Torvalds1da177e2005-04-16 15:20:36 -07002255 stream info */
2256}; /* level 0x109 */
2257
2258struct file_compression_info {
2259 __le64 compressed_size;
2260 __le16 format;
2261 __u8 unit_shift;
2262 __u8 ch_shift;
2263 __u8 cl_shift;
2264 __u8 pad[3];
Steve French0753ca72005-10-27 13:55:12 -07002265} __attribute__((packed)); /* level 0x10b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266
2267/* POSIX ACL set/query path info structures */
2268#define CIFS_ACL_VERSION 1
2269struct cifs_posix_ace { /* access control entry (ACE) */
2270 __u8 cifs_e_tag;
2271 __u8 cifs_e_perm;
2272 __le64 cifs_uid; /* or gid */
Steve French50c2f752007-07-13 00:33:32 +00002273} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274
2275struct cifs_posix_acl { /* access conrol list (ACL) */
2276 __le16 version;
2277 __le16 access_entry_count; /* access ACL - count of entries */
2278 __le16 default_entry_count; /* default ACL - count of entries */
2279 struct cifs_posix_ace ace_array[0];
2280 /* followed by
2281 struct cifs_posix_ace default_ace_arraay[] */
Steve French0753ca72005-10-27 13:55:12 -07002282} __attribute__((packed)); /* level 0x204 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283
2284/* types of access control entries already defined in posix_acl.h */
2285/* #define CIFS_POSIX_ACL_USER_OBJ 0x01
2286#define CIFS_POSIX_ACL_USER 0x02
2287#define CIFS_POSIX_ACL_GROUP_OBJ 0x04
2288#define CIFS_POSIX_ACL_GROUP 0x08
2289#define CIFS_POSIX_ACL_MASK 0x10
2290#define CIFS_POSIX_ACL_OTHER 0x20 */
2291
2292/* types of perms */
2293/* #define CIFS_POSIX_ACL_EXECUTE 0x01
2294#define CIFS_POSIX_ACL_WRITE 0x02
2295#define CIFS_POSIX_ACL_READ 0x04 */
2296
2297/* end of POSIX ACL definitions */
2298
Steve French2dd29d32007-04-23 22:07:35 +00002299/* POSIX Open Flags */
2300#define SMB_O_RDONLY 0x1
2301#define SMB_O_WRONLY 0x2
2302#define SMB_O_RDWR 0x4
2303#define SMB_O_CREAT 0x10
2304#define SMB_O_EXCL 0x20
2305#define SMB_O_TRUNC 0x40
2306#define SMB_O_APPEND 0x80
2307#define SMB_O_SYNC 0x100
2308#define SMB_O_DIRECTORY 0x200
2309#define SMB_O_NOFOLLOW 0x400
2310#define SMB_O_DIRECT 0x800
2311
Steve French595dcfe2007-02-08 18:11:42 +00002312typedef struct {
Steve French2dd29d32007-04-23 22:07:35 +00002313 __le32 OpenFlags; /* same as NT CreateX */
2314 __le32 PosixOpenFlags;
2315 __le64 Permissions;
2316 __le16 Level; /* reply level requested (see QPathInfo levels) */
Steve French595dcfe2007-02-08 18:11:42 +00002317} __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
2318
2319typedef struct {
Steve French2dd29d32007-04-23 22:07:35 +00002320 __le16 OplockFlags;
2321 __u16 Fid;
2322 __le32 CreateAction;
2323 __le16 ReturnedLevel;
2324 __le16 Pad;
2325 /* struct following varies based on requested level */
Steve French8af18972007-02-14 04:42:51 +00002326} __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
Steve French595dcfe2007-02-08 18:11:42 +00002327
Steve French2d785a52007-07-15 01:48:57 +00002328#define SMB_POSIX_UNLINK_FILE_TARGET 0
2329#define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
2330
2331struct unlink_psx_rq { /* level 0x20a SetPathInfo */
2332 __le16 type;
2333} __attribute__((packed));
Steve French595dcfe2007-02-08 18:11:42 +00002334
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335struct file_internal_info {
Steve French85a6dac2009-04-01 05:22:00 +00002336 __le64 UniqueId; /* inode number */
Steve French0753ca72005-10-27 13:55:12 -07002337} __attribute__((packed)); /* level 0x3ee */
Steve French2dd29d32007-04-23 22:07:35 +00002338
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339struct file_mode_info {
2340 __le32 Mode;
Steve French0753ca72005-10-27 13:55:12 -07002341} __attribute__((packed)); /* level 0x3f8 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342
2343struct file_attrib_tag {
2344 __le32 Attribute;
2345 __le32 ReparseTag;
Steve French0753ca72005-10-27 13:55:12 -07002346} __attribute__((packed)); /* level 0x40b */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347
2348
2349/********************************************************/
Steve French50c2f752007-07-13 00:33:32 +00002350/* FindFirst/FindNext transact2 data buffer formats */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351/********************************************************/
2352
2353typedef struct {
2354 __le32 NextEntryOffset;
2355 __u32 ResumeKey; /* as with FileIndex - no need to convert */
Jeff Laytoncc0bad72009-06-25 00:56:52 -04002356 FILE_UNIX_BASIC_INFO basic;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 char FileName[1];
Steve French0753ca72005-10-27 13:55:12 -07002358} __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002359
2360typedef struct {
2361 __le32 NextEntryOffset;
2362 __u32 FileIndex;
2363 __le64 CreationTime;
2364 __le64 LastAccessTime;
2365 __le64 LastWriteTime;
2366 __le64 ChangeTime;
2367 __le64 EndOfFile;
2368 __le64 AllocationSize;
2369 __le32 ExtFileAttributes;
2370 __le32 FileNameLength;
2371 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002372} __attribute__((packed)) FILE_DIRECTORY_INFO; /* level 0x101 FF resp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002373
2374typedef struct {
2375 __le32 NextEntryOffset;
2376 __u32 FileIndex;
2377 __le64 CreationTime;
2378 __le64 LastAccessTime;
2379 __le64 LastWriteTime;
2380 __le64 ChangeTime;
2381 __le64 EndOfFile;
2382 __le64 AllocationSize;
2383 __le32 ExtFileAttributes;
2384 __le32 FileNameLength;
2385 __le32 EaSize; /* length of the xattrs */
2386 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002387} __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388
2389typedef struct {
2390 __le32 NextEntryOffset;
2391 __u32 FileIndex;
2392 __le64 CreationTime;
2393 __le64 LastAccessTime;
2394 __le64 LastWriteTime;
2395 __le64 ChangeTime;
2396 __le64 EndOfFile;
2397 __le64 AllocationSize;
2398 __le32 ExtFileAttributes;
2399 __le32 FileNameLength;
2400 __le32 EaSize; /* EA size */
2401 __le32 Reserved;
Steve French85a6dac2009-04-01 05:22:00 +00002402 __le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002404} __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405
2406typedef struct {
2407 __le32 NextEntryOffset;
2408 __u32 FileIndex;
2409 __le64 CreationTime;
2410 __le64 LastAccessTime;
2411 __le64 LastWriteTime;
2412 __le64 ChangeTime;
2413 __le64 EndOfFile;
2414 __le64 AllocationSize;
2415 __le32 ExtFileAttributes;
Steve French50c2f752007-07-13 00:33:32 +00002416 __le32 FileNameLength;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 __le32 EaSize; /* length of the xattrs */
2418 __u8 ShortNameLength;
2419 __u8 Reserved;
2420 __u8 ShortName[12];
2421 char FileName[1];
Steve French5bafd762006-06-07 00:18:43 +00002422} __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
2423
2424typedef struct {
2425 __u32 ResumeKey;
2426 __le16 CreationDate; /* SMB Date */
2427 __le16 CreationTime; /* SMB Time */
2428 __le16 LastAccessDate;
2429 __le16 LastAccessTime;
2430 __le16 LastWriteDate;
2431 __le16 LastWriteTime;
2432 __le32 DataSize; /* File Size (EOF) */
2433 __le32 AllocationSize;
2434 __le16 Attributes; /* verify not u32 */
2435 __u8 FileNameLength;
2436 char FileName[1];
2437} __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438
2439
Steve French86c96b42005-11-18 20:25:31 -08002440struct win_dev {
2441 unsigned char type[8]; /* IntxCHR or IntxBLK */
2442 __le64 major;
Steve French50c2f752007-07-13 00:33:32 +00002443 __le64 minor;
Steve French86c96b42005-11-18 20:25:31 -08002444} __attribute__((packed));
2445
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446struct gea {
2447 unsigned char name_len;
2448 char name[1];
Steve French0753ca72005-10-27 13:55:12 -07002449} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450
2451struct gealist {
2452 unsigned long list_len;
2453 struct gea list[1];
Steve French0753ca72005-10-27 13:55:12 -07002454} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455
2456struct fea {
2457 unsigned char EA_flags;
2458 __u8 name_len;
2459 __le16 value_len;
2460 char name[1];
2461 /* optionally followed by value */
Steve French0753ca72005-10-27 13:55:12 -07002462} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463/* flags for _FEA.fEA */
2464#define FEA_NEEDEA 0x80 /* need EA bit */
2465
2466struct fealist {
2467 __le32 list_len;
2468 struct fea list[1];
Steve French0753ca72005-10-27 13:55:12 -07002469} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470
2471/* used to hold an arbitrary blob of data */
2472struct data_blob {
2473 __u8 *data;
2474 size_t length;
Steve French50c2f752007-07-13 00:33:32 +00002475 void (*free) (struct data_blob *data_blob);
Steve French0753ca72005-10-27 13:55:12 -07002476} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477
2478
2479#ifdef CONFIG_CIFS_POSIX
Steve French50c2f752007-07-13 00:33:32 +00002480/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 For better POSIX semantics from Linux client, (even better
2482 than the existing CIFS Unix Extensions) we need updated PDUs for:
Steve French50c2f752007-07-13 00:33:32 +00002483
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484 1) PosixCreateX - to set and return the mode, inode#, device info and
2485 perhaps add a CreateDevice - to create Pipes and other special .inodes
2486 Also note POSIX open flags
Steve French50c2f752007-07-13 00:33:32 +00002487 2) Close - to return the last write time to do cache across close
Steve French87f440e2007-02-07 00:29:46 +00002488 more safely
Steve French50c2f752007-07-13 00:33:32 +00002489 3) FindFirst return unique inode number - what about resume key, two
Steve French1982c342005-08-17 12:38:22 -07002490 forms short (matches readdir) and full (enough info to cache inodes)
2491 4) Mkdir - set mode
Steve French50c2f752007-07-13 00:33:32 +00002492
2493 And under consideration:
Steve French1982c342005-08-17 12:38:22 -07002494 5) FindClose2 (return nanosecond timestamp ??)
Steve French50c2f752007-07-13 00:33:32 +00002495 6) Use nanosecond timestamps throughout all time fields if
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 corresponding attribute flag is set
Steve French1982c342005-08-17 12:38:22 -07002497 7) sendfile - handle based copy
Steve French50c2f752007-07-13 00:33:32 +00002498
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 what about fixing 64 bit alignment
Steve French50c2f752007-07-13 00:33:32 +00002500
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 There are also various legacy SMB/CIFS requests used as is
Steve French50c2f752007-07-13 00:33:32 +00002502
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 From existing Lanman and NTLM dialects:
2504 --------------------------------------
2505 NEGOTIATE
2506 SESSION_SETUP_ANDX (BB which?)
2507 TREE_CONNECT_ANDX (BB which wct?)
2508 TREE_DISCONNECT (BB add volume timestamp on response)
2509 LOGOFF_ANDX
2510 DELETE (note delete open file behavior)
2511 DELETE_DIRECTORY
2512 READ_AND_X
2513 WRITE_AND_X
2514 LOCKING_AND_X (note posix lock semantics)
2515 RENAME (note rename across dirs and open file rename posix behaviors)
2516 NT_RENAME (for hardlinks) Is this good enough for all features?
2517 FIND_CLOSE2
2518 TRANSACTION2 (18 cases)
2519 SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
2520 (BB verify that never need to set allocation size)
Steve French87f440e2007-02-07 00:29:46 +00002521 SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
2522 Unix ext?)
Steve French50c2f752007-07-13 00:33:32 +00002523
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 COPY (note support for copy across directories) - FUTURE, OPTIONAL
2525 setting/getting OS/2 EAs - FUTURE (BB can this handle
2526 setting Linux xattrs perfectly) - OPTIONAL
2527 dnotify - FUTURE, OPTIONAL
2528 quota - FUTURE, OPTIONAL
Steve French50c2f752007-07-13 00:33:32 +00002529
2530 Note that various requests implemented for NT interop such as
Linus Torvalds1da177e2005-04-16 15:20:36 -07002531 NT_TRANSACT (IOCTL) QueryReparseInfo
2532 are unneeded to servers compliant with the CIFS POSIX extensions
Steve French50c2f752007-07-13 00:33:32 +00002533
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 From CIFS Unix Extensions:
2535 -------------------------
2536 T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
2537 T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
2538 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
Steve French50c2f752007-07-13 00:33:32 +00002539 T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC) BB check for missing
2540 inode fields
2541 Actually a need QUERY_FILE_UNIX_INFO
2542 since has inode num
2543 BB what about a) blksize/blkbits/blocks
Steve French87f440e2007-02-07 00:29:46 +00002544 b) i_version
2545 c) i_rdev
2546 d) notify mask?
2547 e) generation
2548 f) size_seqcount
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
Steve French50c2f752007-07-13 00:33:32 +00002550 TRANS2_GET_DFS_REFERRAL - OPTIONAL but recommended
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 */
2553
Steve French1982c342005-08-17 12:38:22 -07002554/* xsymlink is a symlink format (used by MacOS) that can be used
Steve French50c2f752007-07-13 00:33:32 +00002555 to save symlink info in a regular file when
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 mounted to operating systems that do not
2557 support the cifs Unix extensions or EAs (for xattr
2558 based symlinks). For such a file to be recognized
Steve French50c2f752007-07-13 00:33:32 +00002559 as containing symlink data:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560
Steve French50c2f752007-07-13 00:33:32 +00002561 1) file size must be 1067,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 2) signature must begin file data,
2563 3) length field must be set to ASCII representation
Steve French50c2f752007-07-13 00:33:32 +00002564 of a number which is less than or equal to 1024,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 4) md5 must match that of the path data */
2566
2567struct xsymlink {
2568 /* 1067 bytes */
2569 char signature[4]; /* XSym */ /* not null terminated */
2570 char cr0; /* \n */
2571/* ASCII representation of length (4 bytes decimal) terminated by \n not null */
2572 char length[4];
2573 char cr1; /* \n */
2574/* md5 of valid subset of path ie path[0] through path[length-1] */
Steve French50c2f752007-07-13 00:33:32 +00002575 __u8 md5[32];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 char cr2; /* \n */
2577/* if room left, then end with \n then 0x20s by convention but not required */
Steve French50c2f752007-07-13 00:33:32 +00002578 char path[1024];
Steve French0753ca72005-10-27 13:55:12 -07002579} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580
Steve Frenchf654bac2005-04-28 22:41:04 -07002581typedef struct file_xattr_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 /* BB do we need another field for flags? BB */
2583 __u32 xattr_name_len;
2584 __u32 xattr_value_len;
2585 char xattr_name[0];
2586 /* followed by xattr_value[xattr_value_len], no pad */
Steve French50c2f752007-07-13 00:33:32 +00002587} __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
2588 level 0x205 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589
2590
Steve Frenchf654bac2005-04-28 22:41:04 -07002591/* flags for chattr command */
2592#define EXT_SECURE_DELETE 0x00000001 /* EXT3_SECRM_FL */
2593#define EXT_ENABLE_UNDELETE 0x00000002 /* EXT3_UNRM_FL */
2594/* Reserved for compress file 0x4 */
2595#define EXT_SYNCHRONOUS 0x00000008 /* EXT3_SYNC_FL */
2596#define EXT_IMMUTABLE_FL 0x00000010 /* EXT3_IMMUTABLE_FL */
2597#define EXT_OPEN_APPEND_ONLY 0x00000020 /* EXT3_APPEND_FL */
2598#define EXT_DO_NOT_BACKUP 0x00000040 /* EXT3_NODUMP_FL */
2599#define EXT_NO_UPDATE_ATIME 0x00000080 /* EXT3_NOATIME_FL */
2600/* 0x100 through 0x800 reserved for compression flags and are GET-ONLY */
2601#define EXT_HASH_TREE_INDEXED_DIR 0x00001000 /* GET-ONLY EXT3_INDEX_FL */
2602/* 0x2000 reserved for IMAGIC_FL */
2603#define EXT_JOURNAL_THIS_FILE 0x00004000 /* GET-ONLY EXT3_JOURNAL_DATA_FL */
2604/* 0x8000 reserved for EXT3_NOTAIL_FL */
2605#define EXT_SYNCHRONOUS_DIR 0x00010000 /* EXT3_DIRSYNC_FL */
2606#define EXT_TOPDIR 0x00020000 /* EXT3_TOPDIR_FL */
2607
2608#define EXT_SET_MASK 0x000300FF
2609#define EXT_GET_MASK 0x0003DFFF
2610
2611typedef struct file_chattr_info {
2612 __le64 mask; /* list of all possible attribute bits */
2613 __le64 mode; /* list of actual attribute bits on this inode */
Steve French50c2f752007-07-13 00:33:32 +00002614} __attribute__((packed)) FILE_CHATTR_INFO; /* ext attributes
2615 (chattr, chflags) level 0x206 */
Steve French03824572009-02-25 16:24:04 +00002616#endif /* POSIX */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617#endif /* _CIFSPDU_H */