2 Unix SMB/CIFS implementation.
3 SMB transaction2 handling
4 Copyright (C) Jeremy Allison 1994-2002.
5 Copyright (C) Andrew Tridgell 1995-2003.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* These are the TRANS2 sub commands */
26 #define TRANSACT2_OPEN 0
27 #define TRANSACT2_FINDFIRST 1
28 #define TRANSACT2_FINDNEXT 2
29 #define TRANSACT2_QFSINFO 3
30 #define TRANSACT2_SETFSINFO 4
31 #define TRANSACT2_QPATHINFO 5
32 #define TRANSACT2_SETPATHINFO 6
33 #define TRANSACT2_QFILEINFO 7
34 #define TRANSACT2_SETFILEINFO 8
35 #define TRANSACT2_FSCTL 9
36 #define TRANSACT2_IOCTL 0xA
37 #define TRANSACT2_FINDNOTIFYFIRST 0xB
38 #define TRANSACT2_FINDNOTIFYNEXT 0xC
39 #define TRANSACT2_MKDIR 0xD
40 #define TRANSACT2_SESSION_SETUP 0xE
41 #define TRANSACT2_GET_DFS_REFERRAL 0x10
42 #define TRANSACT2_REPORT_DFS_INCONSISTANCY 0x11
45 /* trans2 Query FS info levels */
48 Checking for QFSINFO aliases
49 Found level 1 (0x001) of size 18 (0x12)
50 Found level 2 (0x002) of size 12 (0x0c)
51 Found level 258 (0x102) of size 26 (0x1a)
52 Found level 259 (0x103) of size 24 (0x18)
53 Found level 260 (0x104) of size 8 (0x08)
54 Found level 261 (0x105) of size 20 (0x14)
55 Found level 1001 (0x3e9) of size 26 (0x1a)
56 Found level 1003 (0x3eb) of size 24 (0x18)
57 Found level 1004 (0x3ec) of size 8 (0x08)
58 Found level 1005 (0x3ed) of size 20 (0x14)
59 Found level 1006 (0x3ee) of size 48 (0x30)
60 Found level 1007 (0x3ef) of size 32 (0x20)
61 Found level 1008 (0x3f0) of size 64 (0x40)
62 Found 13 levels with success status
63 Level 261 (0x105) and level 1005 (0x3ed) are possible aliases
64 Level 260 (0x104) and level 1004 (0x3ec) are possible aliases
65 Level 259 (0x103) and level 1003 (0x3eb) are possible aliases
66 Level 258 (0x102) and level 1001 (0x3e9) are possible aliases
67 Found 4 aliased levels
69 #define SMB_QFS_ALLOCATION 1
70 #define SMB_QFS_VOLUME 2
71 #define SMB_QFS_VOLUME_INFO 0x102
72 #define SMB_QFS_SIZE_INFO 0x103
73 #define SMB_QFS_DEVICE_INFO 0x104
74 #define SMB_QFS_ATTRIBUTE_INFO 0x105
75 #define SMB_QFS_UNIX_INFO 0x200
76 #define SMB_QFS_VOLUME_INFORMATION 1001
77 #define SMB_QFS_SIZE_INFORMATION 1003
78 #define SMB_QFS_DEVICE_INFORMATION 1004
79 #define SMB_QFS_ATTRIBUTE_INFORMATION 1005
80 #define SMB_QFS_QUOTA_INFORMATION 1006
81 #define SMB_QFS_FULL_SIZE_INFORMATION 1007
82 #define SMB_QFS_OBJECTID_INFORMATION 1008
85 /* trans2 qfileinfo/qpathinfo */
86 /* w2k3 TRANS2ALIASES:
87 Checking for QPATHINFO aliases
88 setting up complex file \qpathinfo_aliases.txt
89 Found level 1 (0x001) of size 22 (0x16)
90 Found level 2 (0x002) of size 26 (0x1a)
91 Found level 4 (0x004) of size 41 (0x29)
92 Found level 6 (0x006) of size 0 (0x00)
93 Found level 257 (0x101) of size 40 (0x28)
94 Found level 258 (0x102) of size 24 (0x18)
95 Found level 259 (0x103) of size 4 (0x04)
96 Found level 260 (0x104) of size 48 (0x30)
97 Found level 263 (0x107) of size 126 (0x7e)
98 Found level 264 (0x108) of size 28 (0x1c)
99 Found level 265 (0x109) of size 38 (0x26)
100 Found level 267 (0x10b) of size 16 (0x10)
101 Found level 1004 (0x3ec) of size 40 (0x28)
102 Found level 1005 (0x3ed) of size 24 (0x18)
103 Found level 1006 (0x3ee) of size 8 (0x08)
104 Found level 1007 (0x3ef) of size 4 (0x04)
105 Found level 1008 (0x3f0) of size 4 (0x04)
106 Found level 1009 (0x3f1) of size 48 (0x30)
107 Found level 1014 (0x3f6) of size 8 (0x08)
108 Found level 1016 (0x3f8) of size 4 (0x04)
109 Found level 1017 (0x3f9) of size 4 (0x04)
110 Found level 1018 (0x3fa) of size 126 (0x7e)
111 Found level 1021 (0x3fd) of size 28 (0x1c)
112 Found level 1022 (0x3fe) of size 38 (0x26)
113 Found level 1028 (0x404) of size 16 (0x10)
114 Found level 1034 (0x40a) of size 56 (0x38)
115 Found level 1035 (0x40b) of size 8 (0x08)
116 Found 27 levels with success status
117 Level 267 (0x10b) and level 1028 (0x404) are possible aliases
118 Level 265 (0x109) and level 1022 (0x3fe) are possible aliases
119 Level 264 (0x108) and level 1021 (0x3fd) are possible aliases
120 Level 263 (0x107) and level 1018 (0x3fa) are possible aliases
121 Level 260 (0x104) and level 1009 (0x3f1) are possible aliases
122 Level 259 (0x103) and level 1007 (0x3ef) are possible aliases
123 Level 258 (0x102) and level 1005 (0x3ed) are possible aliases
124 Level 257 (0x101) and level 1004 (0x3ec) are possible aliases
125 Found 8 aliased levels
127 #define SMB_QFILEINFO_STANDARD 1
128 #define SMB_QFILEINFO_EA_SIZE 2
129 #define SMB_QFILEINFO_ALL_EAS 4
130 #define SMB_QFILEINFO_IS_NAME_VALID 6 /* only for QPATHINFO */
131 #define SMB_QFILEINFO_BASIC_INFO 0x101
132 #define SMB_QFILEINFO_STANDARD_INFO 0x102
133 #define SMB_QFILEINFO_EA_INFO 0x103
134 #define SMB_QFILEINFO_NAME_INFO 0x104
135 #define SMB_QFILEINFO_ALL_INFO 0x107
136 #define SMB_QFILEINFO_ALT_NAME_INFO 0x108
137 #define SMB_QFILEINFO_STREAM_INFO 0x109
138 #define SMB_QFILEINFO_COMPRESSION_INFO 0x10b
139 #define SMB_QFILEINFO_UNIX_BASIC 0x200
140 #define SMB_QFILEINFO_UNIX_LINK 0x201
141 #define SMB_QFILEINFO_BASIC_INFORMATION 1004
142 #define SMB_QFILEINFO_STANDARD_INFORMATION 1005
143 #define SMB_QFILEINFO_INTERNAL_INFORMATION 1006
144 #define SMB_QFILEINFO_EA_INFORMATION 1007
145 #define SMB_QFILEINFO_ACCESS_INFORMATION 1008
146 #define SMB_QFILEINFO_NAME_INFORMATION 1009
147 #define SMB_QFILEINFO_POSITION_INFORMATION 1014
148 #define SMB_QFILEINFO_MODE_INFORMATION 1016
149 #define SMB_QFILEINFO_ALIGNMENT_INFORMATION 1017
150 #define SMB_QFILEINFO_ALL_INFORMATION 1018
151 #define SMB_QFILEINFO_ALT_NAME_INFORMATION 1021
152 #define SMB_QFILEINFO_STREAM_INFORMATION 1022
153 #define SMB_QFILEINFO_COMPRESSION_INFORMATION 1028
154 #define SMB_QFILEINFO_NETWORK_OPEN_INFORMATION 1034
155 #define SMB_QFILEINFO_ATTRIBUTE_TAG_INFORMATION 1035
159 /* trans2 setfileinfo/setpathinfo levels */
162 Checking for SETFILEINFO aliases
163 setting up complex file \setfileinfo_aliases.txt
164 Found level 1 (0x001) of size 2 (0x02)
165 Found level 2 (0x002) of size 2 (0x02)
166 Found level 257 (0x101) of size 40 (0x28)
167 Found level 258 (0x102) of size 2 (0x02)
168 Found level 259 (0x103) of size 8 (0x08)
169 Found level 260 (0x104) of size 8 (0x08)
170 Found level 1004 (0x3ec) of size 40 (0x28)
171 Found level 1010 (0x3f2) of size 2 (0x02)
172 Found level 1013 (0x3f5) of size 2 (0x02)
173 Found level 1014 (0x3f6) of size 8 (0x08)
174 Found level 1016 (0x3f8) of size 4 (0x04)
175 Found level 1019 (0x3fb) of size 8 (0x08)
176 Found level 1020 (0x3fc) of size 8 (0x08)
177 Found level 1023 (0x3ff) of size 8 (0x08)
178 Found level 1025 (0x401) of size 16 (0x10)
179 Found level 1029 (0x405) of size 72 (0x48)
180 Found level 1032 (0x408) of size 56 (0x38)
181 Found level 1039 (0x40f) of size 8 (0x08)
182 Found level 1040 (0x410) of size 8 (0x08)
183 Found 19 valid levels
185 Checking for SETPATHINFO aliases
186 Found level 1004 (0x3ec) of size 40 (0x28)
187 Found level 1010 (0x3f2) of size 2 (0x02)
188 Found level 1013 (0x3f5) of size 2 (0x02)
189 Found level 1014 (0x3f6) of size 8 (0x08)
190 Found level 1016 (0x3f8) of size 4 (0x04)
191 Found level 1019 (0x3fb) of size 8 (0x08)
192 Found level 1020 (0x3fc) of size 8 (0x08)
193 Found level 1023 (0x3ff) of size 8 (0x08)
194 Found level 1025 (0x401) of size 16 (0x10)
195 Found level 1029 (0x405) of size 72 (0x48)
196 Found level 1032 (0x408) of size 56 (0x38)
197 Found level 1039 (0x40f) of size 8 (0x08)
198 Found level 1040 (0x410) of size 8 (0x08)
199 Found 13 valid levels
201 #define SMB_SFILEINFO_STANDARD 1
202 #define SMB_SFILEINFO_EA_SET 2
203 #define SMB_SFILEINFO_BASIC_INFO 0x101
204 #define SMB_SFILEINFO_DISPOSITION_INFO 0x102
205 #define SMB_SFILEINFO_ALLOCATION_INFO 0x103
206 #define SMB_SFILEINFO_END_OF_FILE_INFO 0x104
207 #define SMB_SFILEINFO_UNIX_BASIC 0x200
208 #define SMB_SFILEINFO_UNIX_LINK 0x201
209 #define SMB_SFILEINFO_BASIC_INFORMATION 1004
210 #define SMB_SFILEINFO_RENAME_INFORMATION 1010
211 #define SMB_SFILEINFO_DISPOSITION_INFORMATION 1013
212 #define SMB_SFILEINFO_POSITION_INFORMATION 1014
213 #define SMB_SFILEINFO_MODE_INFORMATION 1016
214 #define SMB_SFILEINFO_ALLOCATION_INFORMATION 1019
215 #define SMB_SFILEINFO_END_OF_FILE_INFORMATION 1020
217 /* filemon shows FilePipeInformation */
218 #define SMB_SFILEINFO_1023 1023
220 /* filemon shows FilePipeRemoteInformation */
221 #define SMB_SFILEINFO_1025 1025
223 /* filemon shows CopyOnWriteInformation */
224 #define SMB_SFILEINFO_1029 1029
226 /* filemon shows OleClassIdInformation */
227 #define SMB_SFILEINFO_1032 1032
229 /* seems to be the file size - perhaps valid data size?
230 filemon shows 'InheritContentIndexInfo'
232 #define SMB_SFILEINFO_1039 1039
234 /* OLE_INFORMATION? */
235 #define SMB_SFILEINFO_1040 1040
238 /* trans2 findfirst levels */
241 Checking for FINDFIRST aliases
242 Found level 1 (0x001) of size 68 (0x44)
243 Found level 2 (0x002) of size 70 (0x46)
244 Found level 257 (0x101) of size 108 (0x6c)
245 Found level 258 (0x102) of size 116 (0x74)
246 Found level 259 (0x103) of size 60 (0x3c)
247 Found level 260 (0x104) of size 140 (0x8c)
248 Found level 261 (0x105) of size 124 (0x7c)
249 Found level 262 (0x106) of size 148 (0x94)
250 Found 8 levels with success status
251 Found 0 aliased levels
253 #define SMB_FIND_STANDARD 1
254 #define SMB_FIND_EA_SIZE 2
255 #define SMB_FIND_DIRECTORY_INFO 0x101
256 #define SMB_FIND_FULL_DIRECTORY_INFO 0x102
257 #define SMB_FIND_NAME_INFO 0x103
258 #define SMB_FIND_BOTH_DIRECTORY_INFO 0x104
259 #define SMB_FIND_ID_FULL_DIRECTORY_INFO 0x105
260 #define SMB_FIND_ID_BOTH_DIRECTORY_INFO 0x106
261 #define SMB_FIND_UNIX_INFO 0x202
263 /* flags on trans2 findfirst/findnext that control search */
264 #define FLAG_TRANS2_FIND_CLOSE 0x1
265 #define FLAG_TRANS2_FIND_CLOSE_IF_END 0x2
266 #define FLAG_TRANS2_FIND_REQUIRE_RESUME 0x4
267 #define FLAG_TRANS2_FIND_CONTINUE 0x8
268 #define FLAG_TRANS2_FIND_BACKUP_INTENT 0x10
271 * DeviceType and Characteristics returned in a
272 * SMB_QFS_DEVICE_INFO call.
274 #define QFS_DEVICETYPE_CD_ROM 0x2
275 #define QFS_DEVICETYPE_CD_ROM_FILE_SYSTEM 0x3
276 #define QFS_DEVICETYPE_DISK 0x7
277 #define QFS_DEVICETYPE_DISK_FILE_SYSTEM 0x8
278 #define QFS_DEVICETYPE_FILE_SYSTEM 0x9
280 /* Characteristics. */
281 #define QFS_TYPE_REMOVABLE_MEDIA 0x1
282 #define QFS_TYPE_READ_ONLY_DEVICE 0x2
283 #define QFS_TYPE_FLOPPY 0x4
284 #define QFS_TYPE_WORM 0x8
285 #define QFS_TYPE_REMOTE 0x10
286 #define QFS_TYPE_MOUNTED 0x20
287 #define QFS_TYPE_VIRTUAL 0x40
291 * Thursby MAC extensions....
295 * MAC CIFS Extensions have the range 0x300 - 0x2FF reserved.
296 * Supposedly Microsoft have agreed to this.
299 #define MIN_MAC_INFO_LEVEL 0x300
300 #define MAX_MAC_INFO_LEVEL 0x3FF
301 #define SMB_QFS_MAC_FS_INFO 0x301
305 /* UNIX CIFS Extensions - created by HP */
307 * UNIX CIFS Extensions have the range 0x200 - 0x2FF reserved.
308 * Supposedly Microsoft have agreed to this.
311 #define MIN_UNIX_INFO_LEVEL 0x200
312 #define MAX_UNIX_INFO_LEVEL 0x2FF
314 #define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL))
316 #define SMB_QFILEINFO_UNIX_BASIC 0x200 /* UNIX File Info*/
317 #define SMB_SFILEINFO_UNIX_BASIC 0x200
319 #define SMB_MODE_NO_CHANGE 0xFFFFFFFF /* file mode value which */
320 /* means "don't change it" */
321 #define SMB_UID_NO_CHANGE 0xFFFFFFFF
322 #define SMB_GID_NO_CHANGE 0xFFFFFFFF
324 #define SMB_SIZE_NO_CHANGE_LO 0xFFFFFFFF
325 #define SMB_SIZE_NO_CHANGE_HI 0xFFFFFFFF
327 #define SMB_TIME_NO_CHANGE_LO 0xFFFFFFFF
328 #define SMB_TIME_NO_CHANGE_HI 0xFFFFFFFF
332 0 LARGE_INTEGER EndOfFile File size
333 8 LARGE_INTEGER Blocks Number of bytes used on disk (st_blocks).
334 16 LARGE_INTEGER CreationTime Creation time
335 24 LARGE_INTEGER LastAccessTime Last access time
336 32 LARGE_INTEGER LastModificationTime Last modification time
337 40 LARGE_INTEGER Uid Numeric user id for the owner
338 48 LARGE_INTEGER Gid Numeric group id of owner
339 56 ULONG Type Enumeration specifying the pathname type:
343 3 -- Character device
345 5 -- FIFO (named pipe)
346 6 -- Unix domain socket
348 60 LARGE_INTEGER devmajor Major device number if type is device
349 68 LARGE_INTEGER devminor Minor device number if type is device
350 76 LARGE_INTEGER uniqueid This is a server-assigned unique id for the file. The client
351 will typically map this onto an inode number. The scope of
352 uniqueness is the share.
353 84 LARGE_INTEGER permissions Standard UNIX file permissions - see below.
354 92 LARGE_INTEGER nlinks The number of directory entries that map to this entry
355 (number of hard links)
360 /* UNIX filetype mappings. */
362 #define UNIX_TYPE_FILE 0
363 #define UNIX_TYPE_DIR 1
364 #define UNIX_TYPE_SYMLINK 2
365 #define UNIX_TYPE_CHARDEV 3
366 #define UNIX_TYPE_BLKDEV 4
367 #define UNIX_TYPE_FIFO 5
368 #define UNIX_TYPE_SOCKET 6
369 #define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
372 * Oh this is fun. "Standard UNIX permissions" has no
373 * meaning in POSIX. We need to define the mapping onto
374 * and off the wire as this was not done in the original HP
378 #define UNIX_X_OTH 0000001
379 #define UNIX_W_OTH 0000002
380 #define UNIX_R_OTH 0000004
381 #define UNIX_X_GRP 0000010
382 #define UNIX_W_GRP 0000020
383 #define UNIX_R_GRP 0000040
384 #define UNIX_X_USR 0000100
385 #define UNIX_W_USR 0000200
386 #define UNIX_R_USR 0000400
387 #define UNIX_STICKY 0001000
388 #define UNIX_SET_GID 0002000
389 #define UNIX_SET_UID 0004000
391 /* Masks for the above */
392 #define UNIX_OTH_MASK 0000007
393 #define UNIX_GRP_MASK 0000070
394 #define UNIX_USR_MASK 0000700
395 #define UNIX_PERM_MASK 0000777
396 #define UNIX_EXTRA_MASK 0007000
397 #define UNIX_ALL_MASK 0007777
399 #define SMB_QFILEINFO_UNIX_LINK 0x201
400 #define SMB_SFILEINFO_UNIX_LINK 0x201
401 #define SMB_SFILEINFO_UNIX_HLINK 0x203
403 #define SMB_FIND_FILE_UNIX 0x202
406 Info level for QVOLINFO - returns version of CIFS UNIX extensions, plus
407 64-bits worth of capability fun :-).
410 #define SMB_QUERY_CIFS_UNIX_INFO 0x200
412 /* Returns the following.
414 UINT16 major version number
415 UINT16 minor version number
416 LARGE_INTEGER capability bitfield
420 #define CIFS_UNIX_MAJOR_VERSION 1
421 #define CIFS_UNIX_MINOR_VERSION 0
423 #define CIFS_UNIX_FCNTL_LOCKS_CAP 0x1
424 #define CIFS_UNIX_POSIX_ACLS_CAP 0x2
426 /* ... more as we think of them :-). */