Blame view

fs/cifs/cifspdu.h 83.8 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
  /*
   *   fs/cifs/cifspdu.h
   *
038245774   Steve French   [CIFS] Add defini...
4
   *   Copyright (c) International Business Machines  Corp., 2002,2009
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
8
9
10
11
12
13
14
15
16
17
18
   *   Author(s): Steve French (sfrench@us.ibm.com)
   *
   *   This library is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU Lesser General Public License as published
   *   by the Free Software Foundation; either version 2.1 of the License, or
   *   (at your option) any later version.
   *
   *   This library is distributed in the hope that it will be useful,
   *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
   *   the GNU Lesser General Public License for more details.
   *
   *   You should have received a copy of the GNU Lesser General Public License
   *   along with this library; if not, write to the Free Software
3979877e5   Steve French   [CIFS] Support fo...
19
   *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
20
21
22
23
24
25
   */
  
  #ifndef _CIFSPDU_H
  #define _CIFSPDU_H
  
  #include <net/sock.h>
690c522fa   Jeff Layton   cifs: use get/put...
26
  #include <asm/unaligned.h>
038245774   Steve French   [CIFS] Add defini...
27
  #include "smbfsctl.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
28

3979877e5   Steve French   [CIFS] Support fo...
29
30
  #ifdef CONFIG_CIFS_WEAK_PW_HASH
  #define LANMAN_PROT 0
9ac00b7d9   Steve French   [CIFS] Do not sen...
31
32
  #define LANMAN2_PROT 1
  #define CIFS_PROT   2
3979877e5   Steve French   [CIFS] Support fo...
33
  #else
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
  #define CIFS_PROT   0
3979877e5   Steve French   [CIFS] Support fo...
35
  #endif
ef571cadd   Shirish Pargaonkar   [CIFS] Fix warnin...
36
  #define POSIX_PROT  (CIFS_PROT+1)
3979877e5   Steve French   [CIFS] Support fo...
37
  #define BAD_PROT 0xFFFF
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38

038245774   Steve French   [CIFS] Add defini...
39
40
  /* SMB command codes:
   * Note some commands have minimal (wct=0,bcc=0), or uninteresting, responses
c14e894bd   Steve French   [CIFS] fix &&/& t...
41
   * (ie which include no useful data other than the SMB error code itself).
038245774   Steve French   [CIFS] Add defini...
42
   * This can allow us to avoid response buffer allocations and copy in some cases
c14e894bd   Steve French   [CIFS] fix &&/& t...
43
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
46
  #define SMB_COM_CREATE_DIRECTORY      0x00 /* trivial response */
  #define SMB_COM_DELETE_DIRECTORY      0x01 /* trivial response */
  #define SMB_COM_CLOSE                 0x04 /* triv req/rsp, timestamp ignored */
b298f2235   Steve French   [CIFS] Send SMB f...
47
  #define SMB_COM_FLUSH                 0x05 /* triv req/rsp */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
  #define SMB_COM_DELETE                0x06 /* trivial response */
  #define SMB_COM_RENAME                0x07 /* trivial response */
6b8edfe0f   Steve French   [CIFS] Support fo...
50
  #define SMB_COM_QUERY_INFORMATION     0x08 /* aka getattr */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
52
53
  #define SMB_COM_SETATTR               0x09 /* trivial response */
  #define SMB_COM_LOCKING_ANDX          0x24 /* trivial response */
  #define SMB_COM_COPY                  0x29 /* trivial rsp, fail filename ignrd*/
766fdbb57   Jeff Layton   cifs: add ability...
54
  #define SMB_COM_ECHO                  0x2B /* echo request */
a9d02ad49   Steve French   [CIFS] Support fo...
55
  #define SMB_COM_OPEN_ANDX             0x2D /* Legacy open for old servers */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
57
58
59
60
61
62
63
64
65
66
67
68
  #define SMB_COM_READ_ANDX             0x2E
  #define SMB_COM_WRITE_ANDX            0x2F
  #define SMB_COM_TRANSACTION2          0x32
  #define SMB_COM_TRANSACTION2_SECONDARY 0x33
  #define SMB_COM_FIND_CLOSE2           0x34 /* trivial response */
  #define SMB_COM_TREE_DISCONNECT       0x71 /* trivial response */
  #define SMB_COM_NEGOTIATE             0x72
  #define SMB_COM_SESSION_SETUP_ANDX    0x73
  #define SMB_COM_LOGOFF_ANDX           0x74 /* trivial response */
  #define SMB_COM_TREE_CONNECT_ANDX     0x75
  #define SMB_COM_NT_TRANSACT           0xA0
  #define SMB_COM_NT_TRANSACT_SECONDARY 0xA1
  #define SMB_COM_NT_CREATE_ANDX        0xA2
ff5dbd9ea   Steve French   [CIFS] Change not...
69
  #define SMB_COM_NT_CANCEL             0xA4 /* no response */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
71
72
73
74
75
76
  #define SMB_COM_NT_RENAME             0xA5 /* trivial response */
  
  /* Transact2 subcommand codes */
  #define TRANS2_OPEN                   0x00
  #define TRANS2_FIND_FIRST             0x01
  #define TRANS2_FIND_NEXT              0x02
  #define TRANS2_QUERY_FS_INFORMATION   0x03
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
77
  #define TRANS2_SET_FS_INFORMATION     0x04
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
79
80
81
82
83
  #define TRANS2_QUERY_PATH_INFORMATION 0x05
  #define TRANS2_SET_PATH_INFORMATION   0x06
  #define TRANS2_QUERY_FILE_INFORMATION 0x07
  #define TRANS2_SET_FILE_INFORMATION   0x08
  #define TRANS2_GET_DFS_REFERRAL       0x10
  #define TRANS2_REPORT_DFS_INCOSISTENCY 0x11
b7206153f   Steve French   [CIFS] Correct in...
84
85
86
87
88
89
90
91
92
93
94
95
  /* SMB Transact (Named Pipe) subcommand codes */
  #define TRANS_SET_NMPIPE_STATE      0x0001
  #define TRANS_RAW_READ_NMPIPE       0x0011
  #define TRANS_QUERY_NMPIPE_STATE    0x0021
  #define TRANS_QUERY_NMPIPE_INFO     0x0022
  #define TRANS_PEEK_NMPIPE           0x0023
  #define TRANS_TRANSACT_NMPIPE       0x0026
  #define TRANS_RAW_WRITE_NMPIPE      0x0031
  #define TRANS_READ_NMPIPE           0x0036
  #define TRANS_WRITE_NMPIPE          0x0037
  #define TRANS_WAIT_NMPIPE           0x0053
  #define TRANS_CALL_NMPIPE           0x0054
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
98
99
100
101
102
103
104
  /* NT Transact subcommand codes */
  #define NT_TRANSACT_CREATE            0x01
  #define NT_TRANSACT_IOCTL             0x02
  #define NT_TRANSACT_SET_SECURITY_DESC 0x03
  #define NT_TRANSACT_NOTIFY_CHANGE     0x04
  #define NT_TRANSACT_RENAME            0x05
  #define NT_TRANSACT_QUERY_SECURITY_DESC 0x06
  #define NT_TRANSACT_GET_USER_QUOTA    0x07
  #define NT_TRANSACT_SET_USER_QUOTA    0x08
ec637e3ff   Steve French   [CIFS] Avoid extr...
105
106
107
108
109
  #define MAX_CIFS_SMALL_BUFFER_SIZE 448 /* big enough for most */
  /* future chained NTCreateXReadX bigger, but for time being NTCreateX biggest */
  /* among the requests (NTCreateX response is bigger with wct of 34) */
  #define MAX_CIFS_HDR_SIZE 0x58 /* 4 len + 32 hdr + (2*24 wct) + 2 bct + 2 pad */
  #define CIFS_SMALL_PATH 120 /* allows for (448-88)/3 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  
  /* internal cifs vfs structures */
  /*****************************************************************
   * All constants go here
   *****************************************************************
   */
  
  /*
   * Starting value for maximum SMB size negotiation
   */
  #define CIFS_MAX_MSGSIZE (4*4096)
  
  /*
   * Size of encrypted user password in bytes
   */
  #define CIFS_ENCPWD_SIZE (16)
  
  /*
   * Size of the crypto key returned on the negotiate SMB in bytes
   */
  #define CIFS_CRYPTO_KEY_SIZE (8)
  
  /*
21e733930   Shirish Pargaonkar   NTLM auth and sig...
133
134
135
136
137
   * Size of the ntlm client response
   */
  #define CIFS_AUTH_RESP_SIZE (24)
  
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
139
   * Size of the session key (crypto key encrypted with the password
   */
21e733930   Shirish Pargaonkar   NTLM auth and sig...
140
  #define CIFS_SESS_KEY_SIZE (16)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141

429b46f4f   Steve French   [CIFS] SMB3 Signi...
142
143
144
145
  /*
   * Size of the smb3 signing key
   */
  #define SMB3_SIGN_KEY_SIZE (16)
d2b915210   Shirish Pargaonkar   NTLM auth and sig...
146
147
148
149
150
  #define CIFS_CLIENT_CHALLENGE_SIZE (8)
  #define CIFS_SERVER_CHALLENGE_SIZE (8)
  #define CIFS_HMAC_MD5_HASH_SIZE (16)
  #define CIFS_CPHTXT_SIZE (16)
  #define CIFS_NTHASH_SIZE (16)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
  /*
   * Maximum user name length
   */
  #define CIFS_UNLEN (20)
  
  /*
   * Flags on SMB open
   */
  #define SMBOPEN_WRITE_THROUGH 0x4000
  #define SMBOPEN_DENY_ALL      0x0010
  #define SMBOPEN_DENY_WRITE    0x0020
  #define SMBOPEN_DENY_READ     0x0030
  #define SMBOPEN_DENY_NONE     0x0040
  #define SMBOPEN_READ          0x0000
  #define SMBOPEN_WRITE         0x0001
  #define SMBOPEN_READWRITE     0x0002
  #define SMBOPEN_EXECUTE       0x0003
  
  #define SMBOPEN_OCREATE       0x0010
  #define SMBOPEN_OTRUNC        0x0002
  #define SMBOPEN_OAPPEND       0x0001
  
  /*
50c2f7538   Steve French   [CIFS] whitespace...
174
   * SMB flag definitions
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
175
   */
0753ca7bc   Steve French   [CIFS] Change pra...
176
  #define SMBFLG_EXTD_LOCK 0x01	/* server supports lock-read write-unlock smb */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
177
178
  #define SMBFLG_RCV_POSTED 0x02	/* obsolete */
  #define SMBFLG_RSVD 0x04
0753ca7bc   Steve French   [CIFS] Change pra...
179
180
  #define SMBFLG_CASELESS 0x08	/* all pathnames treated as caseless (off
  				implies case sensitive file handling request) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
181
182
183
184
185
186
  #define SMBFLG_CANONICAL_PATH_FORMAT 0x10	/* obsolete */
  #define SMBFLG_OLD_OPLOCK 0x20	/* obsolete */
  #define SMBFLG_OLD_OPLOCK_NOTIFY 0x40	/* obsolete */
  #define SMBFLG_RESPONSE 0x80	/* this PDU is a response from server */
  
  /*
50c2f7538   Steve French   [CIFS] whitespace...
187
   * SMB flag2 definitions
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
188
   */
50c2f7538   Steve French   [CIFS] whitespace...
189
  #define SMBFLG2_KNOWS_LONG_NAMES cpu_to_le16(1)	/* can send long (non-8.3)
0753ca7bc   Steve French   [CIFS] Change pra...
190
  						   path names in response */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
191
192
  #define SMBFLG2_KNOWS_EAS cpu_to_le16(2)
  #define SMBFLG2_SECURITY_SIGNATURE cpu_to_le16(4)
675c46796   Steve French   [CIFS] Add variou...
193
194
  #define SMBFLG2_COMPRESSED (8)
  #define SMBFLG2_SECURITY_SIGNATURE_REQUIRED (0x10)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
195
  #define SMBFLG2_IS_LONG_NAME cpu_to_le16(0x40)
675c46796   Steve French   [CIFS] Add variou...
196
  #define SMBFLG2_REPARSE_PATH (0x400)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  #define SMBFLG2_EXT_SEC cpu_to_le16(0x800)
  #define SMBFLG2_DFS cpu_to_le16(0x1000)
  #define SMBFLG2_PAGING_IO cpu_to_le16(0x2000)
  #define SMBFLG2_ERR_STATUS cpu_to_le16(0x4000)
  #define SMBFLG2_UNICODE cpu_to_le16(0x8000)
  
  /*
   * These are the file access permission bits defined in CIFS for the
   * NTCreateAndX as well as the level 0x107
   * TRANS2_QUERY_PATH_INFORMATION API.  The level 0x107, SMB_QUERY_FILE_ALL_INFO
   * responds with the AccessFlags.
   * The AccessFlags specifies the access permissions a caller has to the
   * file and can have any suitable combination of the following values:
   */
0753ca7bc   Steve French   [CIFS] Change pra...
211
212
213
214
215
216
217
218
219
  #define FILE_READ_DATA        0x00000001  /* Data can be read from the file   */
  #define FILE_WRITE_DATA       0x00000002  /* Data can be written to the file  */
  #define FILE_APPEND_DATA      0x00000004  /* Data can be appended to the file */
  #define FILE_READ_EA          0x00000008  /* Extended attributes associated   */
  					  /* with the file can be read        */
  #define FILE_WRITE_EA         0x00000010  /* Extended attributes associated   */
  					  /* with the file can be written     */
  #define FILE_EXECUTE          0x00000020  /*Data can be read into memory from */
  					  /* the file using system paging I/O */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
220
  #define FILE_DELETE_CHILD     0x00000040
0753ca7bc   Steve French   [CIFS] Change pra...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
  #define FILE_READ_ATTRIBUTES  0x00000080  /* Attributes associated with the   */
  					  /* file can be read                 */
  #define FILE_WRITE_ATTRIBUTES 0x00000100  /* Attributes associated with the   */
  					  /* file can be written              */
  #define DELETE                0x00010000  /* The file can be deleted          */
  #define READ_CONTROL          0x00020000  /* The access control list and      */
  					  /* ownership associated with the    */
  					  /* file can be read                 */
  #define WRITE_DAC             0x00040000  /* The access control list and      */
  					  /* ownership associated with the    */
  					  /* file can be written.             */
  #define WRITE_OWNER           0x00080000  /* Ownership information associated */
  					  /* with the file can be written     */
  #define SYNCHRONIZE           0x00100000  /* The file handle can waited on to */
  					  /* synchronize with the completion  */
  					  /* of an input/output request       */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
237
238
239
240
241
242
243
  #define GENERIC_ALL           0x10000000
  #define GENERIC_EXECUTE       0x20000000
  #define GENERIC_WRITE         0x40000000
  #define GENERIC_READ          0x80000000
  					 /* In summary - Relevant file       */
  					 /* access flags from CIFS are       */
  					 /* file_read_data, file_write_data  */
0753ca7bc   Steve French   [CIFS] Change pra...
244
  					 /* file_execute, file_read_attributes*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
245
  					 /* write_dac, and delete.           */
a750e77c2   Steve French   [CIFS] acl suppor...
246
247
248
249
  #define FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)
  #define FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
  				| FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)
  #define FILE_EXEC_RIGHTS (FILE_EXECUTE)
953f86813   Steve French   [CIFS] Don't requ...
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
  #define SET_FILE_READ_RIGHTS (FILE_READ_DATA | FILE_READ_EA | FILE_WRITE_EA \
  				| FILE_READ_ATTRIBUTES \
  				| FILE_WRITE_ATTRIBUTES \
  				| DELETE | READ_CONTROL | WRITE_DAC \
  				| WRITE_OWNER | SYNCHRONIZE)
  #define SET_FILE_WRITE_RIGHTS (FILE_WRITE_DATA | FILE_APPEND_DATA \
  				| FILE_READ_EA | FILE_WRITE_EA \
  				| FILE_DELETE_CHILD | FILE_READ_ATTRIBUTES \
  				| FILE_WRITE_ATTRIBUTES \
  				| DELETE | READ_CONTROL | WRITE_DAC \
  				| WRITE_OWNER | SYNCHRONIZE)
  #define SET_FILE_EXEC_RIGHTS (FILE_READ_EA | FILE_WRITE_EA | FILE_EXECUTE \
  				| FILE_READ_ATTRIBUTES \
  				| FILE_WRITE_ATTRIBUTES \
  				| DELETE | READ_CONTROL | WRITE_DAC \
  				| WRITE_OWNER | SYNCHRONIZE)
97837582b   Steve French   [CIFS] Allow sett...
266
267
  #define SET_MINIMUM_RIGHTS (FILE_READ_EA | FILE_READ_ATTRIBUTES \
  				| READ_CONTROL | SYNCHRONIZE)
a750e77c2   Steve French   [CIFS] acl suppor...
268

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
269
270
271
272
  /*
   * Invalid readdir handle
   */
  #define CIFS_NO_HANDLE        0xFFFF
4e1e7fb9e   Jeff Layton   bundle up Unix SE...
273
  #define NO_CHANGE_64          0xFFFFFFFFFFFFFFFFULL
c7af1857e   Steve French   [CIFS] Fix set fi...
274

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
  /* IPC$ in ASCII */
  #define CIFS_IPC_RESOURCE "\x49\x50\x43\x24"
  
  /* IPC$ in Unicode */
  #define CIFS_IPC_UNICODE_RESOURCE "\x00\x49\x00\x50\x00\x43\x00\x24\x00\x00"
  
  /* Unicode Null terminate 2 bytes of 0 */
  #define UNICODE_NULL "\x00\x00"
  #define ASCII_NULL 0x00
  
  /*
   * Server type values (returned on EnumServer API
   */
  #define CIFS_SV_TYPE_DC     0x00000008
  #define CIFS_SV_TYPE_BACKDC 0x00000010
  
  /*
   * Alias type flags (From EnumAlias API call
   */
  #define CIFS_ALIAS_TYPE_FILE 0x0001
  #define CIFS_SHARE_TYPE_FILE 0x0000
  
  /*
   * File Attribute flags
   */
  #define ATTR_READONLY  0x0001
  #define ATTR_HIDDEN    0x0002
  #define ATTR_SYSTEM    0x0004
  #define ATTR_VOLUME    0x0008
  #define ATTR_DIRECTORY 0x0010
  #define ATTR_ARCHIVE   0x0020
  #define ATTR_DEVICE    0x0040
  #define ATTR_NORMAL    0x0080
  #define ATTR_TEMPORARY 0x0100
  #define ATTR_SPARSE    0x0200
  #define ATTR_REPARSE   0x0400
  #define ATTR_COMPRESSED 0x0800
50c2f7538   Steve French   [CIFS] whitespace...
312
  #define ATTR_OFFLINE    0x1000	/* ie file not immediately available -
0753ca7bc   Steve French   [CIFS] Change pra...
313
  					on offline storage */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
  #define ATTR_NOT_CONTENT_INDEXED 0x2000
  #define ATTR_ENCRYPTED  0x4000
  #define ATTR_POSIX_SEMANTICS 0x01000000
  #define ATTR_BACKUP_SEMANTICS 0x02000000
  #define ATTR_DELETE_ON_CLOSE 0x04000000
  #define ATTR_SEQUENTIAL_SCAN 0x08000000
  #define ATTR_RANDOM_ACCESS   0x10000000
  #define ATTR_NO_BUFFERING    0x20000000
  #define ATTR_WRITE_THROUGH   0x80000000
  
  /* ShareAccess flags */
  #define FILE_NO_SHARE     0x00000000
  #define FILE_SHARE_READ   0x00000001
  #define FILE_SHARE_WRITE  0x00000002
  #define FILE_SHARE_DELETE 0x00000004
  #define FILE_SHARE_ALL    0x00000007
675c46796   Steve French   [CIFS] Add variou...
330
  /* CreateDisposition flags, similar to CreateAction as well */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
331
332
333
334
335
336
337
338
339
340
  #define FILE_SUPERSEDE    0x00000000
  #define FILE_OPEN         0x00000001
  #define FILE_CREATE       0x00000002
  #define FILE_OPEN_IF      0x00000003
  #define FILE_OVERWRITE    0x00000004
  #define FILE_OVERWRITE_IF 0x00000005
  
  /* CreateOptions */
  #define CREATE_NOT_FILE		0x00000001	/* if set must not be file */
  #define CREATE_WRITE_THROUGH	0x00000002
eda3c0298   Steve French   [CIFS] Add compat...
341
  #define CREATE_SEQUENTIAL       0x00000004
675c46796   Steve French   [CIFS] Add variou...
342
343
344
  #define CREATE_NO_BUFFER        0x00000008      /* should not buffer on srv */
  #define CREATE_SYNC_ALERT       0x00000010	/* MBZ */
  #define CREATE_ASYNC_ALERT      0x00000020	/* MBZ */
eda3c0298   Steve French   [CIFS] Add compat...
345
  #define CREATE_NOT_DIR		0x00000040    /* if set must not be directory */
675c46796   Steve French   [CIFS] Add variou...
346
347
  #define CREATE_TREE_CONNECTION  0x00000080	/* should be zero */
  #define CREATE_COMPLETE_IF_OPLK 0x00000100	/* should be zero */
eda3c0298   Steve French   [CIFS] Add compat...
348
  #define CREATE_NO_EA_KNOWLEDGE  0x00000200
675c46796   Steve French   [CIFS] Add variou...
349
  #define CREATE_EIGHT_DOT_THREE  0x00000400	/* doc says this is obsolete
ef571cadd   Shirish Pargaonkar   [CIFS] Fix warnin...
350
  						 "open for recovery" flag should
b7206153f   Steve French   [CIFS] Correct in...
351
352
  						 be zero in any case */
  #define CREATE_OPEN_FOR_RECOVERY 0x00000400
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
353
354
  #define CREATE_RANDOM_ACCESS	0x00000800
  #define CREATE_DELETE_ON_CLOSE	0x00001000
eda3c0298   Steve French   [CIFS] Add compat...
355
  #define CREATE_OPEN_BY_ID       0x00002000
b7206153f   Steve French   [CIFS] Correct in...
356
  #define CREATE_OPEN_BACKUP_INTENT 0x00004000
675c46796   Steve French   [CIFS] Add variou...
357
358
  #define CREATE_NO_COMPRESSION   0x00008000
  #define CREATE_RESERVE_OPFILTER 0x00100000	/* should be zero */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
359
  #define OPEN_REPARSE_POINT	0x00200000
675c46796   Steve French   [CIFS] Add variou...
360
361
  #define OPEN_NO_RECALL          0x00400000
  #define OPEN_FREE_SPACE_QUERY   0x00800000	/* should be zero */
50c2f7538   Steve French   [CIFS] whitespace...
362
  #define CREATE_OPTIONS_MASK     0x007FFFFF
67750fb9e   Jeff Layton   [CIFS] when not u...
363
  #define CREATE_OPTION_READONLY	0x10000000
eda3c0298   Steve French   [CIFS] Add compat...
364
  #define CREATE_OPTION_SPECIAL   0x20000000   /* system. NB not sent over wire */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
  
  /* ImpersonationLevel flags */
  #define SECURITY_ANONYMOUS      0
  #define SECURITY_IDENTIFICATION 1
  #define SECURITY_IMPERSONATION  2
  #define SECURITY_DELEGATION     3
  
  /* SecurityFlags */
  #define SECURITY_CONTEXT_TRACKING 0x01
  #define SECURITY_EFFECTIVE_ONLY   0x02
  
  /*
   * Default PID value, used in all SMBs where the PID is not important
   */
  #define CIFS_DFT_PID  0x1234
  
  /*
   * We use the same routine for Copy and Move SMBs.  This flag is used to
   * distinguish
   */
  #define CIFS_COPY_OP 1
  #define CIFS_RENAME_OP 2
  
  #define GETU16(var)  (*((__u16 *)var))	/* BB check for endian issues */
  #define GETU32(var)  (*((__u32 *)var))	/* BB check for endian issues */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
390
  struct smb_hdr {
be8e3b004   Steve French   consistently use ...
391
392
393
  	__be32 smb_buf_length;	/* BB length is only two (rarely three) bytes,
  		with one or two byte "type" preceding it that will be
  		zero - we could mask the type byte off */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
394
395
396
397
398
399
400
  	__u8 Protocol[4];
  	__u8 Command;
  	union {
  		struct {
  			__u8 ErrorClass;
  			__u8 Reserved;
  			__le16 Error;
0753ca7bc   Steve French   [CIFS] Change pra...
401
  		} __attribute__((packed)) DosError;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
402
  		__le32 CifsError;
0753ca7bc   Steve French   [CIFS] Change pra...
403
  	} __attribute__((packed)) Status;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
404
405
406
407
408
409
410
  	__u8 Flags;
  	__le16 Flags2;		/* note: le */
  	__le16 PidHigh;
  	union {
  		struct {
  			__le32 SequenceNumber;  /* le */
  			__u32 Reserved; /* zero */
0753ca7bc   Steve French   [CIFS] Change pra...
411
  		} __attribute__((packed)) Sequence;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
412
  		__u8 SecuritySignature[8];	/* le */
0753ca7bc   Steve French   [CIFS] Change pra...
413
  	} __attribute__((packed)) Signature;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
414
415
416
417
  	__u8 pad[2];
  	__u16 Tid;
  	__le16 Pid;
  	__u16 Uid;
3d378d3fd   Tim Gardner   cifs: Make big en...
418
  	__le16 Mid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
419
  	__u8 WordCount;
0753ca7bc   Steve French   [CIFS] Change pra...
420
  } __attribute__((packed));
690c522fa   Jeff Layton   cifs: use get/put...
421

460458ce8   Jeff Layton   cifs: turn BCC in...
422
423
424
425
426
427
  /* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */
  static inline void *
  BCC(struct smb_hdr *smb)
  {
  	return (void *)smb + sizeof(*smb) + 2 * smb->WordCount;
  }
690c522fa   Jeff Layton   cifs: use get/put...
428

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
429
  /* given a pointer to an smb_hdr retrieve the pointer to the byte area */
690c522fa   Jeff Layton   cifs: use get/put...
430
  #define pByteArea(smb_var) (BCC(smb_var) + 2)
690c522fa   Jeff Layton   cifs: use get/put...
431
432
  /* get the unconverted ByteCount for a SMB packet and return it */
  static inline __u16
820a803ff   Jeff Layton   cifs: keep BCC in...
433
  get_bcc(struct smb_hdr *hdr)
690c522fa   Jeff Layton   cifs: use get/put...
434
435
436
437
438
  {
  	__le16 *bc_ptr = (__le16 *)BCC(hdr);
  
  	return get_unaligned_le16(bc_ptr);
  }
690c522fa   Jeff Layton   cifs: use get/put...
439
440
  /* set the ByteCount for a SMB packet in little-endian */
  static inline void
820a803ff   Jeff Layton   cifs: keep BCC in...
441
  put_bcc(__u16 count, struct smb_hdr *hdr)
690c522fa   Jeff Layton   cifs: use get/put...
442
443
444
445
446
  {
  	__le16 *bc_ptr = (__le16 *)BCC(hdr);
  
  	put_unaligned_le16(count, bc_ptr);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
447
448
  
  /*
50c2f7538   Steve French   [CIFS] whitespace...
449
450
451
   * Computer Name Length (since Netbios name was length 16 with last byte 0x20)
   * No longer as important, now that TCP names are more commonly used to
   * resolve hosts.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
452
453
454
455
   */
  #define CNLEN 15
  
  /*
50c2f7538   Steve French   [CIFS] whitespace...
456
457
458
459
460
   * Share Name Length (SNLEN)
   * Note:  This length was limited by the SMB used to get
   *        the Share info.   NetShareEnum only returned 13
   *        chars, including the null termination.
   * This was removed because it no longer is limiting.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
461
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
  
  /*
   * Comment Length
   */
  #define MAXCOMMENTLEN 40
  
  /*
   * The OS/2 maximum path name
   */
  #define MAX_PATHCONF 256
  
  /*
   *  SMB frame definitions  (following must be packed structs)
   *  See the SNIA CIFS Specification for details.
   *
   *  The Naming convention is the lower case version of the
   *  smb command code name for the struct and this is typedef to the
50c2f7538   Steve French   [CIFS] whitespace...
479
480
   *  uppercase version of the same name with the prefix SMB_ removed
   *  for brevity.  Although typedefs are not commonly used for
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
481
482
483
484
485
486
487
   *  structure definitions in the Linux kernel, their use in the
   *  CIFS standards document, which this code is based on, may
   *  make this one of the cases where typedefs for structures make
   *  sense to improve readability for readers of the standards doc.
   *  Typedefs can always be removed later if they are too distracting
   *  and they are only used for the CIFSs PDUs themselves, not
   *  internal cifs vfs structures
50c2f7538   Steve French   [CIFS] whitespace...
488
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
489
490
491
492
493
494
   */
  
  typedef struct negotiate_req {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__le16 ByteCount;
  	unsigned char DialectsArray[1];
0753ca7bc   Steve French   [CIFS] Change pra...
495
  } __attribute__((packed)) NEGOTIATE_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
496

3979877e5   Steve French   [CIFS] Support fo...
497
  /* Dialect index is 13 for LANMAN */
b815f1e55   Steve French   [CIFS] Allow for ...
498
  #define MIN_TZ_ADJ (15 * 60) /* minimum grid for timezones in seconds */
3979877e5   Steve French   [CIFS] Support fo...
499
500
501
502
503
504
505
506
507
  typedef struct lanman_neg_rsp {
  	struct smb_hdr hdr;	/* wct = 13 */
  	__le16 DialectIndex;
  	__le16 SecurityMode;
  	__le16 MaxBufSize;
  	__le16 MaxMpxCount;
  	__le16 MaxNumberVcs;
  	__le16 RawMode;
  	__le32 SessionKey;
175ec9e11   Steve French   [CIFS] Rename ser...
508
509
510
511
  	struct {
  		__le16 Time;
  		__le16 Date;
  	} __attribute__((packed)) SrvTime;
3979877e5   Steve French   [CIFS] Support fo...
512
513
514
515
516
517
  	__le16 ServerTimeZone;
  	__le16 EncryptionKeyLength;
  	__le16 Reserved;
  	__u16  ByteCount;
  	unsigned char EncryptionKey[1];
  } __attribute__((packed)) LANMAN_NEG_RSP;
254e55ed0   Steve French   CIFS] Support for...
518
519
520
  #define READ_RAW_ENABLE 1
  #define WRITE_RAW_ENABLE 2
  #define RAW_ENABLE (READ_RAW_ENABLE | WRITE_RAW_ENABLE)
31d9e2bd5   Jeff Layton   cifs: break out d...
521
  #define SMB1_CLIENT_GUID_SIZE (16)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
522
523
  typedef struct negotiate_rsp {
  	struct smb_hdr hdr;	/* wct = 17 */
675c46796   Steve French   [CIFS] Add variou...
524
  	__le16 DialectIndex; /* 0xFFFF = no dialect acceptable */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
525
526
527
528
529
530
531
532
533
534
535
536
537
  	__u8 SecurityMode;
  	__le16 MaxMpxCount;
  	__le16 MaxNumberVcs;
  	__le32 MaxBufferSize;
  	__le32 MaxRawSize;
  	__le32 SessionKey;
  	__le32 Capabilities;	/* see below */
  	__le32 SystemTimeLow;
  	__le32 SystemTimeHigh;
  	__le16 ServerTimeZone;
  	__u8 EncryptionKeyLength;
  	__u16 ByteCount;
  	union {
0753ca7bc   Steve French   [CIFS] Change pra...
538
  		unsigned char EncryptionKey[1];	/* cap extended security off */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
539
540
  		/* followed by Domain name - if extended security is off */
  		/* followed by 16 bytes of server GUID */
0753ca7bc   Steve French   [CIFS] Change pra...
541
  		/* then security blob if cap_extended_security negotiated */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
542
  		struct {
31d9e2bd5   Jeff Layton   cifs: break out d...
543
  			unsigned char GUID[SMB1_CLIENT_GUID_SIZE];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
544
  			unsigned char SecurityBlob[1];
0753ca7bc   Steve French   [CIFS] Change pra...
545
546
547
  		} __attribute__((packed)) extended_response;
  	} __attribute__((packed)) u;
  } __attribute__((packed)) NEGOTIATE_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
  
  /* SecurityMode bits */
  #define SECMODE_USER          0x01	/* off indicates share level security */
  #define SECMODE_PW_ENCRYPT    0x02
  #define SECMODE_SIGN_ENABLED  0x04	/* SMB security signatures enabled */
  #define SECMODE_SIGN_REQUIRED 0x08	/* SMB security signatures required */
  
  /* Negotiate response Capabilities */
  #define CAP_RAW_MODE           0x00000001
  #define CAP_MPX_MODE           0x00000002
  #define CAP_UNICODE            0x00000004
  #define CAP_LARGE_FILES        0x00000008
  #define CAP_NT_SMBS            0x00000010	/* implies CAP_NT_FIND */
  #define CAP_RPC_REMOTE_APIS    0x00000020
  #define CAP_STATUS32           0x00000040
  #define CAP_LEVEL_II_OPLOCKS   0x00000080
  #define CAP_LOCK_AND_READ      0x00000100
  #define CAP_NT_FIND            0x00000200
  #define CAP_DFS                0x00001000
  #define CAP_INFOLEVEL_PASSTHRU 0x00002000
  #define CAP_LARGE_READ_X       0x00004000
  #define CAP_LARGE_WRITE_X      0x00008000
675c46796   Steve French   [CIFS] Add variou...
570
  #define CAP_LWIO               0x00010000 /* support fctl_srv_req_resume_key */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
571
  #define CAP_UNIX               0x00800000
675c46796   Steve French   [CIFS] Add variou...
572
573
574
  #define CAP_COMPRESSED_DATA    0x02000000
  #define CAP_DYNAMIC_REAUTH     0x20000000
  #define CAP_PERSISTENT_HANDLES 0x40000000
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
  #define CAP_EXTENDED_SECURITY  0x80000000
  
  typedef union smb_com_session_setup_andx {
  	struct {		/* request format */
  		struct smb_hdr hdr;	/* wct = 12 */
  		__u8 AndXCommand;
  		__u8 AndXReserved;
  		__le16 AndXOffset;
  		__le16 MaxBufferSize;
  		__le16 MaxMpxCount;
  		__le16 VcNumber;
  		__u32 SessionKey;
  		__le16 SecurityBlobLength;
  		__u32 Reserved;
  		__le32 Capabilities;	/* see below */
  		__le16 ByteCount;
  		unsigned char SecurityBlob[1];	/* followed by */
  		/* STRING NativeOS */
  		/* STRING NativeLanMan */
50c2f7538   Steve French   [CIFS] whitespace...
594
  	} __attribute__((packed)) req;	/* NTLM request format (with
0753ca7bc   Steve French   [CIFS] Change pra...
595
  					extended security */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
596
597
598
599
600
601
602
603
604
605
  
  	struct {		/* request format */
  		struct smb_hdr hdr;	/* wct = 13 */
  		__u8 AndXCommand;
  		__u8 AndXReserved;
  		__le16 AndXOffset;
  		__le16 MaxBufferSize;
  		__le16 MaxMpxCount;
  		__le16 VcNumber;
  		__u32 SessionKey;
0753ca7bc   Steve French   [CIFS] Change pra...
606
607
  		__le16 CaseInsensitivePasswordLength; /* ASCII password len */
  		__le16 CaseSensitivePasswordLength; /* Unicode password length*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
608
609
610
  		__u32 Reserved;	/* see below */
  		__le32 Capabilities;
  		__le16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
611
  		unsigned char CaseInsensitivePassword[1];     /* followed by: */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
612
613
614
615
616
  		/* unsigned char * CaseSensitivePassword; */
  		/* STRING AccountName */
  		/* STRING PrimaryDomain */
  		/* STRING NativeOS */
  		/* STRING NativeLanMan */
0753ca7bc   Steve French   [CIFS] Change pra...
617
618
  	} __attribute__((packed)) req_no_secext; /* NTLM request format (without
  							extended security */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
619
620
621
622
623
624
625
626
627
628
629
630
631
  
  	struct {		/* default (NTLM) response format */
  		struct smb_hdr hdr;	/* wct = 4 */
  		__u8 AndXCommand;
  		__u8 AndXReserved;
  		__le16 AndXOffset;
  		__le16 Action;	/* see below */
  		__le16 SecurityBlobLength;
  		__u16 ByteCount;
  		unsigned char SecurityBlob[1];	/* followed by */
  /*      unsigned char  * NativeOS;      */
  /*	unsigned char  * NativeLanMan;  */
  /*      unsigned char  * PrimaryDomain; */
50c2f7538   Steve French   [CIFS] whitespace...
632
  	} __attribute__((packed)) resp;	/* NTLM response
87f440e70   Steve French   [CIFS] Additional...
633
  					   (with or without extended sec) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
634
635
636
637
638
639
640
641
642
643
  
  	struct {		/* request format */
  		struct smb_hdr hdr;	/* wct = 10 */
  		__u8 AndXCommand;
  		__u8 AndXReserved;
  		__le16 AndXOffset;
  		__le16 MaxBufferSize;
  		__le16 MaxMpxCount;
  		__le16 VcNumber;
  		__u32 SessionKey;
3979877e5   Steve French   [CIFS] Support fo...
644
645
  		__le16 PasswordLength;
  		__u32 Reserved; /* encrypt key len and offset */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
646
647
648
649
650
651
  		__le16 ByteCount;
  		unsigned char AccountPassword[1];	/* followed by */
  		/* STRING AccountName */
  		/* STRING PrimaryDomain */
  		/* STRING NativeOS */
  		/* STRING NativeLanMan */
0a4b92c05   Steve French   [CIFS] Add worker...
652
  	} __attribute__((packed)) old_req; /* pre-NTLM (LANMAN2.1) req format */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
653
654
655
656
657
658
659
660
661
662
663
  
  	struct {		/* default (NTLM) response format */
  		struct smb_hdr hdr;	/* wct = 3 */
  		__u8 AndXCommand;
  		__u8 AndXReserved;
  		__le16 AndXOffset;
  		__le16 Action;	/* see below */
  		__u16 ByteCount;
  		unsigned char NativeOS[1];	/* followed by */
  /*	unsigned char * NativeLanMan; */
  /*      unsigned char * PrimaryDomain; */
0a4b92c05   Steve French   [CIFS] Add worker...
664
  	} __attribute__((packed)) old_resp; /* pre-NTLM (LANMAN2.1) response */
0753ca7bc   Steve French   [CIFS] Change pra...
665
  } __attribute__((packed)) SESSION_SETUP_ANDX;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
666

f64b23ae4   Steve French   [CIFS] NTLMv2 sup...
667
  /* format of NLTMv2 Response ie "case sensitive password" hash when NTLMv2 */
33ec32fae   Steve French   [CIFS] Fix NTLMv2...
668
669
670
671
672
  #define NTLMSSP_SERVER_TYPE	1
  #define NTLMSSP_DOMAIN_TYPE	2
  #define NTLMSSP_FQ_DOMAIN_TYPE	3
  #define NTLMSSP_DNS_DOMAIN_TYPE	4
  #define NTLMSSP_DNS_PARENT_TYPE	5
f64b23ae4   Steve French   [CIFS] NTLMv2 sup...
673
674
675
676
677
678
679
  struct ntlmssp2_name {
  	__le16 type;
  	__le16 length;
  /*	char   name[length]; */
  } __attribute__((packed));
  
  struct ntlmv2_resp {
2c957ddf3   Tim Gardner   cifs: Use data st...
680
681
682
683
684
685
686
  	union {
  	    char ntlmv2_hash[CIFS_ENCPWD_SIZE];
  	    struct {
  		__u8 reserved[8];
  		__u8 key[CIFS_SERVER_CHALLENGE_SIZE];
  	    } __attribute__((packed)) challenge;
  	} __attribute__((packed));
6d027cfdb   Steve French   [CIFS] NTLMv2 sup...
687
  	__le32 blob_signature;
f64b23ae4   Steve French   [CIFS] NTLMv2 sup...
688
689
690
691
  	__u32  reserved;
  	__le64  time;
  	__u64  client_chal; /* random */
  	__u32  reserved2;
f64b23ae4   Steve French   [CIFS] NTLMv2 sup...
692
693
  	/* array of name entries could follow ending in minimum 4 byte struct */
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
694
695
696
697
698
699
700
701
  #define CIFS_NETWORK_OPSYS "CIFS VFS Client for Linux"
  
  /* Capabilities bits (for NTLM SessSetup request) */
  #define CAP_UNICODE            0x00000004
  #define CAP_LARGE_FILES        0x00000008
  #define CAP_NT_SMBS            0x00000010
  #define CAP_STATUS32           0x00000040
  #define CAP_LEVEL_II_OPLOCKS   0x00000080
50c2f7538   Steve French   [CIFS] whitespace...
702
  #define CAP_NT_FIND            0x00000200	/* reserved should be zero
0753ca7bc   Steve French   [CIFS] Change pra...
703
  				(because NT_SMBs implies the same thing?) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
  #define CAP_BULK_TRANSFER      0x20000000
  #define CAP_EXTENDED_SECURITY  0x80000000
  
  /* Action bits */
  #define GUEST_LOGIN 1
  
  typedef struct smb_com_tconx_req {
  	struct smb_hdr hdr;	/* wct = 4 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__le16 Flags;		/* see below */
  	__le16 PasswordLength;
  	__le16 ByteCount;
  	unsigned char Password[1];	/* followed by */
  /* STRING Path    *//* \\server\share name */
  	/* STRING Service */
0753ca7bc   Steve French   [CIFS] Change pra...
721
  } __attribute__((packed)) TCONX_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
722
723
  
  typedef struct smb_com_tconx_rsp {
675c46796   Steve French   [CIFS] Add variou...
724
  	struct smb_hdr hdr;	/* wct = 3 , not extended response */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
725
726
727
728
729
730
731
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__le16 OptionalSupport;	/* see below */
  	__u16 ByteCount;
  	unsigned char Service[1];	/* always ASCII, not Unicode */
  	/* STRING NativeFileSystem */
0753ca7bc   Steve French   [CIFS] Change pra...
732
  } __attribute__((packed)) TCONX_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
733

675c46796   Steve French   [CIFS] Add variou...
734
735
736
737
738
739
740
741
742
743
744
745
  typedef struct smb_com_tconx_rsp_ext {
  	struct smb_hdr hdr;	/* wct = 7, extended response */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__le16 OptionalSupport;	/* see below */
  	__le32 MaximalShareAccessRights;
  	__le32 GuestMaximalShareAccessRights;
  	__u16 ByteCount;
  	unsigned char Service[1];	/* always ASCII, not Unicode */
  	/* STRING NativeFileSystem */
  } __attribute__((packed)) TCONX_RSP_EXT;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
746
747
  /* tree connect Flags */
  #define DISCONNECT_TID          0x0001
675c46796   Steve French   [CIFS] Add variou...
748
  #define TCON_EXTENDED_SIGNATURES 0x0004
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
749
  #define TCON_EXTENDED_SECINFO   0x0008
675c46796   Steve French   [CIFS] Add variou...
750

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
751
  /* OptionalSupport bits */
0753ca7bc   Steve French   [CIFS] Change pra...
752
753
  #define SMB_SUPPORT_SEARCH_BITS 0x0001	/* "must have" directory search bits
  					 (exclusive searches supported) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
754
  #define SMB_SHARE_IS_IN_DFS     0x0002
675c46796   Steve French   [CIFS] Add variou...
755
756
757
758
759
760
  #define SMB_CSC_MASK               0x000C
  /* CSC flags defined as follows */
  #define SMB_CSC_CACHE_MANUAL_REINT 0x0000
  #define SMB_CSC_CACHE_AUTO_REINT   0x0004
  #define SMB_CSC_CACHE_VDO          0x0008
  #define SMB_CSC_NO_CACHING         0x000C
675c46796   Steve French   [CIFS] Add variou...
761
762
763
764
765
766
767
768
769
770
771
772
  #define SMB_UNIQUE_FILE_NAME    0x0010
  #define SMB_EXTENDED_SIGNATURES 0x0020
  
  /* services
   *
   * A:       ie disk
   * LPT1:    ie printer
   * IPC      ie named pipe
   * COMM
   * ?????    ie any type
   *
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
773

766fdbb57   Jeff Layton   cifs: add ability...
774
775
776
777
778
779
780
781
782
783
784
785
786
  typedef struct smb_com_echo_req {
  	struct	smb_hdr hdr;
  	__le16	EchoCount;
  	__le16	ByteCount;
  	char	Data[1];
  } __attribute__((packed)) ECHO_REQ;
  
  typedef struct smb_com_echo_rsp {
  	struct	smb_hdr hdr;
  	__le16	SequenceNumber;
  	__le16	ByteCount;
  	char	Data[1];
  } __attribute__((packed)) ECHO_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
787
788
789
790
791
792
  typedef struct smb_com_logoff_andx_req {
  	struct smb_hdr hdr;	/* wct = 2 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__u16 AndXOffset;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
793
  } __attribute__((packed)) LOGOFF_ANDX_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
794
795
796
797
798
799
800
  
  typedef struct smb_com_logoff_andx_rsp {
  	struct smb_hdr hdr;	/* wct = 2 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__u16 AndXOffset;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
801
  } __attribute__((packed)) LOGOFF_ANDX_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
802

50c2f7538   Steve French   [CIFS] whitespace...
803
  typedef union smb_com_tree_disconnect {	/* as an altetnative can use flag on
86c96b4bb   Steve French   [CIFS] Fix mknod ...
804
805
  					tree_connect PDU to effect disconnect */
  					/* tdis is probably simplest SMB PDU */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
806
807
808
  	struct {
  		struct smb_hdr hdr;	/* wct = 0 */
  		__u16 ByteCount;	/* bcc = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
809
  	} __attribute__((packed)) req;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
810
811
812
  	struct {
  		struct smb_hdr hdr;	/* wct = 0 */
  		__u16 ByteCount;	/* bcc = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
813
814
  	} __attribute__((packed)) resp;
  } __attribute__((packed)) TREE_DISCONNECT;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
815
816
817
818
  
  typedef struct smb_com_close_req {
  	struct smb_hdr hdr;	/* wct = 3 */
  	__u16 FileID;
b815f1e55   Steve French   [CIFS] Allow for ...
819
  	__u32 LastWriteTime;	/* should be zero or -1 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
820
  	__u16 ByteCount;	/* 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
821
  } __attribute__((packed)) CLOSE_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
822
823
824
825
  
  typedef struct smb_com_close_rsp {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__u16 ByteCount;	/* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
826
  } __attribute__((packed)) CLOSE_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
827

b298f2235   Steve French   [CIFS] Send SMB f...
828
829
830
831
832
  typedef struct smb_com_flush_req {
  	struct smb_hdr hdr;	/* wct = 1 */
  	__u16 FileID;
  	__u16 ByteCount;	/* 0 */
  } __attribute__((packed)) FLUSH_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
833
834
835
836
  typedef struct smb_com_findclose_req {
  	struct smb_hdr hdr; /* wct = 1 */
  	__u16 FileID;
  	__u16 ByteCount;    /* 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
837
  } __attribute__((packed)) FINDCLOSE_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
838
839
  
  /* OpenFlags */
a9d02ad49   Steve French   [CIFS] Support fo...
840
  #define REQ_MORE_INFO      0x00000001  /* legacy (OPEN_AND_X) only */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
841
842
843
  #define REQ_OPLOCK         0x00000002
  #define REQ_BATCHOPLOCK    0x00000004
  #define REQ_OPENDIRONLY    0x00000008
75865f8cc   Steve French   [CIFS] Add in som...
844
  #define REQ_EXTENDED_INFO  0x00000010
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
845

92ad9b93c   Steve French   [CIFS] named pipe...
846
847
848
849
850
851
852
  /* File type */
  #define DISK_TYPE		0x0000
  #define BYTE_PIPE_TYPE		0x0001
  #define MESSAGE_PIPE_TYPE	0x0002
  #define PRINTER_TYPE		0x0003
  #define COMM_DEV_TYPE		0x0004
  #define UNKNOWN_TYPE		0xFFFF
675c46796   Steve French   [CIFS] Add variou...
853
854
855
856
857
858
859
860
  /* Device Type or File Status Flags */
  #define NO_EAS			0x0001
  #define NO_SUBSTREAMS		0x0002
  #define NO_REPARSETAG		0x0004
  /* following flags can apply if pipe */
  #define ICOUNT_MASK		0x00FF
  #define PIPE_READ_MODE		0x0100
  #define NAMED_PIPE_TYPE		0x0400
b7206153f   Steve French   [CIFS] Correct in...
861
  #define PIPE_END_POINT		0x4000
675c46796   Steve French   [CIFS] Add variou...
862
  #define BLOCKING_NAMED_PIPE	0x8000
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
863
864
865
866
867
868
869
870
  typedef struct smb_com_open_req {	/* also handles create */
  	struct smb_hdr hdr;	/* wct = 24 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u8 Reserved;		/* Must Be Zero */
  	__le16 NameLength;
  	__le32 OpenFlags;
675c46796   Steve French   [CIFS] Add variou...
871
  	__u32  RootDirectoryFid;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
872
873
874
875
876
877
878
879
880
881
  	__le32 DesiredAccess;
  	__le64 AllocationSize;
  	__le32 FileAttributes;
  	__le32 ShareAccess;
  	__le32 CreateDisposition;
  	__le32 CreateOptions;
  	__le32 ImpersonationLevel;
  	__u8 SecurityFlags;
  	__le16 ByteCount;
  	char fileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
882
  } __attribute__((packed)) OPEN_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
  
  /* open response: oplock levels */
  #define OPLOCK_NONE  	 0
  #define OPLOCK_EXCLUSIVE 1
  #define OPLOCK_BATCH	 2
  #define OPLOCK_READ	 3  /* level 2 oplock */
  
  /* open response for CreateAction shifted left */
  #define CIFS_CREATE_ACTION 0x20000 /* file created */
  
  typedef struct smb_com_open_rsp {
  	struct smb_hdr hdr;	/* wct = 34 BB */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u8 OplockLevel;
  	__u16 Fid;
  	__le32 CreateAction;
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le32 FileAttributes;
  	__le64 AllocationSize;
  	__le64 EndOfFile;
  	__le16 FileType;
  	__le16 DeviceState;
  	__u8 DirectoryFlag;
  	__u16 ByteCount;	/* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
912
  } __attribute__((packed)) OPEN_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
913

675c46796   Steve French   [CIFS] Add variou...
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
  typedef struct smb_com_open_rsp_ext {
  	struct smb_hdr hdr;     /* wct = 42 but meaningless due to MS bug? */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u8 OplockLevel;
  	__u16 Fid;
  	__le32 CreateAction;
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le32 FileAttributes;
  	__le64 AllocationSize;
  	__le64 EndOfFile;
  	__le16 FileType;
  	__le16 DeviceState;
  	__u8 DirectoryFlag;
  	__u8 VolumeGUID[16];
  	__u64 FileId; /* note no endian conversion - is opaque UniqueID */
  	__le32 MaximalAccessRights;
  	__le32 GuestMaximalAccessRights;
  	__u16 ByteCount;        /* bct = 0 */
  } __attribute__((packed)) OPEN_RSP_EXT;
a9d02ad49   Steve French   [CIFS] Support fo...
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
  /* format of legacy open request */
  typedef struct smb_com_openx_req {
  	struct smb_hdr	hdr;	/* wct = 15 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__le16 OpenFlags;
  	__le16 Mode;
  	__le16 Sattr; /* search attributes */
  	__le16 FileAttributes;  /* dos attrs */
  	__le32 CreateTime; /* os2 format */
  	__le16 OpenFunction;
  	__le32 EndOfFile;
  	__le32 Timeout;
  	__le32 Reserved;
70ca734a1   Steve French   [CIFS] Various mi...
953
  	__le16  ByteCount;  /* file name follows */
a9d02ad49   Steve French   [CIFS] Support fo...
954
  	char   fileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
955
  } __attribute__((packed)) OPENX_REQ;
a9d02ad49   Steve French   [CIFS] Support fo...
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
  
  typedef struct smb_com_openx_rsp {
  	struct smb_hdr	hdr;	/* wct = 15 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16  Fid;
  	__le16 FileAttributes;
  	__le32 LastWriteTime; /* os2 format */
  	__le32 EndOfFile;
  	__le16 Access;
  	__le16 FileType;
  	__le16 IPCState;
  	__le16 Action;
  	__u32  FileId;
  	__u16  Reserved;
  	__u16  ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
973
  } __attribute__((packed)) OPENX_RSP;
a9d02ad49   Steve French   [CIFS] Support fo...
974

595dcfecf   Steve French   [CIFS] POSIX CIFS...
975
  /* For encoding of POSIX Open Request - see trans2 function 0x209 data struct */
a9d02ad49   Steve French   [CIFS] Support fo...
976
977
  /* Legacy write request for older servers */
  typedef struct smb_com_writex_req {
50c2f7538   Steve French   [CIFS] whitespace...
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
  	struct smb_hdr hdr;     /* wct = 12 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16 Fid;
  	__le32 OffsetLow;
  	__u32 Reserved; /* Timeout */
  	__le16 WriteMode; /* 1 = write through */
  	__le16 Remaining;
  	__le16 Reserved2;
  	__le16 DataLengthLow;
  	__le16 DataOffset;
  	__le16 ByteCount;
  	__u8 Pad;		/* BB check for whether padded to DWORD
  				   boundary and optimum performance here */
  	char Data[0];
0753ca7bc   Steve French   [CIFS] Change pra...
994
  } __attribute__((packed)) WRITEX_REQ;
a9d02ad49   Steve French   [CIFS] Support fo...
995

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
  typedef struct smb_com_write_req {
  	struct smb_hdr hdr;	/* wct = 14 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16 Fid;
  	__le32 OffsetLow;
  	__u32 Reserved;
  	__le16 WriteMode;
  	__le16 Remaining;
  	__le16 DataLengthHigh;
  	__le16 DataLengthLow;
  	__le16 DataOffset;
  	__le32 OffsetHigh;
  	__le16 ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
1011
1012
  	__u8 Pad;		/* BB check for whether padded to DWORD
  				   boundary and optimum performance here */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1013
  	char Data[0];
0753ca7bc   Steve French   [CIFS] Change pra...
1014
  } __attribute__((packed)) WRITE_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
  
  typedef struct smb_com_write_rsp {
  	struct smb_hdr hdr;	/* wct = 6 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__le16 Count;
  	__le16 Remaining;
  	__le16 CountHigh;
  	__u16  Reserved;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1026
  } __attribute__((packed)) WRITE_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1027

a9d02ad49   Steve French   [CIFS] Support fo...
1028
1029
  /* legacy read request for older servers */
  typedef struct smb_com_readx_req {
50c2f7538   Steve French   [CIFS] whitespace...
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
  	struct smb_hdr hdr;	/* wct = 10 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16 Fid;
  	__le32 OffsetLow;
  	__le16 MaxCount;
  	__le16 MinCount;	/* obsolete */
  	__le32 Reserved;
  	__le16 Remaining;
  	__le16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1041
  } __attribute__((packed)) READX_REQ;
a9d02ad49   Steve French   [CIFS] Support fo...
1042

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
  typedef struct smb_com_read_req {
  	struct smb_hdr hdr;	/* wct = 12 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16 Fid;
  	__le32 OffsetLow;
  	__le16 MaxCount;
  	__le16 MinCount;		/* obsolete */
  	__le32 MaxCountHigh;
  	__le16 Remaining;
  	__le32 OffsetHigh;
  	__le16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1056
  } __attribute__((packed)) READ_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
  
  typedef struct smb_com_read_rsp {
  	struct smb_hdr hdr;	/* wct = 12 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__le16 Remaining;
  	__le16 DataCompactionMode;
  	__le16 Reserved;
  	__le16 DataLength;
  	__le16 DataOffset;
  	__le16 DataLengthHigh;
  	__u64 Reserved2;
  	__u16 ByteCount;
2ab2593f4   Jeff Layton   cifs: fix protoco...
1071
  	/* read response data immediately follows */
0753ca7bc   Steve French   [CIFS] Change pra...
1072
  } __attribute__((packed)) READ_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1073
1074
1075
1076
1077
1078
1079
1080
  
  typedef struct locking_andx_range {
  	__le16 Pid;
  	__le16 Pad;
  	__le32 OffsetHigh;
  	__le32 OffsetLow;
  	__le32 LengthHigh;
  	__le32 LengthLow;
0753ca7bc   Steve French   [CIFS] Change pra...
1081
  } __attribute__((packed)) LOCKING_ANDX_RANGE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
  
  #define LOCKING_ANDX_SHARED_LOCK     0x01
  #define LOCKING_ANDX_OPLOCK_RELEASE  0x02
  #define LOCKING_ANDX_CHANGE_LOCKTYPE 0x04
  #define LOCKING_ANDX_CANCEL_LOCK     0x08
  #define LOCKING_ANDX_LARGE_FILES     0x10	/* always on for us */
  
  typedef struct smb_com_lock_req {
  	struct smb_hdr hdr;	/* wct = 8 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16 Fid;
  	__u8 LockType;
  	__u8 OplockLevel;
  	__le32 Timeout;
  	__le16 NumberOfUnlocks;
  	__le16 NumberOfLocks;
  	__le16 ByteCount;
  	LOCKING_ANDX_RANGE Locks[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1102
  } __attribute__((packed)) LOCK_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1103

08547b036   Steve French   [CIFS] Add posix ...
1104
1105
1106
1107
  /* lock type */
  #define CIFS_RDLCK	0
  #define CIFS_WRLCK	1
  #define CIFS_UNLCK      2
f654bac22   Steve French   [PATCH] cifs: add...
1108
1109
1110
1111
1112
1113
1114
  typedef struct cifs_posix_lock {
  	__le16  lock_type;  /* 0 = Read, 1 = Write, 2 = Unlock */
  	__le16  lock_flags; /* 1 = Wait (only valid for setlock) */
  	__le32  pid;
  	__le64	start;
  	__le64	length;
  	/* BB what about additional owner info to identify network client */
0753ca7bc   Steve French   [CIFS] Change pra...
1115
  } __attribute__((packed)) CIFS_POSIX_LOCK;
f654bac22   Steve French   [PATCH] cifs: add...
1116

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1117
1118
1119
1120
1121
1122
  typedef struct smb_com_lock_rsp {
  	struct smb_hdr hdr;	/* wct = 2 */
  	__u8 AndXCommand;
  	__u8 AndXReserved;
  	__le16 AndXOffset;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1123
  } __attribute__((packed)) LOCK_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1124
1125
1126
1127
1128
1129
1130
1131
1132
  
  typedef struct smb_com_rename_req {
  	struct smb_hdr hdr;	/* wct = 1 */
  	__le16 SearchAttributes;	/* target file attributes */
  	__le16 ByteCount;
  	__u8 BufferFormat;	/* 4 = ASCII or Unicode */
  	unsigned char OldFileName[1];
  	/* followed by __u8 BufferFormat2 */
  	/* followed by NewFileName */
0753ca7bc   Steve French   [CIFS] Change pra...
1133
  } __attribute__((packed)) RENAME_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1134
1135
1136
1137
1138
1139
1140
  
  	/* copy request flags */
  #define COPY_MUST_BE_FILE      0x0001
  #define COPY_MUST_BE_DIR       0x0002
  #define COPY_TARGET_MODE_ASCII 0x0004 /* if not set, binary */
  #define COPY_SOURCE_MODE_ASCII 0x0008 /* if not set, binary */
  #define COPY_VERIFY_WRITES     0x0010
50c2f7538   Steve French   [CIFS] whitespace...
1141
  #define COPY_TREE              0x0020
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1142
1143
1144
1145
1146
1147
1148
  
  typedef struct smb_com_copy_req {
  	struct smb_hdr hdr;	/* wct = 3 */
  	__u16 Tid2;
  	__le16 OpenFunction;
  	__le16 Flags;
  	__le16 ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
1149
  	__u8 BufferFormat;	/* 4 = ASCII or Unicode */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1150
1151
1152
  	unsigned char OldFileName[1];
  	/* followed by __u8 BufferFormat2 */
  	/* followed by NewFileName string */
0753ca7bc   Steve French   [CIFS] Change pra...
1153
  } __attribute__((packed)) COPY_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1154
1155
1156
1157
1158
1159
1160
  
  typedef struct smb_com_copy_rsp {
  	struct smb_hdr hdr;     /* wct = 1 */
  	__le16 CopyCount;    /* number of files copied */
  	__u16 ByteCount;    /* may be zero */
  	__u8 BufferFormat;  /* 0x04 - only present if errored file follows */
  	unsigned char ErrorFileName[1]; /* only present if error in copy */
0753ca7bc   Steve French   [CIFS] Change pra...
1161
  } __attribute__((packed)) COPY_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
  
  #define CREATE_HARD_LINK		0x103
  #define MOVEFILE_COPY_ALLOWED		0x0002
  #define MOVEFILE_REPLACE_EXISTING	0x0001
  
  typedef struct smb_com_nt_rename_req {	/* A5 - also used for create hardlink */
  	struct smb_hdr hdr;	/* wct = 4 */
  	__le16 SearchAttributes;	/* target file attributes */
  	__le16 Flags;		/* spec says Information Level */
  	__le32 ClusterCount;
  	__le16 ByteCount;
  	__u8 BufferFormat;	/* 4 = ASCII or Unicode */
  	unsigned char OldFileName[1];
  	/* followed by __u8 BufferFormat2 */
  	/* followed by NewFileName */
0753ca7bc   Steve French   [CIFS] Change pra...
1177
  } __attribute__((packed)) NT_RENAME_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1178
1179
1180
1181
  
  typedef struct smb_com_rename_rsp {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__u16 ByteCount;	/* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
1182
  } __attribute__((packed)) RENAME_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1183
1184
1185
1186
1187
1188
1189
  
  typedef struct smb_com_delete_file_req {
  	struct smb_hdr hdr;	/* wct = 1 */
  	__le16 SearchAttributes;
  	__le16 ByteCount;
  	__u8 BufferFormat;	/* 4 = ASCII */
  	unsigned char fileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1190
  } __attribute__((packed)) DELETE_FILE_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1191
1192
1193
1194
  
  typedef struct smb_com_delete_file_rsp {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__u16 ByteCount;	/* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
1195
  } __attribute__((packed)) DELETE_FILE_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1196
1197
1198
1199
1200
1201
  
  typedef struct smb_com_delete_directory_req {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__le16 ByteCount;
  	__u8 BufferFormat;	/* 4 = ASCII */
  	unsigned char DirName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1202
  } __attribute__((packed)) DELETE_DIRECTORY_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1203
1204
1205
1206
  
  typedef struct smb_com_delete_directory_rsp {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__u16 ByteCount;	/* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
1207
  } __attribute__((packed)) DELETE_DIRECTORY_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1208
1209
1210
1211
1212
1213
  
  typedef struct smb_com_create_directory_req {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__le16 ByteCount;
  	__u8 BufferFormat;	/* 4 = ASCII */
  	unsigned char DirName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1214
  } __attribute__((packed)) CREATE_DIRECTORY_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1215
1216
1217
1218
  
  typedef struct smb_com_create_directory_rsp {
  	struct smb_hdr hdr;	/* wct = 0 */
  	__u16 ByteCount;	/* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
1219
  } __attribute__((packed)) CREATE_DIRECTORY_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1220

6b8edfe0f   Steve French   [CIFS] Support fo...
1221
1222
1223
1224
1225
  typedef struct smb_com_query_information_req {
  	struct smb_hdr hdr;     /* wct = 0 */
  	__le16 ByteCount;	/* 1 + namelen + 1 */
  	__u8 BufferFormat;      /* 4 = ASCII */
  	unsigned char FileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1226
  } __attribute__((packed)) QUERY_INFORMATION_REQ;
6b8edfe0f   Steve French   [CIFS] Support fo...
1227
1228
1229
1230
1231
1232
1233
1234
  
  typedef struct smb_com_query_information_rsp {
  	struct smb_hdr hdr;     /* wct = 10 */
  	__le16 attr;
  	__le32  last_write_time;
  	__le32 size;
  	__u16  reserved[5];
  	__le16 ByteCount;	/* bcc = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
1235
  } __attribute__((packed)) QUERY_INFORMATION_RSP;
6b8edfe0f   Steve French   [CIFS] Support fo...
1236

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1237
1238
1239
1240
1241
1242
1243
1244
1245
  typedef struct smb_com_setattr_req {
  	struct smb_hdr hdr; /* wct = 8 */
  	__le16 attr;
  	__le16 time_low;
  	__le16 time_high;
  	__le16 reserved[5]; /* must be zero */
  	__u16  ByteCount;
  	__u8   BufferFormat; /* 4 = ASCII */
  	unsigned char fileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1246
  } __attribute__((packed)) SETATTR_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1247
1248
1249
1250
  
  typedef struct smb_com_setattr_rsp {
  	struct smb_hdr hdr;     /* wct = 0 */
  	__u16 ByteCount;        /* bct = 0 */
0753ca7bc   Steve French   [CIFS] Change pra...
1251
  } __attribute__((packed)) SETATTR_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1252
1253
  
  /* empty wct response to setattr */
0a4b92c05   Steve French   [CIFS] Add worker...
1254
  /*******************************************************/
6070d81eb   Adam Buchbinder   tree-wide: fix mi...
1255
  /* NT Transact structure definitions follow            */
50c2f7538   Steve French   [CIFS] whitespace...
1256
  /* Currently only ioctl, acl (get security descriptor) */
0a4b92c05   Steve French   [CIFS] Add worker...
1257
1258
1259
  /* and notify are implemented                          */
  /*******************************************************/
  typedef struct smb_com_ntransact_req {
50c2f7538   Steve French   [CIFS] whitespace...
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
  	struct smb_hdr hdr; /* wct >= 19 */
  	__u8 MaxSetupCount;
  	__u16 Reserved;
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 MaxParameterCount;
  	__le32 MaxDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__u8 SetupCount; /* four setup words follow subcommand */
  	/* SNIA spec incorrectly included spurious pad here */
  	__le16 SubCommand; /* 2 = IOCTL/FSCTL */
  	/* SetupCount words follow then */
  	__le16 ByteCount;
  	__u8 Pad[3];
  	__u8 Parms[0];
0a4b92c05   Steve French   [CIFS] Add worker...
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
  } __attribute__((packed)) NTRANSACT_REQ;
  
  typedef struct smb_com_ntransact_rsp {
  	struct smb_hdr hdr;     /* wct = 18 */
  	__u8 Reserved[3];
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 ParameterDisplacement;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__le32 DataDisplacement;
  	__u8 SetupCount;   /* 0 */
  	__u16 ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
1293
  	/* __u8 Pad[3]; */
0a4b92c05   Steve French   [CIFS] Add worker...
1294
1295
  	/* parms and data follow */
  } __attribute__((packed)) NTRANSACT_RSP;
be7457d38   Steve French   Update headers to...
1296
1297
1298
1299
1300
1301
1302
  /* See MS-SMB 2.2.7.2.1.1 */
  struct srv_copychunk {
  	__le64 SourceOffset;
  	__le64 DestinationOffset;
  	__le32 CopyLength;
  	__u32  Reserved;
  } __packed;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
  typedef struct smb_com_transaction_ioctl_req {
  	struct smb_hdr hdr;	/* wct = 23 */
  	__u8 MaxSetupCount;
  	__u16 Reserved;
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 MaxParameterCount;
  	__le32 MaxDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__u8 SetupCount; /* four setup words follow subcommand */
  	/* SNIA spec incorrectly included spurious pad here */
0a4b92c05   Steve French   [CIFS] Add worker...
1317
  	__le16 SubCommand; /* 2 = IOCTL/FSCTL */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1318
1319
  	__le32 FunctionCode;
  	__u16 Fid;
0a4b92c05   Steve French   [CIFS] Add worker...
1320
1321
  	__u8 IsFsctl;  /* 1 = File System Control 0 = device control (IOCTL) */
  	__u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1322
1323
1324
  	__le16 ByteCount;
  	__u8 Pad[3];
  	__u8 Data[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1325
  } __attribute__((packed)) TRANSACT_IOCTL_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1326

c7f508a99   Steve French   Allow setting per...
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
  typedef struct smb_com_transaction_compr_ioctl_req {
  	struct smb_hdr hdr;	/* wct = 23 */
  	__u8 MaxSetupCount;
  	__u16 Reserved;
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 MaxParameterCount;
  	__le32 MaxDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__u8 SetupCount; /* four setup words follow subcommand */
  	/* SNIA spec incorrectly included spurious pad here */
  	__le16 SubCommand; /* 2 = IOCTL/FSCTL */
  	__le32 FunctionCode;
  	__u16 Fid;
  	__u8 IsFsctl;  /* 1 = File System Control 0 = device control (IOCTL) */
  	__u8 IsRootFlag; /* 1 = apply command to root of share (must be DFS) */
  	__le16 ByteCount;
  	__u8 Pad[3];
  	__le16 compression_state;  /* See below for valid flags */
  } __attribute__((packed)) TRANSACT_COMPR_IOCTL_REQ;
  
  /* compression state flags */
  #define COMPRESSION_FORMAT_NONE		0x0000
  #define COMPRESSION_FORMAT_DEFAULT	0x0001
  #define COMPRESSION_FORMAT_LZNT1	0x0002
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
  typedef struct smb_com_transaction_ioctl_rsp {
  	struct smb_hdr hdr;	/* wct = 19 */
  	__u8 Reserved[3];
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 ParameterDisplacement;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__le32 DataDisplacement;
  	__u8 SetupCount;	/* 1 */
  	__le16 ReturnedDataLen;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1369
  } __attribute__((packed)) TRANSACT_IOCTL_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1370

0a4b92c05   Steve French   [CIFS] Add worker...
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
  #define CIFS_ACL_OWNER 1
  #define CIFS_ACL_GROUP 2
  #define CIFS_ACL_DACL  4
  #define CIFS_ACL_SACL  8
  
  typedef struct smb_com_transaction_qsec_req {
  	struct smb_hdr hdr;     /* wct = 19 */
  	__u8 MaxSetupCount;
  	__u16 Reserved;
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 MaxParameterCount;
  	__le32 MaxDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__u8 SetupCount; /* no setup words follow subcommand */
  	/* SNIA spec incorrectly included spurious pad here */
  	__le16 SubCommand; /* 6 = QUERY_SECURITY_DESC */
  	__le16 ByteCount; /* bcc = 3 + 8 */
  	__u8 Pad[3];
  	__u16 Fid;
  	__u16 Reserved2;
  	__le32 AclFlags;
  } __attribute__((packed)) QUERY_SEC_DESC_REQ;
7505e0525   Steve French   [CIFS] If no Acce...
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
  
  typedef struct smb_com_transaction_ssec_req {
  	struct smb_hdr hdr;     /* wct = 19 */
  	__u8 MaxSetupCount;
  	__u16 Reserved;
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 MaxParameterCount;
  	__le32 MaxDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__u8 SetupCount; /* no setup words follow subcommand */
  	/* SNIA spec incorrectly included spurious pad here */
  	__le16 SubCommand; /* 3 = SET_SECURITY_DESC */
  	__le16 ByteCount; /* bcc = 3 + 8 */
  	__u8 Pad[3];
  	__u16 Fid;
  	__u16 Reserved2;
  	__le32 AclFlags;
  } __attribute__((packed)) SET_SEC_DESC_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
  typedef struct smb_com_transaction_change_notify_req {
  	struct smb_hdr hdr;     /* wct = 23 */
  	__u8 MaxSetupCount;
  	__u16 Reserved;
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 MaxParameterCount;
  	__le32 MaxDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__u8 SetupCount; /* four setup words follow subcommand */
  	/* SNIA spec incorrectly included spurious pad here */
  	__le16 SubCommand;/* 4 = Change Notify */
  	__le32 CompletionFilter;  /* operation to monitor */
  	__u16 Fid;
  	__u8 WatchTree;  /* 1 = Monitor subdirectories */
  	__u8 Reserved2;
  	__le16 ByteCount;
0a4b92c05   Steve French   [CIFS] Add worker...
1439
  /* 	__u8 Pad[3];*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1440
  /*	__u8 Data[1];*/
0753ca7bc   Steve French   [CIFS] Change pra...
1441
  } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1442

50c2f7538   Steve French   [CIFS] whitespace...
1443
  /* BB eventually change to use generic ntransact rsp struct
0a4b92c05   Steve French   [CIFS] Add worker...
1444
        and validation routine */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
  typedef struct smb_com_transaction_change_notify_rsp {
  	struct smb_hdr hdr;	/* wct = 18 */
  	__u8 Reserved[3];
  	__le32 TotalParameterCount;
  	__le32 TotalDataCount;
  	__le32 ParameterCount;
  	__le32 ParameterOffset;
  	__le32 ParameterDisplacement;
  	__le32 DataCount;
  	__le32 DataOffset;
  	__le32 DataDisplacement;
  	__u8 SetupCount;   /* 0 */
  	__u16 ByteCount;
  	/* __u8 Pad[3]; */
0753ca7bc   Steve French   [CIFS] Change pra...
1459
  } __attribute__((packed)) TRANSACT_CHANGE_NOTIFY_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
  /* Completion Filter flags for Notify */
  #define FILE_NOTIFY_CHANGE_FILE_NAME    0x00000001
  #define FILE_NOTIFY_CHANGE_DIR_NAME     0x00000002
  #define FILE_NOTIFY_CHANGE_NAME         0x00000003
  #define FILE_NOTIFY_CHANGE_ATTRIBUTES   0x00000004
  #define FILE_NOTIFY_CHANGE_SIZE         0x00000008
  #define FILE_NOTIFY_CHANGE_LAST_WRITE   0x00000010
  #define FILE_NOTIFY_CHANGE_LAST_ACCESS  0x00000020
  #define FILE_NOTIFY_CHANGE_CREATION     0x00000040
  #define FILE_NOTIFY_CHANGE_EA           0x00000080
  #define FILE_NOTIFY_CHANGE_SECURITY     0x00000100
  #define FILE_NOTIFY_CHANGE_STREAM_NAME  0x00000200
  #define FILE_NOTIFY_CHANGE_STREAM_SIZE  0x00000400
  #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
  
  #define FILE_ACTION_ADDED		0x00000001
  #define FILE_ACTION_REMOVED		0x00000002
  #define FILE_ACTION_MODIFIED		0x00000003
  #define FILE_ACTION_RENAMED_OLD_NAME	0x00000004
  #define FILE_ACTION_RENAMED_NEW_NAME	0x00000005
  #define FILE_ACTION_ADDED_STREAM	0x00000006
  #define FILE_ACTION_REMOVED_STREAM	0x00000007
  #define FILE_ACTION_MODIFIED_STREAM	0x00000008
  
  /* response contains array of the following structures */
  struct file_notify_information {
  	__le32 NextEntryOffset;
  	__le32 Action;
  	__le32 FileNameLength;
  	__u8  FileName[0];
50c2f7538   Steve French   [CIFS] whitespace...
1490
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1491

c31f33071   Steve French   do not treat non-...
1492
1493
1494
1495
  /* For IO_REPARSE_TAG_SYMLINK */
  struct reparse_symlink_data {
  	__le32	ReparseTag;
  	__le16	ReparseDataLength;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1496
  	__u16	Reserved;
c31f33071   Steve French   do not treat non-...
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
  	__le16	SubstituteNameOffset;
  	__le16	SubstituteNameLength;
  	__le16	PrintNameOffset;
  	__le16	PrintNameLength;
  	__le32	Flags;
  	char	PathBuffer[0];
  } __attribute__((packed));
  
  /* For IO_REPARSE_TAG_NFS */
  #define NFS_SPECFILE_LNK	0x00000000014B4E4C
  #define NFS_SPECFILE_CHR	0x0000000000524843
  #define NFS_SPECFILE_BLK	0x00000000004B4C42
  #define NFS_SPECFILE_FIFO	0x000000004F464946
  #define NFS_SPECFILE_SOCK	0x000000004B434F53
  struct reparse_posix_data {
  	__le32	ReparseTag;
  	__le16	ReparseDataLength;
  	__u16	Reserved;
  	__le64	InodeType; /* LNK, FIFO, CHR etc. */
d244bf2df   Pavel Shilovsky   CIFS: Implement f...
1516
  	char	PathBuffer[0];
0753ca7bc   Steve French   [CIFS] Change pra...
1517
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1518
1519
1520
1521
1522
1523
1524
1525
1526
  
  struct cifs_quota_data {
  	__u32	rsrvd1;  /* 0 */
  	__u32	sid_size;
  	__u64	rsrvd2;  /* 0 */
  	__u64	space_used;
  	__u64	soft_limit;
  	__u64	hard_limit;
  	char	sid[1];  /* variable size? */
0753ca7bc   Steve French   [CIFS] Change pra...
1527
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
  
  /* quota sub commands */
  #define QUOTA_LIST_CONTINUE	    0
  #define QUOTA_LIST_START	0x100
  #define QUOTA_FOR_SID		0x101
  
  struct trans2_req {
  	/* struct smb_hdr hdr precedes. Set wct = 14+ */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;
  	__u8 Reserved3;
  	__le16 SubCommand; /* 1st setup word - SetupCount words follow */
  	__le16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1553
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1554
1555
1556
1557
  
  struct smb_t2_req {
  	struct smb_hdr hdr;
  	struct trans2_req t2_req;
0753ca7bc   Steve French   [CIFS] Change pra...
1558
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
  
  struct trans2_resp {
  	/* struct smb_hdr hdr precedes. Note wct = 10 + setup count */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__u16 Reserved;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 ParameterDisplacement;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__le16 DataDisplacement;
  	__u8 SetupCount;
  	__u8 Reserved1;
  	/* SetupWords[SetupCount];
  	__u16 ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
1575
  	__u16 Reserved2;*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1576
  	/* data area follows */
0753ca7bc   Steve French   [CIFS] Change pra...
1577
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1578
1579
1580
1581
  
  struct smb_t2_rsp {
  	struct smb_hdr hdr;
  	struct trans2_resp t2_rsp;
0753ca7bc   Steve French   [CIFS] Change pra...
1582
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
  
  /* PathInfo/FileInfo infolevels */
  #define SMB_INFO_STANDARD                   1
  #define SMB_SET_FILE_EA                     2
  #define SMB_QUERY_FILE_EA_SIZE              2
  #define SMB_INFO_QUERY_EAS_FROM_LIST        3
  #define SMB_INFO_QUERY_ALL_EAS              4
  #define SMB_INFO_IS_NAME_VALID              6
  #define SMB_QUERY_FILE_BASIC_INFO       0x101
  #define SMB_QUERY_FILE_STANDARD_INFO    0x102
  #define SMB_QUERY_FILE_EA_INFO          0x103
  #define SMB_QUERY_FILE_NAME_INFO        0x104
  #define SMB_QUERY_FILE_ALLOCATION_INFO  0x105
  #define SMB_QUERY_FILE_END_OF_FILEINFO  0x106
  #define SMB_QUERY_FILE_ALL_INFO         0x107
  #define SMB_QUERY_ALT_NAME_INFO         0x108
  #define SMB_QUERY_FILE_STREAM_INFO      0x109
  #define SMB_QUERY_FILE_COMPRESSION_INFO 0x10B
  #define SMB_QUERY_FILE_UNIX_BASIC       0x200
  #define SMB_QUERY_FILE_UNIX_LINK        0x201
  #define SMB_QUERY_POSIX_ACL             0x204
87f440e70   Steve French   [CIFS] Additional...
1604
  #define SMB_QUERY_XATTR                 0x205  /* e.g. system EA name space */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1605
  #define SMB_QUERY_ATTR_FLAGS            0x206  /* append,immutable etc. */
f654bac22   Steve French   [PATCH] cifs: add...
1606
1607
  #define SMB_QUERY_POSIX_PERMISSION      0x207
  #define SMB_QUERY_POSIX_LOCK            0x208
87f440e70   Steve French   [CIFS] Additional...
1608
1609
1610
  /* #define SMB_POSIX_OPEN               0x209 */
  /* #define SMB_POSIX_UNLINK             0x20a */
  #define SMB_QUERY_FILE__UNIX_INFO2      0x20b
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1611
1612
1613
  #define SMB_QUERY_FILE_INTERNAL_INFO    0x3ee
  #define SMB_QUERY_FILE_ACCESS_INFO      0x3f0
  #define SMB_QUERY_FILE_NAME_INFO2       0x3f1 /* 0x30 bytes */
50c2f7538   Steve French   [CIFS] whitespace...
1614
  #define SMB_QUERY_FILE_POSITION_INFO    0x3f6
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1615
  #define SMB_QUERY_FILE_MODE_INFO        0x3f8
50c2f7538   Steve French   [CIFS] whitespace...
1616
  #define SMB_QUERY_FILE_ALGN_INFO        0x3f9
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
  
  
  #define SMB_SET_FILE_BASIC_INFO	        0x101
  #define SMB_SET_FILE_DISPOSITION_INFO   0x102
  #define SMB_SET_FILE_ALLOCATION_INFO    0x103
  #define SMB_SET_FILE_END_OF_FILE_INFO   0x104
  #define SMB_SET_FILE_UNIX_BASIC         0x200
  #define SMB_SET_FILE_UNIX_LINK          0x201
  #define SMB_SET_FILE_UNIX_HLINK         0x203
  #define SMB_SET_POSIX_ACL               0x204
  #define SMB_SET_XATTR                   0x205
  #define SMB_SET_ATTR_FLAGS              0x206  /* append, immutable etc. */
f654bac22   Steve French   [PATCH] cifs: add...
1629
  #define SMB_SET_POSIX_LOCK              0x208
2fe87f02a   Steve French   [CIFS] Support de...
1630
  #define SMB_POSIX_OPEN                  0x209
87f440e70   Steve French   [CIFS] Additional...
1631
  #define SMB_POSIX_UNLINK                0x20a
2dd29d313   Steve French   [CIFS] New CIFS P...
1632
  #define SMB_SET_FILE_UNIX_INFO2         0x20b
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1633
  #define SMB_SET_FILE_BASIC_INFO2        0x3ec
87f440e70   Steve French   [CIFS] Additional...
1634
  #define SMB_SET_FILE_RENAME_INFORMATION 0x3f2 /* BB check if qpathinfo too */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1635
1636
1637
1638
1639
1640
1641
1642
1643
  #define SMB_FILE_ALL_INFO2              0x3fa
  #define SMB_SET_FILE_ALLOCATION_INFO2   0x3fb
  #define SMB_SET_FILE_END_OF_FILE_INFO2  0x3fc
  #define SMB_FILE_MOVE_CLUSTER_INFO      0x407
  #define SMB_FILE_QUOTA_INFO             0x408
  #define SMB_FILE_REPARSEPOINT_INFO      0x409
  #define SMB_FILE_MAXIMUM_INFO           0x40d
  
  /* Find File infolevels */
5bafd7659   Steve French   [CIFS] Add suppor...
1644
1645
1646
  #define SMB_FIND_FILE_INFO_STANDARD       0x001
  #define SMB_FIND_FILE_QUERY_EA_SIZE       0x002
  #define SMB_FIND_FILE_QUERY_EAS_FROM_LIST 0x003
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
  #define SMB_FIND_FILE_DIRECTORY_INFO      0x101
  #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
  #define SMB_FIND_FILE_NAMES_INFO          0x103
  #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
  #define SMB_FIND_FILE_ID_FULL_DIR_INFO    0x105
  #define SMB_FIND_FILE_ID_BOTH_DIR_INFO    0x106
  #define SMB_FIND_FILE_UNIX                0x202
  
  typedef struct smb_com_transaction2_qpi_req {
  	struct smb_hdr hdr;	/* wct = 14+ */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;
  	__u8 Reserved3;
  	__le16 SubCommand;	/* one setup word */
  	__le16 ByteCount;
  	__u8 Pad;
  	__le16 InformationLevel;
  	__u32 Reserved4;
  	char FileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1678
  } __attribute__((packed)) TRANSACTION2_QPI_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1679
1680
1681
1682
1683
  
  typedef struct smb_com_transaction2_qpi_rsp {
  	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
  	struct trans2_resp t2;
  	__u16 ByteCount;
87f440e70   Steve French   [CIFS] Additional...
1684
  	__u16 Reserved2; /* parameter word is present for infolevels > 100 */
0753ca7bc   Steve French   [CIFS] Change pra...
1685
  } __attribute__((packed)) TRANSACTION2_QPI_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
  
  typedef struct smb_com_transaction2_spi_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;
  	__u8 Reserved3;
  	__le16 SubCommand;	/* one setup word */
  	__le16 ByteCount;
  	__u8 Pad;
  	__u16 Pad1;
  	__le16 InformationLevel;
  	__u32 Reserved4;
  	char FileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1711
  } __attribute__((packed)) TRANSACTION2_SPI_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1712
1713
1714
1715
1716
  
  typedef struct smb_com_transaction2_spi_rsp {
  	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
  	struct trans2_resp t2;
  	__u16 ByteCount;
87f440e70   Steve French   [CIFS] Additional...
1717
  	__u16 Reserved2; /* parameter word is present for infolevels > 100 */
0753ca7bc   Steve French   [CIFS] Change pra...
1718
  } __attribute__((packed)) TRANSACTION2_SPI_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1719
1720
1721
1722
1723
1724
  
  struct set_file_rename {
  	__le32 overwrite;   /* 1 = overwrite dest */
  	__u32 root_fid;   /* zero */
  	__le32 target_name_len;
  	char  target_name[0];  /* Must be unicode */
0753ca7bc   Steve French   [CIFS] Change pra...
1725
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
  
  struct smb_com_transaction2_sfi_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;
  	__u8 Reserved3;
  	__le16 SubCommand;	/* one setup word */
  	__le16 ByteCount;
  	__u8 Pad;
  	__u16 Pad1;
  	__u16 Fid;
  	__le16 InformationLevel;
50c2f7538   Steve French   [CIFS] whitespace...
1750
  	__u16 Reserved4;
0753ca7bc   Steve French   [CIFS] Change pra...
1751
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1752
1753
1754
1755
1756
  
  struct smb_com_transaction2_sfi_rsp {
  	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
  	struct trans2_resp t2;
  	__u16 ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
1757
  	__u16 Reserved2;	/* parameter word reserved -
f654bac22   Steve French   [PATCH] cifs: add...
1758
  					present for infolevels > 100 */
0753ca7bc   Steve French   [CIFS] Change pra...
1759
  } __attribute__((packed));
f654bac22   Steve French   [PATCH] cifs: add...
1760
1761
  
  struct smb_t2_qfi_req {
50c2f7538   Steve French   [CIFS] whitespace...
1762
1763
  	struct	smb_hdr hdr;
  	struct	trans2_req t2;
f654bac22   Steve French   [PATCH] cifs: add...
1764
  	__u8	Pad;
f654bac22   Steve French   [PATCH] cifs: add...
1765
1766
  	__u16	Fid;
  	__le16	InformationLevel;
0753ca7bc   Steve French   [CIFS] Change pra...
1767
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1768

f654bac22   Steve French   [PATCH] cifs: add...
1769
  struct smb_t2_qfi_rsp {
50c2f7538   Steve French   [CIFS] whitespace...
1770
1771
1772
1773
1774
  	struct smb_hdr hdr;     /* wct = 10 + SetupCount */
  	struct trans2_resp t2;
  	__u16 ByteCount;
  	__u16 Reserved2;        /* parameter word reserved -
  				   present for infolevels > 100 */
0753ca7bc   Steve French   [CIFS] Change pra...
1775
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1776
1777
  
  /*
50c2f7538   Steve French   [CIFS] whitespace...
1778
   * Flags on T2 FINDFIRST and FINDNEXT
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
   */
  #define CIFS_SEARCH_CLOSE_ALWAYS  0x0001
  #define CIFS_SEARCH_CLOSE_AT_END  0x0002
  #define CIFS_SEARCH_RETURN_RESUME 0x0004
  #define CIFS_SEARCH_CONTINUE_FROM_LAST 0x0008
  #define CIFS_SEARCH_BACKUP_SEARCH 0x0010
  
  /*
   * Size of the resume key on FINDFIRST and FINDNEXT calls
   */
  #define CIFS_SMB_RESUME_KEY_SIZE 4
  
  typedef struct smb_com_transaction2_ffirst_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;	/* one */
  	__u8 Reserved3;
  	__le16 SubCommand;	/* TRANS2_FIND_FIRST */
  	__le16 ByteCount;
  	__u8 Pad;
  	__le16 SearchAttributes;
  	__le16 SearchCount;
  	__le16 SearchFlags;
  	__le16 InformationLevel;
  	__le32 SearchStorageType;
  	char FileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1817
  } __attribute__((packed)) TRANSACTION2_FFIRST_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1818
1819
1820
1821
1822
  
  typedef struct smb_com_transaction2_ffirst_rsp {
  	struct smb_hdr hdr;	/* wct = 10 */
  	struct trans2_resp t2;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1823
  } __attribute__((packed)) TRANSACTION2_FFIRST_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1824
1825
1826
1827
1828
1829
1830
  
  typedef struct smb_com_transaction2_ffirst_rsp_parms {
  	__u16 SearchHandle;
  	__le16 SearchCount;
  	__le16 EndofSearch;
  	__le16 EAErrorOffset;
  	__le16 LastNameOffset;
0753ca7bc   Steve French   [CIFS] Change pra...
1831
  } __attribute__((packed)) T2_FFIRST_RSP_PARMS;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
  
  typedef struct smb_com_transaction2_fnext_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;	/* one */
  	__u8 Reserved3;
  	__le16 SubCommand;	/* TRANS2_FIND_NEXT */
  	__le16 ByteCount;
  	__u8 Pad;
  	__u16 SearchHandle;
  	__le16 SearchCount;
  	__le16 InformationLevel;
  	__u32 ResumeKey;
  	__le16 SearchFlags;
  	char ResumeFileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
1859
  } __attribute__((packed)) TRANSACTION2_FNEXT_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1860
1861
1862
1863
1864
  
  typedef struct smb_com_transaction2_fnext_rsp {
  	struct smb_hdr hdr;	/* wct = 10 */
  	struct trans2_resp t2;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
1865
  } __attribute__((packed)) TRANSACTION2_FNEXT_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1866
1867
1868
1869
1870
1871
  
  typedef struct smb_com_transaction2_fnext_rsp_parms {
  	__le16 SearchCount;
  	__le16 EndofSearch;
  	__le16 EAErrorOffset;
  	__le16 LastNameOffset;
0753ca7bc   Steve French   [CIFS] Change pra...
1872
  } __attribute__((packed)) T2_FNEXT_RSP_PARMS;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
  
  /* QFSInfo Levels */
  #define SMB_INFO_ALLOCATION         1
  #define SMB_INFO_VOLUME             2
  #define SMB_QUERY_FS_VOLUME_INFO    0x102
  #define SMB_QUERY_FS_SIZE_INFO      0x103
  #define SMB_QUERY_FS_DEVICE_INFO    0x104
  #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
  #define SMB_QUERY_CIFS_UNIX_INFO    0x200
  #define SMB_QUERY_POSIX_FS_INFO     0x201
87f440e70   Steve French   [CIFS] Additional...
1883
  #define SMB_QUERY_POSIX_WHO_AM_I    0x202
ee4987ab5   Steve French   [CIFS] Fix define...
1884
1885
  #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203
  #define SMB_QUERY_FS_PROXY          0x204 /* WAFS enabled. Returns structure
2302aca85   Steve French   [CIFS] Reserve ne...
1886
1887
1888
1889
  					    FILE_SYSTEM__UNIX_INFO to tell
  					    whether new NTIOCTL available
  					    (0xACE) for WAN friendly SMB
  					    operations to be carried */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
  #define SMB_QUERY_LABEL_INFO        0x3ea
  #define SMB_QUERY_FS_QUOTA_INFO     0x3ee
  #define SMB_QUERY_FS_FULL_SIZE_INFO 0x3ef
  #define SMB_QUERY_OBJECTID_INFO     0x3f0
  
  typedef struct smb_com_transaction2_qfsi_req {
  	struct smb_hdr hdr;	/* wct = 14+ */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;
  	__u8 Reserved3;
  	__le16 SubCommand;	/* one setup word */
  	__le16 ByteCount;
  	__u8 Pad;
  	__le16 InformationLevel;
0753ca7bc   Steve French   [CIFS] Change pra...
1916
  } __attribute__((packed)) TRANSACTION2_QFSI_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1917
1918
1919
1920
1921
  
  typedef struct smb_com_transaction_qfsi_rsp {
  	struct smb_hdr hdr;	/* wct = 10 + SetupCount */
  	struct trans2_resp t2;
  	__u16 ByteCount;
87f440e70   Steve French   [CIFS] Additional...
1922
  	__u8 Pad;	/* may be three bytes? *//* followed by data area */
0753ca7bc   Steve French   [CIFS] Change pra...
1923
  } __attribute__((packed)) TRANSACTION2_QFSI_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1924

87f440e70   Steve French   [CIFS] Additional...
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
  typedef struct whoami_rsp_data { /* Query level 0x202 */
  	__u32 flags; /* 0 = Authenticated user 1 = GUEST */
  	__u32 mask; /* which flags bits server understands ie 0x0001 */
  	__u64 unix_user_id;
  	__u64 unix_user_gid;
  	__u32 number_of_supplementary_gids; /* may be zero */
  	__u32 number_of_sids; /* may be zero */
  	__u32 length_of_sid_array; /* in bytes - may be zero */
  	__u32 pad; /* reserved - MBZ */
  	/* __u64 gid_array[0]; */  /* may be empty */
  	/* __u8 * psid_list */  /* may be empty */
  } __attribute__((packed)) WHOAMI_RSP_DATA;
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
1937
1938
1939
  
  /* SETFSInfo Levels */
  #define SMB_SET_CIFS_UNIX_INFO    0x200
96814ecb4   Steve French   Add definition fo...
1940
1941
1942
1943
  /* level 0x203 is defined above in list of QFS info levels */
  /* #define SMB_REQUEST_TRANSPORT_ENCRYPTION 0x203 */
  
  /* Level 0x200 request structure follows */
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
  typedef struct smb_com_transaction2_setfsi_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;	/* 4 */
  	__le16 ParameterOffset;
  	__le16 DataCount;	/* 12 */
  	__le16 DataOffset;
  	__u8 SetupCount;	/* one */
  	__u8 Reserved3;
  	__le16 SubCommand;	/* TRANS2_SET_FS_INFORMATION */
  	__le16 ByteCount;
  	__u8 Pad;
  	__u16 FileNum;		/* Parameters start. */
  	__le16 InformationLevel;/* Parameters end. */
  	__le16 ClientUnixMajor; /* Data start. */
  	__le16 ClientUnixMinor;
  	__le64 ClientUnixCap;   /* Data end */
0753ca7bc   Steve French   [CIFS] Change pra...
1969
  } __attribute__((packed)) TRANSACTION2_SETFSI_REQ;
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
1970

96814ecb4   Steve French   Add definition fo...
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
  /* level 0x203 request structure follows */
  typedef struct smb_com_transaction2_setfs_enc_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;	/* 4 */
  	__le16 ParameterOffset;
  	__le16 DataCount;	/* 12 */
  	__le16 DataOffset;
  	__u8 SetupCount;	/* one */
  	__u8 Reserved3;
  	__le16 SubCommand;	/* TRANS2_SET_FS_INFORMATION */
  	__le16 ByteCount;
  	__u8 Pad;
  	__u16  Reserved4;	/* Parameters start. */
  	__le16 InformationLevel;/* Parameters end. */
  	/* NTLMSSP Blob, Data start. */
  } __attribute__((packed)) TRANSACTION2_SETFSI_ENC_REQ;
  
  /* response for setfsinfo levels 0x200 and 0x203 */
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
1998
1999
2000
2001
  typedef struct smb_com_transaction2_setfsi_rsp {
  	struct smb_hdr hdr;	/* wct = 10 */
  	struct trans2_resp t2;
  	__u16 ByteCount;
0753ca7bc   Steve French   [CIFS] Change pra...
2002
  } __attribute__((packed)) TRANSACTION2_SETFSI_RSP;
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
2003

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
  typedef struct smb_com_transaction2_get_dfs_refer_req {
  	struct smb_hdr hdr;	/* wct = 15 */
  	__le16 TotalParameterCount;
  	__le16 TotalDataCount;
  	__le16 MaxParameterCount;
  	__le16 MaxDataCount;
  	__u8 MaxSetupCount;
  	__u8 Reserved;
  	__le16 Flags;
  	__le32 Timeout;
  	__u16 Reserved2;
  	__le16 ParameterCount;
  	__le16 ParameterOffset;
  	__le16 DataCount;
  	__le16 DataOffset;
  	__u8 SetupCount;
  	__u8 Reserved3;
  	__le16 SubCommand;	/* one setup word */
  	__le16 ByteCount;
50c2f7538   Steve French   [CIFS] whitespace...
2023
2024
2025
  	__u8 Pad[3];		/* Win2K has sent 0x0F01 (max response length
  				   perhaps?) followed by one byte pad - doesn't
  				   seem to matter though */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2026
2027
  	__le16 MaxReferralLevel;
  	char RequestFileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
2028
  } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_REQ;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2029

a1fe78f16   Steve French   [CIFS] Add missin...
2030
2031
2032
2033
2034
  #define DFS_VERSION cpu_to_le16(0x0003)
  
  /* DFS server target type */
  #define DFS_TYPE_LINK 0x0000  /* also for sysvol targets */
  #define DFS_TYPE_ROOT 0x0001
61e748015   Steve French   [CIFS] various mi...
2035

a1fe78f16   Steve French   [CIFS] Add missin...
2036
  /* Referral Entry Flags */
10e70afa7   Steve French   [CIFS] DFS no lon...
2037
2038
  #define DFS_NAME_LIST_REF 0x0200 /* set for domain or DC referral responses */
  #define DFS_TARGET_SET_BOUNDARY 0x0400 /* only valid with version 4 dfs req */
a1fe78f16   Steve French   [CIFS] Add missin...
2039

10e70afa7   Steve French   [CIFS] DFS no lon...
2040
2041
  typedef struct dfs_referral_level_3 { /* version 4 is same, + one flag bit */
  	__le16 VersionNumber;  /* must be 3 or 4 */
fec4585fd   Igor Mammedov   CIFSGetDFSRefer c...
2042
2043
  	__le16 Size;
  	__le16 ServerType; /* 0x0001 = root targets; 0x0000 = link targets */
10e70afa7   Steve French   [CIFS] DFS no lon...
2044
  	__le16 ReferralEntryFlags;
fec4585fd   Igor Mammedov   CIFSGetDFSRefer c...
2045
  	__le32 TimeToLive;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2046
2047
  	__le16 DfsPathOffset;
  	__le16 DfsAlternatePathOffset;
fec4585fd   Igor Mammedov   CIFSGetDFSRefer c...
2048
  	__le16 NetworkAddressOffset; /* offset of the link target */
10e70afa7   Steve French   [CIFS] DFS no lon...
2049
  	__u8   ServiceSiteGuid[16];  /* MBZ, ignored */
0753ca7bc   Steve French   [CIFS] Change pra...
2050
  } __attribute__((packed)) REFERRAL3;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2051
2052
2053
2054
2055
2056
2057
2058
  
  typedef struct smb_com_transaction_get_dfs_refer_rsp {
  	struct smb_hdr hdr;	/* wct = 10 */
  	struct trans2_resp t2;
  	__u16 ByteCount;
  	__u8 Pad;
  	__le16 PathConsumed;
  	__le16 NumberOfReferrals;
10e70afa7   Steve French   [CIFS] DFS no lon...
2059
  	__le32 DFSFlags;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2060
2061
  	REFERRAL3 referrals[1];	/* array of level 3 dfs_referral structures */
  	/* followed by the strings pointed to by the referral structures */
0753ca7bc   Steve French   [CIFS] Change pra...
2062
  } __attribute__((packed)) TRANSACTION2_GET_DFS_REFER_RSP;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2063
2064
  
  /* DFS Flags */
10e70afa7   Steve French   [CIFS] DFS no lon...
2065
2066
2067
  #define DFSREF_REFERRAL_SERVER  0x00000001 /* all targets are DFS roots */
  #define DFSREF_STORAGE_SERVER   0x00000002 /* no further ref requests needed */
  #define DFSREF_TARGET_FAILBACK  0x00000004 /* only for DFS referral version 4 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2068

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2069
2070
2071
  /*
   ************************************************************************
   * All structs for everything above the SMB PDUs themselves
50c2f7538   Steve French   [CIFS] whitespace...
2072
   * (such as the T2 level specific data) go here
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
   ************************************************************************
   */
  
  /*
   * Information on a server
   */
  
  struct serverInfo {
  	char name[16];
  	unsigned char versionMajor;
  	unsigned char versionMinor;
  	unsigned long type;
  	unsigned int commentOffset;
0753ca7bc   Steve French   [CIFS] Change pra...
2086
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
  
  /*
   * The following structure is the format of the data returned on a NetShareEnum
   * with level "90" (x5A)
   */
  
  struct shareInfo {
  	char shareName[13];
  	char pad;
  	unsigned short type;
  	unsigned int commentOffset;
0753ca7bc   Steve French   [CIFS] Change pra...
2098
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2099
2100
2101
2102
2103
2104
  
  struct aliasInfo {
  	char aliasName[9];
  	char pad;
  	unsigned int commentOffset;
  	unsigned char type[2];
0753ca7bc   Steve French   [CIFS] Change pra...
2105
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2106
2107
2108
2109
2110
  
  struct aliasInfo92 {
  	int aliasNameOffset;
  	int serverNameOffset;
  	int shareNameOffset;
0753ca7bc   Steve French   [CIFS] Change pra...
2111
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2112
2113
2114
2115
2116
2117
  
  typedef struct {
  	__le64 TotalAllocationUnits;
  	__le64 FreeAllocationUnits;
  	__le32 SectorsPerAllocationUnit;
  	__le32 BytesPerSector;
50c2f7538   Steve French   [CIFS] whitespace...
2118
  } __attribute__((packed)) FILE_SYSTEM_INFO;	/* size info, level 0x103 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2119
2120
  
  typedef struct {
209624388   Steve French   [CIFS] Add suppor...
2121
2122
2123
2124
2125
  	__le32 fsid;
  	__le32 SectorsPerAllocationUnit;
  	__le32 TotalAllocationUnits;
  	__le32 FreeAllocationUnits;
  	__le16  BytesPerSector;
0753ca7bc   Steve French   [CIFS] Change pra...
2126
  } __attribute__((packed)) FILE_SYSTEM_ALLOC_INFO;
209624388   Steve French   [CIFS] Add suppor...
2127
2128
  
  typedef struct {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2129
2130
2131
  	__le16 MajorVersionNumber;
  	__le16 MinorVersionNumber;
  	__le64 Capability;
50c2f7538   Steve French   [CIFS] whitespace...
2132
  } __attribute__((packed)) FILE_SYSTEM_UNIX_INFO; /* Unix extension level 0x200*/
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
2133
2134
2135
2136
  
  /* Version numbers for CIFS UNIX major and minor. */
  #define CIFS_UNIX_MAJOR_VERSION 1
  #define CIFS_UNIX_MINOR_VERSION 0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2137
2138
  /* Linux/Unix extensions capability flags */
  #define CIFS_UNIX_FCNTL_CAP             0x00000001 /* support for fcntl locks */
f654bac22   Steve French   [PATCH] cifs: add...
2139
2140
2141
  #define CIFS_UNIX_POSIX_ACL_CAP         0x00000002 /* support getfacl/setfacl */
  #define CIFS_UNIX_XATTR_CAP             0x00000004 /* support new namespace   */
  #define CIFS_UNIX_EXTATTR_CAP           0x00000008 /* support chattr/chflag   */
82940a465   Steve French   [CIFS] Make POSIX...
2142
  #define CIFS_UNIX_POSIX_PATHNAMES_CAP   0x00000010 /* Allow POSIX path chars  */
87f440e70   Steve French   [CIFS] Additional...
2143
2144
  #define CIFS_UNIX_POSIX_PATH_OPS_CAP    0x00000020 /* Allow new POSIX path based
  						      calls including posix open
75865f8cc   Steve French   [CIFS] Add in som...
2145
2146
  						      and posix unlink */
  #define CIFS_UNIX_LARGE_READ_CAP        0x00000040 /* support reads >128K (up
50c2f7538   Steve French   [CIFS] whitespace...
2147
  						      to 0xFFFF00 */
75865f8cc   Steve French   [CIFS] Add in som...
2148
  #define CIFS_UNIX_LARGE_WRITE_CAP       0x00000080
a7f796a60   Steve French   [CIFS] Fix typo i...
2149
  #define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
0206e61b4   Steve French   [CIFS] Fix spelli...
2150
  #define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP  0x00000200 /* must do  */
ee4987ab5   Steve French   [CIFS] Fix define...
2151
  #define CIFS_UNIX_PROXY_CAP             0x00000400 /* Proxy cap: 0xACE ioctl and
2302aca85   Steve French   [CIFS] Reserve ne...
2152
  						      QFS PROXY call */
82940a465   Steve French   [CIFS] Make POSIX...
2153
  #ifdef CONFIG_CIFS_POSIX
96814ecb4   Steve French   Add definition fo...
2154
2155
2156
2157
2158
  /* presumably don't need the 0x20 POSIX_PATH_OPS_CAP since we never send
     LockingX instead of posix locking call on unix sess (and we do not expect
     LockingX to use different (ie Windows) semantics than posix locking on
     the same session (if WINE needs to do this later, we can add this cap
     back in later */
75865f8cc   Steve French   [CIFS] Add in som...
2159
  /* #define CIFS_UNIX_CAP_MASK              0x000000fb */
96814ecb4   Steve French   Add definition fo...
2160
  #define CIFS_UNIX_CAP_MASK              0x000003db
50c2f7538   Steve French   [CIFS] whitespace...
2161
  #else
82940a465   Steve French   [CIFS] Make POSIX...
2162
2163
  #define CIFS_UNIX_CAP_MASK              0x00000013
  #endif /* CONFIG_CIFS_POSIX */
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
2164

f28ac91b0   Steve French   [PATCH] cifs: CIF...
2165
  #define CIFS_POSIX_EXTENSIONS           0x00000010 /* support for new QFSInfo */
ac67055ef   Jeremy Allison   [CIFS] POSIX exte...
2166

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2167
2168
2169
  typedef struct {
  	/* For undefined recommended transfer size return -1 in that field */
  	__le32 OptimalTransferSize;  /* bsize on some os, iosize on other os */
50c2f7538   Steve French   [CIFS] whitespace...
2170
  	__le32 BlockSize;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2171
2172
      /* The next three fields are in terms of the block size.
  	(above). If block size is unknown, 4096 would be a
50c2f7538   Steve French   [CIFS] whitespace...
2173
  	reasonable block size for a server to report.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
  	Note that returning the blocks/blocksavail removes need
  	to make a second call (to QFSInfo level 0x103 to get this info.
  	UserBlockAvail is typically less than or equal to BlocksAvail,
  	if no distinction is made return the same value in each */
  	__le64 TotalBlocks;
  	__le64 BlocksAvail;       /* bfree */
  	__le64 UserBlocksAvail;   /* bavail */
      /* For undefined Node fields or FSID return -1 */
  	__le64 TotalFileNodes;
  	__le64 FreeFileNodes;
  	__le64 FileSysIdentifier;   /* fsid */
  	/* NB Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call */
  	/* NB flags can come from FILE_SYSTEM_DEVICE_INFO call   */
0753ca7bc   Steve French   [CIFS] Change pra...
2187
  } __attribute__((packed)) FILE_SYSTEM_POSIX_INFO;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
  
  /* DeviceType Flags */
  #define FILE_DEVICE_CD_ROM              0x00000002
  #define FILE_DEVICE_CD_ROM_FILE_SYSTEM  0x00000003
  #define FILE_DEVICE_DFS                 0x00000006
  #define FILE_DEVICE_DISK                0x00000007
  #define FILE_DEVICE_DISK_FILE_SYSTEM    0x00000008
  #define FILE_DEVICE_FILE_SYSTEM         0x00000009
  #define FILE_DEVICE_NAMED_PIPE          0x00000011
  #define FILE_DEVICE_NETWORK             0x00000012
  #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
  #define FILE_DEVICE_NULL                0x00000015
  #define FILE_DEVICE_PARALLEL_PORT       0x00000016
  #define FILE_DEVICE_PRINTER             0x00000018
  #define FILE_DEVICE_SERIAL_PORT         0x0000001b
  #define FILE_DEVICE_STREAMS             0x0000001e
  #define FILE_DEVICE_TAPE                0x0000001f
  #define FILE_DEVICE_TAPE_FILE_SYSTEM    0x00000020
  #define FILE_DEVICE_VIRTUAL_DISK        0x00000024
  #define FILE_DEVICE_NETWORK_REDIRECTOR  0x00000028
0de1f4c6f   Steve French   Add way to query ...
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
  /* Device Characteristics */
  #define FILE_REMOVABLE_MEDIA			0x00000001
  #define FILE_READ_ONLY_DEVICE			0x00000002
  #define FILE_FLOPPY_DISKETTE			0x00000004
  #define FILE_WRITE_ONCE_MEDIA			0x00000008
  #define FILE_REMOTE_DEVICE			0x00000010
  #define FILE_DEVICE_IS_MOUNTED			0x00000020
  #define FILE_VIRTUAL_VOLUME			0x00000040
  #define FILE_DEVICE_SECURE_OPEN			0x00000100
  #define FILE_CHARACTERISTIC_TS_DEVICE		0x00001000
  #define FILE_CHARACTERISTIC_WEBDAV_DEVICE	0x00002000
  #define FILE_PORTABLE_DEVICE			0x00004000
  #define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL 0x00020000
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2221
2222
2223
  typedef struct {
  	__le32 DeviceType;
  	__le32 DeviceCharacteristics;
3979877e5   Steve French   [CIFS] Support fo...
2224
  } __attribute__((packed)) FILE_SYSTEM_DEVICE_INFO; /* device info level 0x104 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2225

34f626406   Steve French   Query file system...
2226
2227
  /* minimum includes first three fields, and empty FS Name */
  #define MIN_FS_ATTR_INFO_SIZE 12
8ae31240c   Steve French   Add missing defin...
2228
2229
  
  /* List of FileSystemAttributes - see 2.5.1 of MS-FSCC */
02b166654   Steve French   Add reflink copy ...
2230
2231
  #define FILE_SUPPORTS_SPARSE_VDL	0x10000000 /* faster nonsparse extend */
  #define FILE_SUPPORTS_BLOCK_REFCOUNTING	0x08000000 /* allow ioctl dup extents */
8ae31240c   Steve French   Add missing defin...
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
  #define FILE_SUPPORT_INTEGRITY_STREAMS	0x04000000
  #define FILE_SUPPORTS_USN_JOURNAL	0x02000000
  #define FILE_SUPPORTS_OPEN_BY_FILE_ID	0x01000000
  #define FILE_SUPPORTS_EXTENDED_ATTRIBUTES 0x00800000
  #define FILE_SUPPORTS_HARD_LINKS	0x00400000
  #define FILE_SUPPORTS_TRANSACTIONS	0x00200000
  #define FILE_SEQUENTIAL_WRITE_ONCE	0x00100000
  #define FILE_READ_ONLY_VOLUME		0x00080000
  #define FILE_NAMED_STREAMS		0x00040000
  #define FILE_SUPPORTS_ENCRYPTION	0x00020000
  #define FILE_SUPPORTS_OBJECT_IDS	0x00010000
  #define FILE_VOLUME_IS_COMPRESSED	0x00008000
  #define FILE_SUPPORTS_REMOTE_STORAGE	0x00000100
  #define FILE_SUPPORTS_REPARSE_POINTS	0x00000080
  #define FILE_SUPPORTS_SPARSE_FILES	0x00000040
  #define FILE_VOLUME_QUOTAS		0x00000020
  #define FILE_FILE_COMPRESSION		0x00000010
  #define FILE_PERSISTENT_ACLS		0x00000008
  #define FILE_UNICODE_ON_DISK		0x00000004
  #define FILE_CASE_PRESERVED_NAMES	0x00000002
  #define FILE_CASE_SENSITIVE_SEARCH	0x00000001
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2253
2254
2255
2256
  typedef struct {
  	__le32 Attributes;
  	__le32 MaxPathNameComponentLength;
  	__le32 FileSystemNameLen;
3979877e5   Steve French   [CIFS] Support fo...
2257
  	char FileSystemName[52]; /* do not have to save this - get subset? */
0753ca7bc   Steve French   [CIFS] Change pra...
2258
  } __attribute__((packed)) FILE_SYSTEM_ATTRIBUTE_INFO;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
  
  /******************************************************************************/
  /* QueryFileInfo/QueryPathinfo (also for SetPath/SetFile) data buffer formats */
  /******************************************************************************/
  typedef struct { /* data block encoding of response to level 263 QPathInfo */
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le32 Attributes;
  	__u32 Pad1;
  	__le64 AllocationSize;
  	__le64 EndOfFile;	/* size ie offset to first free byte in file */
  	__le32 NumberOfLinks;	/* hard links */
  	__u8 DeletePending;
  	__u8 Directory;
  	__u16 Pad2;
e4e370355   Pavel Shilovsky   CIFS: Fix endian ...
2276
  	__le64 IndexNumber;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2277
2278
2279
2280
2281
2282
2283
2284
  	__le32 EASize;
  	__le32 AccessFlags;
  	__u64 IndexNumber1;
  	__le64 CurrentByteOffset;
  	__le32 Mode;
  	__le32 AlignmentRequirement;
  	__le32 FileNameLength;
  	char FileName[1];
87f440e70   Steve French   [CIFS] Additional...
2285
  } __attribute__((packed)) FILE_ALL_INFO;	/* level 0x107 QPathInfo */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2286

80bc83c36   Steve French   add struct FILE_S...
2287
2288
2289
2290
2291
2292
2293
2294
  typedef struct {
  	__le64 AllocationSize;
  	__le64 EndOfFile;	/* size ie offset to first free byte in file */
  	__le32 NumberOfLinks;	/* hard links */
  	__u8 DeletePending;
  	__u8 Directory;
  	__u16 Pad;
  } __attribute__((packed)) FILE_STANDARD_INFO;	/* level 0x102 QPathInfo */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
  /* defines for enumerating possible values of the Unix type field below */
  #define UNIX_FILE      0
  #define UNIX_DIR       1
  #define UNIX_SYMLINK   2
  #define UNIX_CHARDEV   3
  #define UNIX_BLOCKDEV  4
  #define UNIX_FIFO      5
  #define UNIX_SOCKET    6
  typedef struct {
  	__le64 EndOfFile;
  	__le64 NumOfBytes;
  	__le64 LastStatusChange; /*SNIA specs DCE time for the 3 time fields */
  	__le64 LastAccessTime;
  	__le64 LastModificationTime;
  	__le64 Uid;
  	__le64 Gid;
  	__le32 Type;
  	__le64 DevMajor;
  	__le64 DevMinor;
85a6dac54   Steve French   [CIFS] Endian con...
2314
  	__le64 UniqueId;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2315
2316
  	__le64 Permissions;
  	__le64 Nlinks;
87f440e70   Steve French   [CIFS] Additional...
2317
  } __attribute__((packed)) FILE_UNIX_BASIC_INFO;	/* level 0x200 QPathInfo */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2318
2319
2320
  
  typedef struct {
  	char LinkDest[1];
87f440e70   Steve French   [CIFS] Additional...
2321
  } __attribute__((packed)) FILE_UNIX_LINK_INFO;	/* level 0x201 QPathInfo */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2322
2323
2324
2325
2326
2327
2328
2329
  
  /* The following three structures are needed only for
  	setting time to NT4 and some older servers via
  	the primitive DOS time format */
  typedef struct {
  	__u16 Day:5;
  	__u16 Month:4;
  	__u16 Year:7;
0753ca7bc   Steve French   [CIFS] Change pra...
2330
  } __attribute__((packed)) SMB_DATE;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2331
2332
2333
2334
2335
  
  typedef struct {
  	__u16 TwoSeconds:5;
  	__u16 Minutes:6;
  	__u16 Hours:5;
0753ca7bc   Steve French   [CIFS] Change pra...
2336
  } __attribute__((packed)) SMB_TIME;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
  
  typedef struct {
  	__le16 CreationDate; /* SMB Date see above */
  	__le16 CreationTime; /* SMB Time */
  	__le16 LastAccessDate;
  	__le16 LastAccessTime;
  	__le16 LastWriteDate;
  	__le16 LastWriteTime;
  	__le32 DataSize; /* File Size (EOF) */
  	__le32 AllocationSize;
  	__le16 Attributes; /* verify not u32 */
  	__le32 EASize;
0753ca7bc   Steve French   [CIFS] Change pra...
2349
  } __attribute__((packed)) FILE_INFO_STANDARD;  /* level 1 SetPath/FileInfo */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2350
2351
2352
2353
2354
2355
2356
2357
  
  typedef struct {
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le32 Attributes;
  	__u32 Pad;
87f440e70   Steve French   [CIFS] Additional...
2358
  } __attribute__((packed)) FILE_BASIC_INFO;	/* size info, level 0x101 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2359
2360
2361
  
  struct file_allocation_info {
  	__le64 AllocationSize; /* Note old Samba srvr rounds this up too much */
5bafd7659   Steve French   [CIFS] Add suppor...
2362
2363
  } __attribute__((packed));	/* size used on disk, for level 0x103 for set,
  				   0x105 for query */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2364
2365
2366
  
  struct file_end_of_file_info {
  	__le64 FileSize;		/* offset to end of file */
87f440e70   Steve French   [CIFS] Additional...
2367
  } __attribute__((packed)); /* size info, level 0x104 for set, 0x106 for query */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2368
2369
2370
  
  struct file_alt_name_info {
  	__u8   alt_name[1];
0753ca7bc   Steve French   [CIFS] Change pra...
2371
  } __attribute__((packed));      /* level 0x0108 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2372
2373
2374
  
  struct file_stream_info {
  	__le32 number_of_streams;  /* BB check sizes and verify location */
50c2f7538   Steve French   [CIFS] whitespace...
2375
  	/* followed by info on streams themselves
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2376
  		u64 size;
50c2f7538   Steve French   [CIFS] whitespace...
2377
  		u64 allocation_size
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
  		stream info */
  };      /* level 0x109 */
  
  struct file_compression_info {
  	__le64 compressed_size;
  	__le16 format;
  	__u8   unit_shift;
  	__u8   ch_shift;
  	__u8   cl_shift;
  	__u8   pad[3];
0753ca7bc   Steve French   [CIFS] Change pra...
2388
  } __attribute__((packed));      /* level 0x10b */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2389
2390
2391
2392
2393
2394
2395
  
  /* POSIX ACL set/query path info structures */
  #define CIFS_ACL_VERSION 1
  struct cifs_posix_ace { /* access control entry (ACE) */
  	__u8  cifs_e_tag;
  	__u8  cifs_e_perm;
  	__le64 cifs_uid; /* or gid */
50c2f7538   Steve French   [CIFS] whitespace...
2396
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2397
2398
2399
2400
2401
2402
2403
2404
  
  struct cifs_posix_acl { /* access conrol list  (ACL) */
  	__le16	version;
  	__le16	access_entry_count;  /* access ACL - count of entries */
  	__le16	default_entry_count; /* default ACL - count of entries */
  	struct cifs_posix_ace ace_array[0];
  	/* followed by
  	struct cifs_posix_ace default_ace_arraay[] */
0753ca7bc   Steve French   [CIFS] Change pra...
2405
  } __attribute__((packed));  /* level 0x204 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
  
  /* types of access control entries already defined in posix_acl.h */
  /* #define CIFS_POSIX_ACL_USER_OBJ	 0x01
  #define CIFS_POSIX_ACL_USER      0x02
  #define CIFS_POSIX_ACL_GROUP_OBJ 0x04
  #define CIFS_POSIX_ACL_GROUP     0x08
  #define CIFS_POSIX_ACL_MASK      0x10
  #define CIFS_POSIX_ACL_OTHER     0x20 */
  
  /* types of perms */
  /* #define CIFS_POSIX_ACL_EXECUTE   0x01
  #define CIFS_POSIX_ACL_WRITE     0x02
  #define CIFS_POSIX_ACL_READ	     0x04 */
  
  /* end of POSIX ACL definitions */
2dd29d313   Steve French   [CIFS] New CIFS P...
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
  /* POSIX Open Flags */
  #define SMB_O_RDONLY 	 0x1
  #define SMB_O_WRONLY 	0x2
  #define SMB_O_RDWR 	0x4
  #define SMB_O_CREAT 	0x10
  #define SMB_O_EXCL 	0x20
  #define SMB_O_TRUNC 	0x40
  #define SMB_O_APPEND 	0x80
  #define SMB_O_SYNC 	0x100
  #define SMB_O_DIRECTORY 0x200
  #define SMB_O_NOFOLLOW 	0x400
  #define SMB_O_DIRECT 	0x800
595dcfecf   Steve French   [CIFS] POSIX CIFS...
2433
  typedef struct {
2dd29d313   Steve French   [CIFS] New CIFS P...
2434
2435
2436
2437
  	__le32 OpenFlags; /* same as NT CreateX */
  	__le32 PosixOpenFlags;
  	__le64 Permissions;
  	__le16 Level; /* reply level requested (see QPathInfo levels) */
595dcfecf   Steve French   [CIFS] POSIX CIFS...
2438
2439
2440
  } __attribute__((packed)) OPEN_PSX_REQ; /* level 0x209 SetPathInfo data */
  
  typedef struct {
2dd29d313   Steve French   [CIFS] New CIFS P...
2441
2442
2443
2444
2445
2446
  	__le16 OplockFlags;
  	__u16 Fid;
  	__le32 CreateAction;
  	__le16 ReturnedLevel;
  	__le16 Pad;
  	/* struct following varies based on requested level */
8af189715   Steve French   [CIFS] on reconne...
2447
  } __attribute__((packed)) OPEN_PSX_RSP; /* level 0x209 SetPathInfo data */
595dcfecf   Steve French   [CIFS] POSIX CIFS...
2448

2d785a50a   Steve French   [CIFS] Add suppor...
2449
2450
2451
2452
2453
2454
  #define SMB_POSIX_UNLINK_FILE_TARGET		0
  #define SMB_POSIX_UNLINK_DIRECTORY_TARGET	1
  
  struct unlink_psx_rq { /* level 0x20a SetPathInfo */
  	__le16 type;
  } __attribute__((packed));
595dcfecf   Steve French   [CIFS] POSIX CIFS...
2455

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2456
  struct file_internal_info {
85a6dac54   Steve French   [CIFS] Endian con...
2457
  	__le64  UniqueId; /* inode number */
0753ca7bc   Steve French   [CIFS] Change pra...
2458
  } __attribute__((packed));      /* level 0x3ee */
2dd29d313   Steve French   [CIFS] New CIFS P...
2459

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2460
2461
  struct file_mode_info {
  	__le32	Mode;
0753ca7bc   Steve French   [CIFS] Change pra...
2462
  } __attribute__((packed));      /* level 0x3f8 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2463
2464
2465
2466
  
  struct file_attrib_tag {
  	__le32 Attribute;
  	__le32 ReparseTag;
0753ca7bc   Steve French   [CIFS] Change pra...
2467
  } __attribute__((packed));      /* level 0x40b */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2468
2469
2470
  
  
  /********************************************************/
50c2f7538   Steve French   [CIFS] whitespace...
2471
  /*  FindFirst/FindNext transact2 data buffer formats    */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2472
2473
2474
2475
2476
  /********************************************************/
  
  typedef struct {
  	__le32 NextEntryOffset;
  	__u32 ResumeKey; /* as with FileIndex - no need to convert */
cc0bad755   Jeff Layton   cifs: add new cif...
2477
  	FILE_UNIX_BASIC_INFO basic;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2478
  	char FileName[1];
0753ca7bc   Steve French   [CIFS] Change pra...
2479
  } __attribute__((packed)) FILE_UNIX_INFO; /* level 0x202 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
  
  typedef struct {
  	__le32 NextEntryOffset;
  	__u32 FileIndex;
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le64 EndOfFile;
  	__le64 AllocationSize;
  	__le32 ExtFileAttributes;
  	__le32 FileNameLength;
  	char FileName[1];
5bafd7659   Steve French   [CIFS] Add suppor...
2493
  } __attribute__((packed)) FILE_DIRECTORY_INFO;   /* level 0x101 FF resp data */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
  
  typedef struct {
  	__le32 NextEntryOffset;
  	__u32 FileIndex;
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le64 EndOfFile;
  	__le64 AllocationSize;
  	__le32 ExtFileAttributes;
  	__le32 FileNameLength;
  	__le32 EaSize; /* length of the xattrs */
  	char FileName[1];
5bafd7659   Steve French   [CIFS] Add suppor...
2508
  } __attribute__((packed)) FILE_FULL_DIRECTORY_INFO; /* level 0x102 rsp data */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
  
  typedef struct {
  	__le32 NextEntryOffset;
  	__u32 FileIndex;
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le64 EndOfFile;
  	__le64 AllocationSize;
  	__le32 ExtFileAttributes;
  	__le32 FileNameLength;
  	__le32 EaSize; /* EA size */
  	__le32 Reserved;
85a6dac54   Steve French   [CIFS] Endian con...
2523
  	__le64 UniqueId; /* inode num - le since Samba puts ino in low 32 bit*/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2524
  	char FileName[1];
5bafd7659   Steve French   [CIFS] Add suppor...
2525
  } __attribute__((packed)) SEARCH_ID_FULL_DIR_INFO; /* level 0x105 FF rsp data */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
  
  typedef struct {
  	__le32 NextEntryOffset;
  	__u32 FileIndex;
  	__le64 CreationTime;
  	__le64 LastAccessTime;
  	__le64 LastWriteTime;
  	__le64 ChangeTime;
  	__le64 EndOfFile;
  	__le64 AllocationSize;
  	__le32 ExtFileAttributes;
50c2f7538   Steve French   [CIFS] whitespace...
2537
  	__le32 FileNameLength;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2538
2539
2540
2541
2542
  	__le32 EaSize; /* length of the xattrs */
  	__u8   ShortNameLength;
  	__u8   Reserved;
  	__u8   ShortName[12];
  	char FileName[1];
5bafd7659   Steve French   [CIFS] Add suppor...
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
  } __attribute__((packed)) FILE_BOTH_DIRECTORY_INFO; /* level 0x104 FFrsp data */
  
  typedef struct {
  	__u32  ResumeKey;
  	__le16 CreationDate; /* SMB Date */
  	__le16 CreationTime; /* SMB Time */
  	__le16 LastAccessDate;
  	__le16 LastAccessTime;
  	__le16 LastWriteDate;
  	__le16 LastWriteTime;
  	__le32 DataSize; /* File Size (EOF) */
  	__le32 AllocationSize;
  	__le16 Attributes; /* verify not u32 */
  	__u8   FileNameLength;
  	char FileName[1];
  } __attribute__((packed)) FIND_FILE_STANDARD_INFO; /* level 0x1 FF resp data */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2559

86c96b4bb   Steve French   [CIFS] Fix mknod ...
2560
2561
2562
  struct win_dev {
  	unsigned char type[8]; /* IntxCHR or IntxBLK */
  	__le64 major;
50c2f7538   Steve French   [CIFS] whitespace...
2563
  	__le64 minor;
86c96b4bb   Steve French   [CIFS] Fix mknod ...
2564
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2565
2566
2567
  struct gea {
  	unsigned char name_len;
  	char name[1];
0753ca7bc   Steve French   [CIFS] Change pra...
2568
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2569
2570
2571
2572
  
  struct gealist {
  	unsigned long list_len;
  	struct gea list[1];
0753ca7bc   Steve French   [CIFS] Change pra...
2573
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2574
2575
2576
2577
2578
2579
2580
  
  struct fea {
  	unsigned char EA_flags;
  	__u8 name_len;
  	__le16 value_len;
  	char name[1];
  	/* optionally followed by value */
0753ca7bc   Steve French   [CIFS] Change pra...
2581
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2582
2583
2584
2585
2586
2587
  /* flags for _FEA.fEA */
  #define FEA_NEEDEA         0x80	/* need EA bit */
  
  struct fealist {
  	__le32 list_len;
  	struct fea list[1];
0753ca7bc   Steve French   [CIFS] Change pra...
2588
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2589
2590
2591
2592
2593
  
  /* used to hold an arbitrary blob of data */
  struct data_blob {
  	__u8 *data;
  	size_t length;
50c2f7538   Steve French   [CIFS] whitespace...
2594
  	void (*free) (struct data_blob *data_blob);
0753ca7bc   Steve French   [CIFS] Change pra...
2595
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2596
2597
2598
  
  
  #ifdef CONFIG_CIFS_POSIX
50c2f7538   Steve French   [CIFS] whitespace...
2599
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2600
2601
  	For better POSIX semantics from Linux client, (even better
  	than the existing CIFS Unix Extensions) we need updated PDUs for:
50c2f7538   Steve French   [CIFS] whitespace...
2602

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2603
2604
2605
  	1) PosixCreateX - to set and return the mode, inode#, device info and
  	perhaps add a CreateDevice - to create Pipes and other special .inodes
  	Also note POSIX open flags
50c2f7538   Steve French   [CIFS] whitespace...
2606
  	2) Close - to return the last write time to do cache across close
87f440e70   Steve French   [CIFS] Additional...
2607
  		more safely
50c2f7538   Steve French   [CIFS] whitespace...
2608
  	3) FindFirst return unique inode number - what about resume key, two
1982c344f   Steve French   [CIFS] Ensure tha...
2609
2610
  	forms short (matches readdir) and full (enough info to cache inodes)
  	4) Mkdir - set mode
50c2f7538   Steve French   [CIFS] whitespace...
2611
2612
  
  	And under consideration:
1982c344f   Steve French   [CIFS] Ensure tha...
2613
  	5) FindClose2 (return nanosecond timestamp ??)
50c2f7538   Steve French   [CIFS] whitespace...
2614
  	6) Use nanosecond timestamps throughout all time fields if
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2615
  	   corresponding attribute flag is set
1982c344f   Steve French   [CIFS] Ensure tha...
2616
  	7) sendfile - handle based copy
50c2f7538   Steve French   [CIFS] whitespace...
2617

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2618
  	what about fixing 64 bit alignment
50c2f7538   Steve French   [CIFS] whitespace...
2619

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2620
  	There are also various legacy SMB/CIFS requests used as is
50c2f7538   Steve French   [CIFS] whitespace...
2621

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
  	From existing Lanman and NTLM dialects:
  	--------------------------------------
  	NEGOTIATE
  	SESSION_SETUP_ANDX (BB which?)
  	TREE_CONNECT_ANDX (BB which wct?)
  	TREE_DISCONNECT (BB add volume timestamp on response)
  	LOGOFF_ANDX
  	DELETE (note delete open file behavior)
  	DELETE_DIRECTORY
  	READ_AND_X
  	WRITE_AND_X
  	LOCKING_AND_X (note posix lock semantics)
  	RENAME (note rename across dirs and open file rename posix behaviors)
  	NT_RENAME (for hardlinks) Is this good enough for all features?
  	FIND_CLOSE2
  	TRANSACTION2 (18 cases)
  		SMB_SET_FILE_END_OF_FILE_INFO2 SMB_SET_PATH_END_OF_FILE_INFO2
  		(BB verify that never need to set allocation size)
87f440e70   Steve French   [CIFS] Additional...
2640
2641
  		SMB_SET_FILE_BASIC_INFO2 (setting times - BB can it be done via
  			 Unix ext?)
50c2f7538   Steve French   [CIFS] whitespace...
2642

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2643
2644
2645
2646
2647
  	COPY (note support for copy across directories) - FUTURE, OPTIONAL
  	setting/getting OS/2 EAs - FUTURE (BB can this handle
  	setting Linux xattrs perfectly)         - OPTIONAL
  	dnotify                                 - FUTURE, OPTIONAL
  	quota                                   - FUTURE, OPTIONAL
50c2f7538   Steve French   [CIFS] whitespace...
2648
2649
  
  	Note that various requests implemented for NT interop such as
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2650
2651
  		NT_TRANSACT (IOCTL) QueryReparseInfo
  	are unneeded to servers compliant with the CIFS POSIX extensions
50c2f7538   Steve French   [CIFS] whitespace...
2652

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2653
2654
2655
2656
2657
  	From CIFS Unix Extensions:
  	-------------------------
  	T2 SET_PATH_INFO (SMB_SET_FILE_UNIX_LINK) for symlinks
  	T2 SET_PATH_INFO (SMB_SET_FILE_BASIC_INFO2)
  	T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_LINK)
50c2f7538   Steve French   [CIFS] whitespace...
2658
2659
2660
2661
2662
  	T2 QUERY_PATH_INFO (SMB_QUERY_FILE_UNIX_BASIC)	BB check for missing
  							inode fields
  				Actually a need QUERY_FILE_UNIX_INFO
  				since has inode num
  				BB what about a) blksize/blkbits/blocks
87f440e70   Steve French   [CIFS] Additional...
2663
2664
2665
2666
2667
  							  b) i_version
  							  c) i_rdev
  							  d) notify mask?
  							  e) generation
  							  f) size_seqcount
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2668
  	T2 FIND_FIRST/FIND_NEXT FIND_FILE_UNIX
50c2f7538   Steve French   [CIFS] whitespace...
2669
  	TRANS2_GET_DFS_REFERRAL		      - OPTIONAL but recommended
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2670
  	T2_QFS_INFO QueryDevice/AttributeInfo - OPTIONAL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2671
   */
1982c344f   Steve French   [CIFS] Ensure tha...
2672
  /* xsymlink is a symlink format (used by MacOS) that can be used
50c2f7538   Steve French   [CIFS] whitespace...
2673
     to save symlink info in a regular file when
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2674
2675
2676
     mounted to operating systems that do not
     support the cifs Unix extensions or EAs (for xattr
     based symlinks).  For such a file to be recognized
50c2f7538   Steve French   [CIFS] whitespace...
2677
     as containing symlink data:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2678

50c2f7538   Steve French   [CIFS] whitespace...
2679
     1) file size must be 1067,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2680
2681
     2) signature must begin file data,
     3) length field must be set to ASCII representation
50c2f7538   Steve French   [CIFS] whitespace...
2682
  	of a number which is less than or equal to 1024,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
     4) md5 must match that of the path data */
  
  struct xsymlink {
  	/* 1067 bytes */
  	char signature[4]; /* XSym */ /* not null terminated */
  	char cr0;         /* 
   */
  /* ASCII representation of length (4 bytes decimal) terminated by 
   not null */
  	char length[4];
  	char cr1;         /* 
   */
  /* md5 of valid subset of path ie path[0] through path[length-1] */
50c2f7538   Steve French   [CIFS] whitespace...
2696
  	__u8 md5[32];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2697
2698
2699
2700
  	char cr2;        /* 
   */
  /* if room left, then end with 
   then 0x20s by convention but not required */
50c2f7538   Steve French   [CIFS] whitespace...
2701
  	char path[1024];
0753ca7bc   Steve French   [CIFS] Change pra...
2702
  } __attribute__((packed));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2703

f654bac22   Steve French   [PATCH] cifs: add...
2704
  typedef struct file_xattr_info {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2705
2706
2707
2708
2709
  	/* BB do we need another field for flags? BB */
  	__u32 xattr_name_len;
  	__u32 xattr_value_len;
  	char  xattr_name[0];
  	/* followed by xattr_value[xattr_value_len], no pad */
50c2f7538   Steve French   [CIFS] whitespace...
2710
2711
  } __attribute__((packed)) FILE_XATTR_INFO; /* extended attribute info
  					      level 0x205 */
f654bac22   Steve French   [PATCH] cifs: add...
2712

05c715f2a   Steve French   [CIFS] Remove ext...
2713
  /* flags for lsattr and chflags commands removed arein uapi/linux/fs.h */
f654bac22   Steve French   [PATCH] cifs: add...
2714
2715
2716
2717
  
  typedef struct file_chattr_info {
  	__le64	mask; /* list of all possible attribute bits */
  	__le64	mode; /* list of actual attribute bits on this inode */
50c2f7538   Steve French   [CIFS] whitespace...
2718
2719
  } __attribute__((packed)) FILE_CHATTR_INFO;  /* ext attributes
  						(chattr, chflags) level 0x206 */
038245774   Steve French   [CIFS] Add defini...
2720
  #endif 				/* POSIX */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2721
  #endif				/* _CIFSPDU_H */