1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | SMB transaction2 handling
|
---|
4 |
|
---|
5 | Copyright (C) James Peach 2007
|
---|
6 | Copyright (C) Jeremy Allison 1994-2002.
|
---|
7 |
|
---|
8 | Extensively modified by Andrew Tridgell, 1995
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify
|
---|
11 | it under the terms of the GNU General Public License as published by
|
---|
12 | the Free Software Foundation; either version 2 of the License, or
|
---|
13 | (at your option) any later version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
18 | GNU General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU General Public License
|
---|
21 | along with this program; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef _TRANS2_H_
|
---|
26 | #define _TRANS2_H_
|
---|
27 |
|
---|
28 | /* Define the structures needed for the trans2 calls. */
|
---|
29 |
|
---|
30 | /*******************************************************
|
---|
31 | For DosFindFirst/DosFindNext - level 1
|
---|
32 |
|
---|
33 | MAXFILENAMELEN = 255;
|
---|
34 | FDATE == uint16
|
---|
35 | FTIME == uint16
|
---|
36 | ULONG == uint32
|
---|
37 | USHORT == uint16
|
---|
38 |
|
---|
39 | typedef struct _FILEFINDBUF {
|
---|
40 | Byte offset Type name description
|
---|
41 | -------------+-------+-------------------+--------------
|
---|
42 | 0 FDATE fdateCreation;
|
---|
43 | 2 FTIME ftimeCreation;
|
---|
44 | 4 FDATE fdateLastAccess;
|
---|
45 | 6 FTIME ftimeLastAccess;
|
---|
46 | 8 FDATE fdateLastWrite;
|
---|
47 | 10 FTIME ftimeLastWrite;
|
---|
48 | 12 ULONG cbFile file length in bytes
|
---|
49 | 16 ULONG cbFileAlloc size of file allocation unit
|
---|
50 | 20 USHORT attrFile
|
---|
51 | 22 UCHAR cchName length of name to follow (not including zero)
|
---|
52 | 23 UCHAR achName[MAXFILENAMELEN]; Null terminated name
|
---|
53 | } FILEFINDBUF;
|
---|
54 | *********************************************************/
|
---|
55 |
|
---|
56 | #define l1_fdateCreation 0
|
---|
57 | #define l1_fdateLastAccess 4
|
---|
58 | #define l1_fdateLastWrite 8
|
---|
59 | #define l1_cbFile 12
|
---|
60 | #define l1_cbFileAlloc 16
|
---|
61 | #define l1_attrFile 20
|
---|
62 | #define l1_cchName 22
|
---|
63 | #define l1_achName 23
|
---|
64 |
|
---|
65 | /**********************************************************
|
---|
66 | For DosFindFirst/DosFindNext - level 2
|
---|
67 |
|
---|
68 | typedef struct _FILEFINDBUF2 {
|
---|
69 | Byte offset Type name description
|
---|
70 | -------------+-------+-------------------+--------------
|
---|
71 | 0 FDATE fdateCreation;
|
---|
72 | 2 FTIME ftimeCreation;
|
---|
73 | 4 FDATE fdateLastAccess;
|
---|
74 | 6 FTIME ftimeLastAccess;
|
---|
75 | 8 FDATE fdateLastWrite;
|
---|
76 | 10 FTIME ftimeLastWrite;
|
---|
77 | 12 ULONG cbFile file length in bytes
|
---|
78 | 16 ULONG cbFileAlloc size of file allocation unit
|
---|
79 | 20 USHORT attrFile
|
---|
80 | 22 ULONG cbList Extended attribute list (always 0)
|
---|
81 | 26 UCHAR cchName length of name to follow (not including zero)
|
---|
82 | 27 UCHAR achName[MAXFILENAMELEN]; Null terminated name
|
---|
83 | } FILEFINDBUF2;
|
---|
84 | *************************************************************/
|
---|
85 |
|
---|
86 | #define l2_fdateCreation 0
|
---|
87 | #define l2_fdateLastAccess 4
|
---|
88 | #define l2_fdateLastWrite 8
|
---|
89 | #define l2_cbFile 12
|
---|
90 | #define l2_cbFileAlloc 16
|
---|
91 | #define l2_attrFile 20
|
---|
92 | #define l2_cbList 22
|
---|
93 | #define l2_cchName 26
|
---|
94 | #define l2_achName 27
|
---|
95 |
|
---|
96 |
|
---|
97 | /**********************************************************
|
---|
98 | For DosFindFirst/DosFindNext - level 260
|
---|
99 |
|
---|
100 | typedef struct _FILEFINDBUF260 {
|
---|
101 | Byte offset Type name description
|
---|
102 | -------------+-------+-------------------+--------------
|
---|
103 | 0 ULONG NextEntryOffset;
|
---|
104 | 4 ULONG FileIndex;
|
---|
105 | 8 LARGE_INTEGER CreationTime;
|
---|
106 | 16 LARGE_INTEGER LastAccessTime;
|
---|
107 | 24 LARGE_INTEGER LastWriteTime;
|
---|
108 | 32 LARGE_INTEGER ChangeTime;
|
---|
109 | 40 LARGE_INTEGER EndOfFile;
|
---|
110 | 48 LARGE_INTEGER AllocationSize;
|
---|
111 | 56 ULONG FileAttributes;
|
---|
112 | 60 ULONG FileNameLength;
|
---|
113 | 64 ULONG EaSize;
|
---|
114 | 68 CHAR ShortNameLength;
|
---|
115 | 70 UNICODE ShortName[12];
|
---|
116 | 94 UNICODE FileName[];
|
---|
117 | *************************************************************/
|
---|
118 |
|
---|
119 | #define l260_achName 94
|
---|
120 |
|
---|
121 |
|
---|
122 | /**********************************************************
|
---|
123 | For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
|
---|
124 | DosSetFileInfo - level 1
|
---|
125 |
|
---|
126 | typedef struct _FILESTATUS {
|
---|
127 | Byte offset Type name description
|
---|
128 | -------------+-------+-------------------+--------------
|
---|
129 | 0 FDATE fdateCreation;
|
---|
130 | 2 FTIME ftimeCreation;
|
---|
131 | 4 FDATE fdateLastAccess;
|
---|
132 | 6 FTIME ftimeLastAccess;
|
---|
133 | 8 FDATE fdateLastWrite;
|
---|
134 | 10 FTIME ftimeLastWrite;
|
---|
135 | 12 ULONG cbFile file length in bytes
|
---|
136 | 16 ULONG cbFileAlloc size of file allocation unit
|
---|
137 | 20 USHORT attrFile
|
---|
138 | } FILESTATUS;
|
---|
139 | *************************************************************/
|
---|
140 |
|
---|
141 | /* Use the l1_ defines from DosFindFirst */
|
---|
142 |
|
---|
143 | /**********************************************************
|
---|
144 | For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
|
---|
145 | DosSetFileInfo - level 2
|
---|
146 |
|
---|
147 | typedef struct _FILESTATUS2 {
|
---|
148 | Byte offset Type name description
|
---|
149 | -------------+-------+-------------------+--------------
|
---|
150 | 0 FDATE fdateCreation;
|
---|
151 | 2 FTIME ftimeCreation;
|
---|
152 | 4 FDATE fdateLastAccess;
|
---|
153 | 6 FTIME ftimeLastAccess;
|
---|
154 | 8 FDATE fdateLastWrite;
|
---|
155 | 10 FTIME ftimeLastWrite;
|
---|
156 | 12 ULONG cbFile file length in bytes
|
---|
157 | 16 ULONG cbFileAlloc size of file allocation unit
|
---|
158 | 20 USHORT attrFile
|
---|
159 | 22 ULONG cbList Length of EA's (0)
|
---|
160 | } FILESTATUS2;
|
---|
161 | *************************************************************/
|
---|
162 |
|
---|
163 | /* Use the l2_ #defines from DosFindFirst */
|
---|
164 |
|
---|
165 | /**********************************************************
|
---|
166 | For DosQFSInfo/DosSetFSInfo - level 1
|
---|
167 |
|
---|
168 | typedef struct _FSALLOCATE {
|
---|
169 | Byte offset Type name description
|
---|
170 | -------------+-------+-------------------+--------------
|
---|
171 | 0 ULONG idFileSystem id of file system
|
---|
172 | 4 ULONG cSectorUnit number of sectors per allocation unit
|
---|
173 | 8 ULONG cUnit number of allocation units
|
---|
174 | 12 ULONG cUnitAvail Available allocation units
|
---|
175 | 16 USHORT cbSector bytes per sector
|
---|
176 | } FSALLOCATE;
|
---|
177 | *************************************************************/
|
---|
178 |
|
---|
179 | #define l1_idFileSystem 0
|
---|
180 | #define l1_cSectorUnit 4
|
---|
181 | #define l1_cUnit 8
|
---|
182 | #define l1_cUnitAvail 12
|
---|
183 | #define l1_cbSector 16
|
---|
184 |
|
---|
185 | /**********************************************************
|
---|
186 | For DosQFSInfo/DosSetFSInfo - level 2
|
---|
187 |
|
---|
188 | typedef struct _FSINFO {
|
---|
189 | Byte offset Type name description
|
---|
190 | -------------+-------+-------------------+--------------
|
---|
191 | 0 FDATE vol_fdateCreation
|
---|
192 | 2 FTIME vol_ftimeCreation
|
---|
193 | 4 UCHAR vol_cch length of volume name (excluding NULL)
|
---|
194 | 5 UCHAR vol_szVolLabel[12] volume name
|
---|
195 | } FSINFO;
|
---|
196 | *************************************************************/
|
---|
197 |
|
---|
198 | #define SMB_INFO_STANDARD 1 /* FILESTATUS3 struct */
|
---|
199 | #define SMB_INFO_SET_EA 2 /* EAOP2 struct, only valid on set not query */
|
---|
200 | #define SMB_INFO_QUERY_EA_SIZE 2 /* FILESTATUS4 struct, only valid on query not set */
|
---|
201 | #define SMB_INFO_QUERY_EAS_FROM_LIST 3 /* only valid on query not set */
|
---|
202 | #define SMB_INFO_QUERY_ALL_EAS 4 /* only valid on query not set */
|
---|
203 | #define SMB_INFO_IS_NAME_VALID 6
|
---|
204 | #define SMB_INFO_STANDARD_LONG 11 /* similar to level 1, ie struct FileStatus3 */
|
---|
205 | #define SMB_QUERY_EA_SIZE_LONG 12 /* similar to level 2, ie struct FileStatus4 */
|
---|
206 | #define SMB_QUERY_FS_LABEL_INFO 0x101
|
---|
207 | #define SMB_QUERY_FS_VOLUME_INFO 0x102
|
---|
208 | #define SMB_QUERY_FS_SIZE_INFO 0x103
|
---|
209 | #define SMB_QUERY_FS_DEVICE_INFO 0x104
|
---|
210 | #define SMB_QUERY_FS_ATTRIBUTE_INFO 0x105
|
---|
211 | #if 0
|
---|
212 | #define SMB_QUERY_FS_QUOTA_INFO
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | #define l2_vol_fdateCreation 0
|
---|
216 | #define l2_vol_cch 4
|
---|
217 | #define l2_vol_szVolLabel 5
|
---|
218 |
|
---|
219 |
|
---|
220 | #define SMB_QUERY_FILE_BASIC_INFO 0x101
|
---|
221 | #define SMB_QUERY_FILE_STANDARD_INFO 0x102
|
---|
222 | #define SMB_QUERY_FILE_EA_INFO 0x103
|
---|
223 | #define SMB_QUERY_FILE_NAME_INFO 0x104
|
---|
224 | #define SMB_QUERY_FILE_ALLOCATION_INFO 0x105
|
---|
225 | #define SMB_QUERY_FILE_END_OF_FILEINFO 0x106
|
---|
226 | #define SMB_QUERY_FILE_ALL_INFO 0x107
|
---|
227 | #define SMB_QUERY_FILE_ALT_NAME_INFO 0x108
|
---|
228 | #define SMB_QUERY_FILE_STREAM_INFO 0x109
|
---|
229 | #define SMB_QUERY_COMPRESSION_INFO 0x10b
|
---|
230 |
|
---|
231 | #define SMB_FIND_INFO_STANDARD 1
|
---|
232 | #define SMB_FIND_EA_SIZE 2
|
---|
233 | #define SMB_FIND_EA_LIST 3
|
---|
234 | #define SMB_FIND_FILE_DIRECTORY_INFO 0x101
|
---|
235 | #define SMB_FIND_FILE_FULL_DIRECTORY_INFO 0x102
|
---|
236 | #define SMB_FIND_FILE_NAMES_INFO 0x103
|
---|
237 | #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO 0x104
|
---|
238 | #define SMB_FIND_ID_FULL_DIRECTORY_INFO 0x105
|
---|
239 | #define SMB_FIND_ID_BOTH_DIRECTORY_INFO 0x106
|
---|
240 |
|
---|
241 | #define SMB_SET_FILE_BASIC_INFO 0x101
|
---|
242 | #define SMB_SET_FILE_DISPOSITION_INFO 0x102
|
---|
243 | #define SMB_SET_FILE_ALLOCATION_INFO 0x103
|
---|
244 | #define SMB_SET_FILE_END_OF_FILE_INFO 0x104
|
---|
245 |
|
---|
246 | /* Query FS info. */
|
---|
247 | #define SMB_INFO_ALLOCATION 1
|
---|
248 | #define SMB_INFO_VOLUME 2
|
---|
249 |
|
---|
250 | /*
|
---|
251 | * Thursby MAC extensions....
|
---|
252 | */
|
---|
253 |
|
---|
254 | /*
|
---|
255 | * MAC CIFS Extensions have the range 0x300 - 0x2FF reserved.
|
---|
256 | * Supposedly Microsoft have agreed to this.
|
---|
257 | */
|
---|
258 |
|
---|
259 | #define MIN_MAC_INFO_LEVEL 0x300
|
---|
260 | #define MAX_MAC_INFO_LEVEL 0x3FF
|
---|
261 |
|
---|
262 | #define SMB_MAC_QUERY_FS_INFO 0x301
|
---|
263 |
|
---|
264 | #define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName))
|
---|
265 |
|
---|
266 | /*
|
---|
267 | * DeviceType and Characteristics returned in a
|
---|
268 | * SMB_QUERY_FS_DEVICE_INFO call.
|
---|
269 | */
|
---|
270 |
|
---|
271 | #define DEVICETYPE_CD_ROM 0x2
|
---|
272 | #define DEVICETYPE_CD_ROM_FILE_SYSTEM 0x3
|
---|
273 | #define DEVICETYPE_DISK 0x7
|
---|
274 | #define DEVICETYPE_DISK_FILE_SYSTEM 0x8
|
---|
275 | #define DEVICETYPE_FILE_SYSTEM 0x9
|
---|
276 |
|
---|
277 | /* Characteristics. */
|
---|
278 | #define TYPE_REMOVABLE_MEDIA 0x1
|
---|
279 | #define TYPE_READ_ONLY_DEVICE 0x2
|
---|
280 | #define TYPE_FLOPPY 0x4
|
---|
281 | #define TYPE_WORM 0x8
|
---|
282 | #define TYPE_REMOTE 0x10
|
---|
283 | #define TYPE_MOUNTED 0x20
|
---|
284 | #define TYPE_VIRTUAL 0x40
|
---|
285 |
|
---|
286 | /* NT passthrough levels... */
|
---|
287 |
|
---|
288 | #define SMB_FILE_DIRECTORY_INFORMATION 1001
|
---|
289 | #define SMB_FILE_FULL_DIRECTORY_INFORMATION 1002
|
---|
290 | #define SMB_FILE_BOTH_DIRECTORY_INFORMATION 1003
|
---|
291 | #define SMB_FILE_BASIC_INFORMATION 1004
|
---|
292 | #define SMB_FILE_STANDARD_INFORMATION 1005
|
---|
293 | #define SMB_FILE_INTERNAL_INFORMATION 1006
|
---|
294 | #define SMB_FILE_EA_INFORMATION 1007
|
---|
295 | #define SMB_FILE_ACCESS_INFORMATION 1008
|
---|
296 | #define SMB_FILE_NAME_INFORMATION 1009
|
---|
297 | #define SMB_FILE_RENAME_INFORMATION 1010
|
---|
298 | #define SMB_FILE_LINK_INFORMATION 1011
|
---|
299 | #define SMB_FILE_NAMES_INFORMATION 1012
|
---|
300 | #define SMB_FILE_DISPOSITION_INFORMATION 1013
|
---|
301 | #define SMB_FILE_POSITION_INFORMATION 1014
|
---|
302 | #define SMB_FILE_FULL_EA_INFORMATION 1015
|
---|
303 | #define SMB_FILE_MODE_INFORMATION 1016
|
---|
304 | #define SMB_FILE_ALIGNMENT_INFORMATION 1017
|
---|
305 | #define SMB_FILE_ALL_INFORMATION 1018
|
---|
306 | #define SMB_FILE_ALLOCATION_INFORMATION 1019
|
---|
307 | #define SMB_FILE_END_OF_FILE_INFORMATION 1020
|
---|
308 | #define SMB_FILE_ALTERNATE_NAME_INFORMATION 1021
|
---|
309 | #define SMB_FILE_STREAM_INFORMATION 1022
|
---|
310 | #define SMB_FILE_PIPE_INFORMATION 1023
|
---|
311 | #define SMB_FILE_PIPE_LOCAL_INFORMATION 1024
|
---|
312 | #define SMB_FILE_PIPE_REMOTE_INFORMATION 1025
|
---|
313 | #define SMB_FILE_MAILSLOT_QUERY_INFORMATION 1026
|
---|
314 | #define SMB_FILE_MAILSLOT_SET_INFORMATION 1027
|
---|
315 | #define SMB_FILE_COMPRESSION_INFORMATION 1028
|
---|
316 | #define SMB_FILE_OBJECTID_INFORMATION 1029
|
---|
317 | #define SMB_FILE_COMPLETION_INFORMATION 1030
|
---|
318 | #define SMB_FILE_MOVE_CLUSTER_INFORMATION 1031
|
---|
319 | #define SMB_FILE_QUOTA_INFORMATION 1032
|
---|
320 | #define SMB_FILE_REPARSEPOINT_INFORMATION 1033
|
---|
321 | #define SMB_FILE_NETWORK_OPEN_INFORMATION 1034
|
---|
322 | #define SMB_FILE_ATTRIBUTE_TAG_INFORMATION 1035
|
---|
323 | #define SMB_FILE_TRACKING_INFORMATION 1036
|
---|
324 | #define SMB_FILE_MAXIMUM_INFORMATION 1037
|
---|
325 |
|
---|
326 | /* NT passthough levels for qfsinfo. */
|
---|
327 |
|
---|
328 | #define SMB_FS_VOLUME_INFORMATION 1001
|
---|
329 | #define SMB_FS_LABEL_INFORMATION 1002
|
---|
330 | #define SMB_FS_SIZE_INFORMATION 1003
|
---|
331 | #define SMB_FS_DEVICE_INFORMATION 1004
|
---|
332 | #define SMB_FS_ATTRIBUTE_INFORMATION 1005
|
---|
333 | #define SMB_FS_QUOTA_INFORMATION 1006
|
---|
334 | #define SMB_FS_FULL_SIZE_INFORMATION 1007
|
---|
335 | #define SMB_FS_OBJECTID_INFORMATION 1008
|
---|
336 |
|
---|
337 | /* flags on trans2 findfirst/findnext that control search */
|
---|
338 | #define FLAG_TRANS2_FIND_CLOSE 0x1
|
---|
339 | #define FLAG_TRANS2_FIND_CLOSE_IF_END 0x2
|
---|
340 | #define FLAG_TRANS2_FIND_REQUIRE_RESUME 0x4
|
---|
341 | #define FLAG_TRANS2_FIND_CONTINUE 0x8
|
---|
342 | #define FLAG_TRANS2_FIND_BACKUP_INTENT 0x10
|
---|
343 |
|
---|
344 | /* UNIX CIFS Extensions - created by HP */
|
---|
345 | /*
|
---|
346 | * UNIX CIFS Extensions have the range 0x200 - 0x2FF reserved.
|
---|
347 | * Supposedly Microsoft have agreed to this.
|
---|
348 | */
|
---|
349 |
|
---|
350 | #define MIN_UNIX_INFO_LEVEL 0x200
|
---|
351 | #define MAX_UNIX_INFO_LEVEL 0x2FF
|
---|
352 |
|
---|
353 | #define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL))
|
---|
354 |
|
---|
355 | #define SMB_QUERY_FILE_UNIX_BASIC 0x200 /* UNIX File Info*/
|
---|
356 | #define SMB_SET_FILE_UNIX_BASIC 0x200
|
---|
357 | #define SMB_SET_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
|
---|
358 |
|
---|
359 | #define SMB_MODE_NO_CHANGE 0xFFFFFFFF /* file mode value which */
|
---|
360 | /* means "don't change it" */
|
---|
361 | #define SMB_UID_NO_CHANGE 0xFFFFFFFF
|
---|
362 | #define SMB_GID_NO_CHANGE 0xFFFFFFFF
|
---|
363 |
|
---|
364 | #define SMB_SIZE_NO_CHANGE_LO 0xFFFFFFFF
|
---|
365 | #define SMB_SIZE_NO_CHANGE_HI 0xFFFFFFFF
|
---|
366 |
|
---|
367 | #define SMB_TIME_NO_CHANGE_LO 0xFFFFFFFF
|
---|
368 | #define SMB_TIME_NO_CHANGE_HI 0xFFFFFFFF
|
---|
369 |
|
---|
370 | /*
|
---|
371 | Offset Size Name
|
---|
372 | 0 LARGE_INTEGER EndOfFile File size
|
---|
373 | 8 LARGE_INTEGER Blocks Number of bytes used on disk (st_blocks).
|
---|
374 | 16 LARGE_INTEGER CreationTime Creation time
|
---|
375 | 24 LARGE_INTEGER LastAccessTime Last access time
|
---|
376 | 32 LARGE_INTEGER LastModificationTime Last modification time
|
---|
377 | 40 LARGE_INTEGER Uid Numeric user id for the owner
|
---|
378 | 48 LARGE_INTEGER Gid Numeric group id of owner
|
---|
379 | 56 ULONG Type Enumeration specifying the pathname type:
|
---|
380 | 0 -- File
|
---|
381 | 1 -- Directory
|
---|
382 | 2 -- Symbolic link
|
---|
383 | 3 -- Character device
|
---|
384 | 4 -- Block device
|
---|
385 | 5 -- FIFO (named pipe)
|
---|
386 | 6 -- Unix domain socket
|
---|
387 |
|
---|
388 | 60 LARGE_INTEGER devmajor Major device number if type is device
|
---|
389 | 68 LARGE_INTEGER devminor Minor device number if type is device
|
---|
390 | 76 LARGE_INTEGER uniqueid This is a server-assigned unique id for the file. The client
|
---|
391 | will typically map this onto an inode number. The scope of
|
---|
392 | uniqueness is the share.
|
---|
393 | 84 LARGE_INTEGER permissions Standard UNIX file permissions - see below.
|
---|
394 | 92 LARGE_INTEGER nlinks The number of directory entries that map to this entry
|
---|
395 | (number of hard links)
|
---|
396 |
|
---|
397 | 100 - end.
|
---|
398 | */
|
---|
399 |
|
---|
400 | #define SMB_FILE_UNIX_BASIC_SIZE 100
|
---|
401 |
|
---|
402 | /* UNIX filetype mappings. */
|
---|
403 |
|
---|
404 | #define UNIX_TYPE_FILE 0
|
---|
405 | #define UNIX_TYPE_DIR 1
|
---|
406 | #define UNIX_TYPE_SYMLINK 2
|
---|
407 | #define UNIX_TYPE_CHARDEV 3
|
---|
408 | #define UNIX_TYPE_BLKDEV 4
|
---|
409 | #define UNIX_TYPE_FIFO 5
|
---|
410 | #define UNIX_TYPE_SOCKET 6
|
---|
411 | #define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
|
---|
412 |
|
---|
413 | /*
|
---|
414 | * Oh this is fun. "Standard UNIX permissions" has no
|
---|
415 | * meaning in POSIX. We need to define the mapping onto
|
---|
416 | * and off the wire as this was not done in the original HP
|
---|
417 | * spec. JRA.
|
---|
418 | */
|
---|
419 |
|
---|
420 | #define UNIX_X_OTH 0000001
|
---|
421 | #define UNIX_W_OTH 0000002
|
---|
422 | #define UNIX_R_OTH 0000004
|
---|
423 | #define UNIX_X_GRP 0000010
|
---|
424 | #define UNIX_W_GRP 0000020
|
---|
425 | #define UNIX_R_GRP 0000040
|
---|
426 | #define UNIX_X_USR 0000100
|
---|
427 | #define UNIX_W_USR 0000200
|
---|
428 | #define UNIX_R_USR 0000400
|
---|
429 | #define UNIX_STICKY 0001000
|
---|
430 | #define UNIX_SET_GID 0002000
|
---|
431 | #define UNIX_SET_UID 0004000
|
---|
432 |
|
---|
433 | /* Masks for the above */
|
---|
434 | #define UNIX_OTH_MASK 0000007
|
---|
435 | #define UNIX_GRP_MASK 0000070
|
---|
436 | #define UNIX_USR_MASK 0000700
|
---|
437 | #define UNIX_PERM_MASK 0000777
|
---|
438 | #define UNIX_EXTRA_MASK 0007000
|
---|
439 | #define UNIX_ALL_MASK 0007777
|
---|
440 |
|
---|
441 | /* Flags for chflags (CIFS_UNIX_EXTATTR_CAP capability) and
|
---|
442 | * SMB_QUERY_FILE_UNIX_INFO2.
|
---|
443 | */
|
---|
444 | #define EXT_SECURE_DELETE 0x00000001
|
---|
445 | #define EXT_ENABLE_UNDELETE 0x00000002
|
---|
446 | #define EXT_SYNCHRONOUS 0x00000004
|
---|
447 | #define EXT_IMMUTABLE 0x00000008
|
---|
448 | #define EXT_OPEN_APPEND_ONLY 0x00000010
|
---|
449 | #define EXT_DO_NOT_BACKUP 0x00000020
|
---|
450 | #define EXT_NO_UPDATE_ATIME 0x00000040
|
---|
451 | #define EXT_HIDDEN 0x00000080
|
---|
452 |
|
---|
453 | #define SMB_QUERY_FILE_UNIX_LINK 0x201
|
---|
454 | #define SMB_SET_FILE_UNIX_LINK 0x201
|
---|
455 | #define SMB_SET_FILE_UNIX_HLINK 0x203
|
---|
456 | /* SMB_QUERY_POSIX_ACL 0x204 see below */
|
---|
457 | #define SMB_QUERY_XATTR 0x205 /* need for non-user XATTRs */
|
---|
458 | #define SMB_QUERY_ATTR_FLAGS 0x206 /* chflags, chattr */
|
---|
459 | #define SMB_SET_ATTR_FLAGS 0x206
|
---|
460 | #define SMB_QUERY_POSIX_PERMISSION 0x207
|
---|
461 | /* Only valid for qfileinfo */
|
---|
462 | #define SMB_QUERY_POSIX_LOCK 0x208
|
---|
463 | /* Only valid for setfileinfo */
|
---|
464 | #define SMB_SET_POSIX_LOCK 0x208
|
---|
465 |
|
---|
466 | /* The set info levels for POSIX path operations. */
|
---|
467 | #define SMB_POSIX_PATH_OPEN 0x209
|
---|
468 | #define SMB_POSIX_PATH_UNLINK 0x20A
|
---|
469 |
|
---|
470 | #define SMB_QUERY_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
|
---|
471 | #define SMB_SET_FILE_UNIX_INFO2 0x20B
|
---|
472 |
|
---|
473 | /*
|
---|
474 | SMB_QUERY_FILE_UNIX_INFO2 is SMB_QUERY_FILE_UNIX_BASIC with create
|
---|
475 | time and file flags appended. The corresponding info level for
|
---|
476 | findfirst/findnext is SMB_FIND_FILE_UNIX_INFO2.
|
---|
477 | Size Offset Value
|
---|
478 | ---------------------
|
---|
479 | 0 LARGE_INTEGER EndOfFile File size
|
---|
480 | 8 LARGE_INTEGER Blocks Number of blocks used on disk
|
---|
481 | 16 LARGE_INTEGER ChangeTime Attribute change time
|
---|
482 | 24 LARGE_INTEGER LastAccessTime Last access time
|
---|
483 | 32 LARGE_INTEGER LastModificationTime Last modification time
|
---|
484 | 40 LARGE_INTEGER Uid Numeric user id for the owner
|
---|
485 | 48 LARGE_INTEGER Gid Numeric group id of owner
|
---|
486 | 56 ULONG Type Enumeration specifying the file type
|
---|
487 | 60 LARGE_INTEGER devmajor Major device number if type is device
|
---|
488 | 68 LARGE_INTEGER devminor Minor device number if type is device
|
---|
489 | 76 LARGE_INTEGER uniqueid This is a server-assigned unique id
|
---|
490 | 84 LARGE_INTEGER permissions Standard UNIX permissions
|
---|
491 | 92 LARGE_INTEGER nlinks Number of hard links
|
---|
492 | 100 LARGE_INTEGER CreationTime Create/birth time
|
---|
493 | 108 ULONG FileFlags File flags enumeration
|
---|
494 | 112 ULONG FileFlagsMask Mask of valid flags
|
---|
495 | */
|
---|
496 |
|
---|
497 | /* Transact 2 Find First levels */
|
---|
498 | #define SMB_FIND_FILE_UNIX 0x202
|
---|
499 | #define SMB_FIND_FILE_UNIX_INFO2 0x20B /* UNIX File Info2 */
|
---|
500 |
|
---|
501 | #define SMB_FILE_UNIX_INFO2_SIZE 116
|
---|
502 |
|
---|
503 | /*
|
---|
504 | Info level for TRANS2_QFSINFO - returns version of CIFS UNIX extensions, plus
|
---|
505 | 64-bits worth of capability fun :-).
|
---|
506 | Use the same info level for TRANS2_SETFSINFO
|
---|
507 | */
|
---|
508 |
|
---|
509 | #define SMB_QUERY_CIFS_UNIX_INFO 0x200
|
---|
510 | #define SMB_SET_CIFS_UNIX_INFO 0x200
|
---|
511 |
|
---|
512 | /* Returns or sets the following.
|
---|
513 |
|
---|
514 | UINT16 major version number
|
---|
515 | UINT16 minor version number
|
---|
516 | LARGE_INTEGER capability bitfield
|
---|
517 |
|
---|
518 | */
|
---|
519 |
|
---|
520 | #define CIFS_UNIX_MAJOR_VERSION 1
|
---|
521 | #define CIFS_UNIX_MINOR_VERSION 0
|
---|
522 |
|
---|
523 | #define CIFS_UNIX_FCNTL_LOCKS_CAP 0x1
|
---|
524 | #define CIFS_UNIX_POSIX_ACLS_CAP 0x2
|
---|
525 | #define CIFS_UNIX_XATTTR_CAP 0x4 /* for support of other xattr
|
---|
526 | namespaces such as system,
|
---|
527 | security and trusted */
|
---|
528 | #define CIFS_UNIX_EXTATTR_CAP 0x8 /* for support of chattr
|
---|
529 | (chflags) and lsattr */
|
---|
530 | #define CIFS_UNIX_POSIX_PATHNAMES_CAP 0x10 /* Use POSIX pathnames on the wire. */
|
---|
531 | #define CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP 0x20 /* We can cope with POSIX open/mkdir/unlink etc. */
|
---|
532 |
|
---|
533 |
|
---|
534 | #define SMB_QUERY_POSIX_FS_INFO 0x201
|
---|
535 |
|
---|
536 | /* Returns FILE_SYSTEM_POSIX_INFO struct as follows
|
---|
537 | (NB For undefined values return -1 in that field)
|
---|
538 | le32 OptimalTransferSize; bsize on some os, iosize on other os, This
|
---|
539 | is a hint to the client about best size. Server
|
---|
540 | can return -1 if no preference, ie if SMB
|
---|
541 | negotiated size is adequate for optimal
|
---|
542 | read/write performance
|
---|
543 | le32 BlockSize; (often 512 bytes) NB: BlockSize * TotalBlocks = disk space
|
---|
544 | le64 TotalBlocks; redundant with other infolevels but easy to ret here
|
---|
545 | le64 BlocksAvail; although redundant, easy to return
|
---|
546 | le64 UserBlocksAvail; bavail
|
---|
547 | le64 TotalFileNodes;
|
---|
548 | le64 FreeFileNodes;
|
---|
549 | le64 FileSysIdentifier; fsid
|
---|
550 | (NB statfs field Namelen comes from FILE_SYSTEM_ATTRIBUTE_INFO call)
|
---|
551 | (NB statfs field flags can come from FILE_SYSTEM_DEVICE_INFO call)
|
---|
552 | */
|
---|
553 |
|
---|
554 | /* ... more as we think of them :-). */
|
---|
555 |
|
---|
556 | /* SMB POSIX ACL definitions. */
|
---|
557 | /* Wire format is (all little endian) :
|
---|
558 |
|
---|
559 | [2 bytes] - Version number.
|
---|
560 | [2 bytes] - Number of ACE entries to follow.
|
---|
561 | [2 bytes] - Number of default ACE entries to follow.
|
---|
562 | -------------------------------------
|
---|
563 | ^
|
---|
564 | |
|
---|
565 | ACE entries
|
---|
566 | |
|
---|
567 | v
|
---|
568 | -------------------------------------
|
---|
569 | ^
|
---|
570 | |
|
---|
571 | Default ACE entries
|
---|
572 | |
|
---|
573 | v
|
---|
574 | -------------------------------------
|
---|
575 |
|
---|
576 | Where an ACE entry looks like :
|
---|
577 |
|
---|
578 | [1 byte] - Entry type.
|
---|
579 |
|
---|
580 | Entry types are :
|
---|
581 |
|
---|
582 | ACL_USER_OBJ 0x01
|
---|
583 | ACL_USER 0x02
|
---|
584 | ACL_GROUP_OBJ 0x04
|
---|
585 | ACL_GROUP 0x08
|
---|
586 | ACL_MASK 0x10
|
---|
587 | ACL_OTHER 0x20
|
---|
588 |
|
---|
589 | [1 byte] - permissions (perm_t)
|
---|
590 |
|
---|
591 | perm_t types are :
|
---|
592 |
|
---|
593 | ACL_READ 0x04
|
---|
594 | ACL_WRITE 0x02
|
---|
595 | ACL_EXECUTE 0x01
|
---|
596 |
|
---|
597 | [8 bytes] - uid/gid to apply this permission to.
|
---|
598 |
|
---|
599 | In the same format as the uid/gid fields in the other
|
---|
600 | UNIX extensions definitions. Use 0xFFFFFFFFFFFFFFFF for
|
---|
601 | the MASK and OTHER entry types.
|
---|
602 |
|
---|
603 | If the Number of ACE entries for either file or default ACE's
|
---|
604 | is set to 0xFFFF this means ignore this kind of ACE (and the
|
---|
605 | number of entries sent will be zero.
|
---|
606 |
|
---|
607 | */
|
---|
608 |
|
---|
609 | #define SMB_QUERY_POSIX_WHOAMI 0x202
|
---|
610 |
|
---|
611 | enum smb_whoami_flags {
|
---|
612 | SMB_WHOAMI_GUEST = 0x1 /* Logged in as (or squashed to) guest */
|
---|
613 | };
|
---|
614 |
|
---|
615 | /* Mask of which WHOAMI bits are valid. This should make it easier for clients
|
---|
616 | * to cope with servers that have different sets of WHOAMI flags (as more get
|
---|
617 | * added).
|
---|
618 | */
|
---|
619 | #define SMB_WHOAMI_MASK 0x00000001
|
---|
620 |
|
---|
621 | /*
|
---|
622 | SMBWhoami - Query the user mapping performed by the server for the
|
---|
623 | connected tree. This is a subcommand of the TRANS2_QFSINFO.
|
---|
624 |
|
---|
625 | Returns:
|
---|
626 | 4 bytes unsigned - mapping flags (smb_whoami_flags)
|
---|
627 | 4 bytes unsigned - flags mask
|
---|
628 |
|
---|
629 | 8 bytes unsigned - primary UID
|
---|
630 | 8 bytes unsigned - primary GID
|
---|
631 | 4 bytes unsigned - number of supplementary GIDs
|
---|
632 | 4 bytes unsigned - number of SIDs
|
---|
633 | 4 bytes unsigned - SID list byte count
|
---|
634 | 4 bytes - pad / reserved (must be zero)
|
---|
635 |
|
---|
636 | 8 bytes unsigned[] - list of GIDs (may be empty)
|
---|
637 | DOM_SID[] - list of SIDs (may be empty)
|
---|
638 | */
|
---|
639 |
|
---|
640 | /* The query/set info levels for POSIX ACLs. */
|
---|
641 | #define SMB_QUERY_POSIX_ACL 0x204
|
---|
642 | #define SMB_SET_POSIX_ACL 0x204
|
---|
643 |
|
---|
644 | /* Current on the wire ACL version. */
|
---|
645 | #define SMB_POSIX_ACL_VERSION 1
|
---|
646 |
|
---|
647 | /* ACE entry type. */
|
---|
648 | #define SMB_POSIX_ACL_USER_OBJ 0x01
|
---|
649 | #define SMB_POSIX_ACL_USER 0x02
|
---|
650 | #define SMB_POSIX_ACL_GROUP_OBJ 0x04
|
---|
651 | #define SMB_POSIX_ACL_GROUP 0x08
|
---|
652 | #define SMB_POSIX_ACL_MASK 0x10
|
---|
653 | #define SMB_POSIX_ACL_OTHER 0x20
|
---|
654 |
|
---|
655 | /* perm_t types. */
|
---|
656 | #define SMB_POSIX_ACL_READ 0x04
|
---|
657 | #define SMB_POSIX_ACL_WRITE 0x02
|
---|
658 | #define SMB_POSIX_ACL_EXECUTE 0x01
|
---|
659 |
|
---|
660 | #define SMB_POSIX_ACL_HEADER_SIZE 6
|
---|
661 | #define SMB_POSIX_ACL_ENTRY_SIZE 10
|
---|
662 |
|
---|
663 | #define SMB_POSIX_IGNORE_ACE_ENTRIES 0xFFFF
|
---|
664 |
|
---|
665 | /* Definition of data block of SMB_SET_POSIX_LOCK */
|
---|
666 | /*
|
---|
667 | [2 bytes] lock_type - 0 = Read, 1 = Write, 2 = Unlock
|
---|
668 | [2 bytes] lock_flags - 1 = Wait (only valid for setlock)
|
---|
669 | [4 bytes] pid = locking context.
|
---|
670 | [8 bytes] start = unsigned 64 bits.
|
---|
671 | [8 bytes] length = unsigned 64 bits.
|
---|
672 | */
|
---|
673 |
|
---|
674 | #define POSIX_LOCK_TYPE_OFFSET 0
|
---|
675 | #define POSIX_LOCK_FLAGS_OFFSET 2
|
---|
676 | #define POSIX_LOCK_PID_OFFSET 4
|
---|
677 | #define POSIX_LOCK_START_OFFSET 8
|
---|
678 | #define POSIX_LOCK_LEN_OFFSET 16
|
---|
679 | #define POSIX_LOCK_DATA_SIZE 24
|
---|
680 |
|
---|
681 | #define POSIX_LOCK_FLAG_NOWAIT 0
|
---|
682 | #define POSIX_LOCK_FLAG_WAIT 1
|
---|
683 |
|
---|
684 | #define POSIX_LOCK_TYPE_READ 0
|
---|
685 | #define POSIX_LOCK_TYPE_WRITE 1
|
---|
686 | #define POSIX_LOCK_TYPE_UNLOCK 2
|
---|
687 |
|
---|
688 | /* SMB_POSIX_PATH_OPEN "open_mode" definitions. */
|
---|
689 | #define SMB_O_RDONLY 0x1
|
---|
690 | #define SMB_O_WRONLY 0x2
|
---|
691 | #define SMB_O_RDWR 0x4
|
---|
692 |
|
---|
693 | #define SMB_ACCMODE 0x7
|
---|
694 |
|
---|
695 | #define SMB_O_CREAT 0x10
|
---|
696 | #define SMB_O_EXCL 0x20
|
---|
697 | #define SMB_O_TRUNC 0x40
|
---|
698 | #define SMB_O_APPEND 0x80
|
---|
699 | #define SMB_O_SYNC 0x100
|
---|
700 | #define SMB_O_DIRECTORY 0x200
|
---|
701 | #define SMB_O_NOFOLLOW 0x400
|
---|
702 | #define SMB_O_DIRECT 0x800
|
---|
703 |
|
---|
704 | /* Definition of request data block for SMB_POSIX_PATH_OPEN */
|
---|
705 | /*
|
---|
706 | [4 bytes] flags (as smb_ntcreate_Flags).
|
---|
707 | [4 bytes] open_mode - SMB_O_xxx flags above.
|
---|
708 | [8 bytes] mode_t (permissions) - same encoding as "Standard UNIX permissions" above in SMB_SET_FILE_UNIX_BASIC.
|
---|
709 | [2 bytes] ret_info_level - optimization. Info level to be returned.
|
---|
710 | */
|
---|
711 |
|
---|
712 | /* Definition of reply data block for SMB_POSIX_PATH_OPEN */
|
---|
713 |
|
---|
714 | #define SMB_NO_INFO_LEVEL_RETURNED 0xFFFF
|
---|
715 |
|
---|
716 | /*
|
---|
717 | [2 bytes] - flags field. Identical to flags reply for oplock response field in SMBNTCreateX)
|
---|
718 | [2 bytes] - FID returned.
|
---|
719 | [4 bytes] - CreateAction (same as in NTCreateX response).
|
---|
720 | [2 bytes] - reply info level - as requested or 0xFFFF if not available.
|
---|
721 | [2 bytes] - padding (must be zero)
|
---|
722 | [n bytes] - info level reply - if available.
|
---|
723 | */
|
---|
724 |
|
---|
725 | /* Definition of request data block for SMB_POSIX_UNLINK */
|
---|
726 | /*
|
---|
727 | [2 bytes] flags (defined below).
|
---|
728 | */
|
---|
729 |
|
---|
730 | #define SMB_POSIX_UNLINK_FILE_TARGET 0
|
---|
731 | #define SMB_POSIX_UNLINK_DIRECTORY_TARGET 1
|
---|
732 |
|
---|
733 | #endif
|
---|