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