This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[sfrench/samba-autobuild/.git] / source3 / include / trans2.h
1 /* 
2    Unix SMB/CIFS implementation.
3    SMB transaction2 handling
4    Copyright (C) Jeremy Allison 1994-2002.
5
6    Extensively modified by Andrew Tridgell, 1995
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #ifndef _TRANS2_H_
24 #define _TRANS2_H_
25
26 /* Define the structures needed for the trans2 calls. */
27
28 /*******************************************************
29  For DosFindFirst/DosFindNext - level 1
30
31 MAXFILENAMELEN = 255;
32 FDATE == uint16
33 FTIME == uint16
34 ULONG == uint32
35 USHORT == uint16
36
37 typedef struct _FILEFINDBUF {
38 Byte offset   Type     name                description
39 -------------+-------+-------------------+--------------
40 0             FDATE    fdateCreation;
41 2             FTIME    ftimeCreation;
42 4             FDATE    fdateLastAccess;
43 6             FTIME    ftimeLastAccess;
44 8             FDATE    fdateLastWrite;
45 10            FTIME    ftimeLastWrite;
46 12            ULONG    cbFile               file length in bytes
47 16            ULONG    cbFileAlloc          size of file allocation unit
48 20            USHORT   attrFile
49 22            UCHAR    cchName              length of name to follow (not including zero)
50 23            UCHAR    achName[MAXFILENAMELEN]; Null terminated name
51 } FILEFINDBUF;
52 *********************************************************/
53
54 #define l1_fdateCreation 0
55 #define l1_fdateLastAccess 4
56 #define l1_fdateLastWrite 8
57 #define l1_cbFile 12
58 #define l1_cbFileAlloc 16
59 #define l1_attrFile 20
60 #define l1_cchName 22
61 #define l1_achName 23
62
63 /**********************************************************
64 For DosFindFirst/DosFindNext - level 2
65
66 typedef struct _FILEFINDBUF2 {
67 Byte offset   Type     name                description
68 -------------+-------+-------------------+--------------
69 0             FDATE    fdateCreation;
70 2             FTIME    ftimeCreation;
71 4             FDATE    fdateLastAccess;
72 6             FTIME    ftimeLastAccess;
73 8             FDATE    fdateLastWrite;
74 10            FTIME    ftimeLastWrite;
75 12            ULONG    cbFile               file length in bytes
76 16            ULONG    cbFileAlloc          size of file allocation unit
77 20            USHORT   attrFile
78 22            ULONG    cbList               Extended attribute list (always 0)
79 26            UCHAR    cchName              length of name to follow (not including zero)
80 27            UCHAR    achName[MAXFILENAMELEN]; Null terminated name
81 } FILEFINDBUF2;
82 *************************************************************/
83
84 #define l2_fdateCreation 0
85 #define l2_fdateLastAccess 4
86 #define l2_fdateLastWrite 8
87 #define l2_cbFile 12
88 #define l2_cbFileAlloc 16
89 #define l2_attrFile 20
90 #define l2_cbList 22
91 #define l2_cchName 26
92 #define l2_achName 27
93
94
95 /**********************************************************
96 For DosFindFirst/DosFindNext - level 260
97
98 typedef struct _FILEFINDBUF260 {
99 Byte offset   Type     name                description
100 -------------+-------+-------------------+--------------
101 0              ULONG  NextEntryOffset;
102 4              ULONG  FileIndex;
103 8              LARGE_INTEGER CreationTime;
104 16             LARGE_INTEGER LastAccessTime;
105 24             LARGE_INTEGER LastWriteTime;
106 32             LARGE_INTEGER ChangeTime;
107 40             LARGE_INTEGER EndOfFile;
108 48             LARGE_INTEGER AllocationSize;
109 56             ULONG FileAttributes;
110 60             ULONG FileNameLength;
111 64             ULONG EaSize;
112 68             CHAR ShortNameLength;
113 70             UNICODE ShortName[12];
114 94             UNICODE FileName[];
115 *************************************************************/
116
117 #define l260_achName 94
118
119
120 /**********************************************************
121 For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
122 DosSetFileInfo - level 1
123
124 typedef struct _FILESTATUS {
125 Byte offset   Type     name                description
126 -------------+-------+-------------------+--------------
127 0             FDATE    fdateCreation;
128 2             FTIME    ftimeCreation;
129 4             FDATE    fdateLastAccess;
130 6             FTIME    ftimeLastAccess;
131 8             FDATE    fdateLastWrite;
132 10            FTIME    ftimeLastWrite;
133 12            ULONG    cbFile               file length in bytes
134 16            ULONG    cbFileAlloc          size of file allocation unit
135 20            USHORT   attrFile
136 } FILESTATUS;
137 *************************************************************/
138
139 /* Use the l1_ defines from DosFindFirst */
140
141 /**********************************************************
142 For DosQueryPathInfo/DosQueryFileInfo/DosSetPathInfo/
143 DosSetFileInfo - level 2
144
145 typedef struct _FILESTATUS2 {
146 Byte offset   Type     name                description
147 -------------+-------+-------------------+--------------
148 0             FDATE    fdateCreation;
149 2             FTIME    ftimeCreation;
150 4             FDATE    fdateLastAccess;
151 6             FTIME    ftimeLastAccess;
152 8             FDATE    fdateLastWrite;
153 10            FTIME    ftimeLastWrite;
154 12            ULONG    cbFile               file length in bytes
155 16            ULONG    cbFileAlloc          size of file allocation unit
156 20            USHORT   attrFile
157 22            ULONG    cbList               Length of EA's (0)
158 } FILESTATUS2;
159 *************************************************************/
160
161 /* Use the l2_ #defines from DosFindFirst */
162
163 /**********************************************************
164 For DosQFSInfo/DosSetFSInfo - level 1
165
166 typedef struct _FSALLOCATE {
167 Byte offset   Type     name                description
168 -------------+-------+-------------------+--------------
169 0             ULONG    idFileSystem       id of file system
170 4             ULONG    cSectorUnit        number of sectors per allocation unit
171 8             ULONG    cUnit              number of allocation units
172 12            ULONG    cUnitAvail         Available allocation units
173 16            USHORT   cbSector           bytes per sector
174 } FSALLOCATE;
175 *************************************************************/
176
177 #define l1_idFileSystem 0
178 #define l1_cSectorUnit 4
179 #define l1_cUnit 8
180 #define l1_cUnitAvail 12
181 #define l1_cbSector 16
182
183 /**********************************************************
184 For DosQFSInfo/DosSetFSInfo - level 2
185
186 typedef struct _FSINFO {
187 Byte offset   Type     name                description
188 -------------+-------+-------------------+--------------
189 0             FDATE   vol_fdateCreation
190 2             FTIME   vol_ftimeCreation
191 4             UCHAR   vol_cch             length of volume name (excluding NULL)
192 5             UCHAR   vol_szVolLabel[12]  volume name
193 } FSINFO;
194 *************************************************************/
195
196 #define SMB_INFO_STANDARD               1
197 #define SMB_INFO_QUERY_EA_SIZE          2
198 #define SMB_INFO_QUERY_EAS_FROM_LIST    3
199 #define SMB_INFO_QUERY_ALL_EAS          4
200 #define SMB_INFO_IS_NAME_VALID          6
201 #define SMB_QUERY_FS_LABEL_INFO                 0x101
202 #define SMB_QUERY_FS_VOLUME_INFO                0x102
203 #define SMB_QUERY_FS_SIZE_INFO                  0x103
204 #define SMB_QUERY_FS_DEVICE_INFO                0x104
205 #define SMB_QUERY_FS_ATTRIBUTE_INFO             0x105
206
207
208 #define l2_vol_fdateCreation 0
209 #define l2_vol_cch 4
210 #define l2_vol_szVolLabel 5
211
212
213 #define SMB_QUERY_FILE_BASIC_INFO       0x101
214 #define SMB_QUERY_FILE_STANDARD_INFO    0x102
215 #define SMB_QUERY_FILE_EA_INFO          0x103
216 #define SMB_QUERY_FILE_NAME_INFO        0x104
217 #define SMB_QUERY_FILE_ALLOCATION_INFO  0x105
218 #define SMB_QUERY_FILE_END_OF_FILEINFO  0x106
219 #define SMB_QUERY_FILE_ALL_INFO         0x107
220 #define SMB_QUERY_FILE_ALT_NAME_INFO    0x108
221 #define SMB_QUERY_FILE_STREAM_INFO      0x109
222
223 #define SMB_FIND_FILE_DIRECTORY_INFO            0x101
224 #define SMB_FIND_FILE_FULL_DIRECTORY_INFO       0x102
225 #define SMB_FIND_FILE_NAMES_INFO                0x103
226 #define SMB_FIND_FILE_BOTH_DIRECTORY_INFO       0x104
227
228 #define SMB_SET_FILE_BASIC_INFO         0x101
229 #define SMB_SET_FILE_DISPOSITION_INFO   0x102
230 #define SMB_SET_FILE_ALLOCATION_INFO    0x103
231 #define SMB_SET_FILE_END_OF_FILE_INFO   0x104
232
233 /* Query FS info. */
234 #define SMB_INFO_ALLOCATION             1
235 #define SMB_INFO_VOLUME                 2
236
237 /*
238  * Thursby MAC extensions....
239  */
240
241 /*
242  * MAC CIFS Extensions have the range 0x300 - 0x2FF reserved.
243  * Supposedly Microsoft have agreed to this.
244  */
245
246 #define MIN_MAC_INFO_LEVEL 0x300
247 #define MAX_MAC_INFO_LEVEL 0x3FF
248
249 #define SMB_MAC_QUERY_FS_INFO           0x301
250
251 #define DIRLEN_GUESS (45+MAX(l1_achName,l2_achName))
252
253 /*
254  * DeviceType and Characteristics returned in a
255  * SMB_QUERY_FS_DEVICE_INFO call.
256  */
257
258 #define DEVICETYPE_CD_ROM               0x2
259 #define DEVICETYPE_CD_ROM_FILE_SYSTEM   0x3
260 #define DEVICETYPE_DISK                 0x7
261 #define DEVICETYPE_DISK_FILE_SYSTEM     0x8
262 #define DEVICETYPE_FILE_SYSTEM          0x9
263
264 /* Characteristics. */
265 #define TYPE_REMOVABLE_MEDIA            0x1
266 #define TYPE_READ_ONLY_DEVICE           0x2
267 #define TYPE_FLOPPY                     0x4
268 #define TYPE_WORM                       0x8
269 #define TYPE_REMOTE                     0x10
270 #define TYPE_MOUNTED                    0x20
271 #define TYPE_VIRTUAL                    0x40
272
273 /* NT passthrough levels... */
274
275 #define SMB_FILE_DIRECTORY_INFORMATION                  1001
276 #define SMB_FILE_FULL_DIRECTORY_INFORMATION             1002
277 #define SMB_FILE_BOTH_DIRECTORY_INFORMATION             1003
278 #define SMB_FILE_BASIC_INFORMATION                      1004
279 #define SMB_FILE_STANDARD_INFORMATION                   1005
280 #define SMB_FILE_INTERNAL_INFORMATION                   1006
281 #define SMB_FILE_EA_INFORMATION                         1007
282 #define SMB_FILE_ACCESS_INFORMATION                     1008
283 #define SMB_FILE_NAME_INFORMATION                       1009
284 #define SMB_FILE_RENAME_INFORMATION                     1010
285 #define SMB_FILE_LINK_INFORMATION                       1011
286 #define SMB_FILE_NAMES_INFORMATION                      1012
287 #define SMB_FILE_DISPOSITION_INFORMATION                1013
288 #define SMB_FILE_POSITION_INFORMATION                   1014
289 #define SMB_FILE_FULL_EA_INFORMATION                    1015
290 #define SMB_FILE_MODE_INFORMATION                       1016
291 #define SMB_FILE_ALIGNMENT_INFORMATION                  1017
292 #define SMB_FILE_ALL_INFORMATION                        1018
293 #define SMB_FILE_ALLOCATION_INFORMATION                 1019
294 #define SMB_FILE_END_OF_FILE_INFORMATION                1020
295 #define SMB_FILE_ALTERNATE_NAME_INFORMATION             1021
296 #define SMB_FILE_STREAM_INFORMATION                     1022
297 #define SMB_FILE_PIPE_INFORMATION                       1023
298 #define SMB_FILE_PIPE_LOCAL_INFORMATION                 1024
299 #define SMB_FILE_PIPE_REMOTE_INFORMATION                1025
300 #define SMB_FILE_MAILSLOT_QUERY_INFORMATION             1026
301 #define SMB_FILE_MAILSLOT_SET_INFORMATION               1027
302 #define SMB_FILE_COMPRESSION_INFORMATION                1028
303 #define SMB_FILE_OBJECTID_INFORMATION                   1029
304 #define SMB_FILE_COMPLETION_INFORMATION                 1030
305 #define SMB_FILE_MOVE_CLUSTER_INFORMATION               1031
306 #define SMB_FILE_QUOTA_INFORMATION                      1032
307 #define SMB_FILE_REPARSEPOINT_INFORMATION               1033
308 #define SMB_FILE_NETWORK_OPEN_INFORMATION               1034
309 #define SMB_FILE_ATTRIBUTE_TAG_INFORMATION              1035
310 #define SMB_FILE_TRACKING_INFORMATION                   1036
311 #define SMB_FILE_MAXIMUM_INFORMATION                    1037
312
313 /* NT passthough levels for qfsinfo. */
314
315 #define SMB_FS_VOLUME_INFORMATION                       1001
316 #define SMB_FS_LABEL_INFORMATION                        1002
317 #define SMB_FS_SIZE_INFORMATION                         1003
318 #define SMB_FS_DEVICE_INFORMATION                       1004
319 #define SMB_FS_ATTRIBUTE_INFORMATION                    1005
320 #define SMB_FS_CONTROL_INFORMATION                      1006
321 #define SMB_FS_FULL_SIZE_INFORMATION                    1007
322 #define SMB_FS_OBJECTID_INFORMATION                     1008
323
324 /* UNIX CIFS Extensions - created by HP */
325 /*
326  * UNIX CIFS Extensions have the range 0x200 - 0x2FF reserved.
327  * Supposedly Microsoft have agreed to this.
328  */
329
330 #define MIN_UNIX_INFO_LEVEL 0x200
331 #define MAX_UNIX_INFO_LEVEL 0x2FF
332
333 #define INFO_LEVEL_IS_UNIX(level) (((level) >= MIN_UNIX_INFO_LEVEL) && ((level) <= MAX_UNIX_INFO_LEVEL))
334
335 #define SMB_QUERY_FILE_UNIX_BASIC      0x200   /* UNIX File Info*/
336 #define SMB_SET_FILE_UNIX_BASIC        0x200
337
338 #define SMB_MODE_NO_CHANGE                 0xFFFFFFFF     /* file mode value which */
339                                               /* means "don't change it" */
340 #define SMB_UID_NO_CHANGE                  0xFFFFFFFF
341 #define SMB_GID_NO_CHANGE                  0xFFFFFFFF
342
343 #define SMB_SIZE_NO_CHANGE_LO              0xFFFFFFFF
344 #define SMB_SIZE_NO_CHANGE_HI              0xFFFFFFFF
345  
346 #define SMB_TIME_NO_CHANGE_LO              0xFFFFFFFF
347 #define SMB_TIME_NO_CHANGE_HI              0xFFFFFFFF
348
349 /*
350 Offset Size         Name
351 0      LARGE_INTEGER EndOfFile                File size
352 8      LARGE_INTEGER Blocks                   Number of bytes used on disk (st_blocks).
353 16     LARGE_INTEGER CreationTime             Creation time
354 24     LARGE_INTEGER LastAccessTime           Last access time
355 32     LARGE_INTEGER LastModificationTime     Last modification time
356 40     LARGE_INTEGER Uid                      Numeric user id for the owner
357 48     LARGE_INTEGER Gid                      Numeric group id of owner
358 56     ULONG Type                             Enumeration specifying the pathname type:
359                                               0 -- File
360                                               1 -- Directory
361                                               2 -- Symbolic link
362                                               3 -- Character device
363                                               4 -- Block device
364                                               5 -- FIFO (named pipe)
365                                               6 -- Unix domain socket
366
367 60     LARGE_INTEGER devmajor                 Major device number if type is device
368 68     LARGE_INTEGER devminor                 Minor device number if type is device
369 76     LARGE_INTEGER uniqueid                 This is a server-assigned unique id for the file. The client
370                                               will typically map this onto an inode number. The scope of
371                                               uniqueness is the share.
372 84     LARGE_INTEGER permissions              Standard UNIX file permissions  - see below.
373 92     LARGE_INTEGER nlinks                   The number of directory entries that map to this entry
374                                               (number of hard links)
375
376 100 - end.
377 */
378
379 /* UNIX filetype mappings. */
380
381 #define UNIX_TYPE_FILE 0
382 #define UNIX_TYPE_DIR 1
383 #define UNIX_TYPE_SYMLINK 2
384 #define UNIX_TYPE_CHARDEV 3
385 #define UNIX_TYPE_BLKDEV 4
386 #define UNIX_TYPE_FIFO 5
387 #define UNIX_TYPE_SOCKET 6
388 #define UNIX_TYPE_UNKNOWN 0xFFFFFFFF
389
390 /*
391  * Oh this is fun. "Standard UNIX permissions" has no
392  * meaning in POSIX. We need to define the mapping onto
393  * and off the wire as this was not done in the original HP
394  * spec. JRA.
395  */
396
397 #define UNIX_X_OTH                      0000001
398 #define UNIX_W_OTH                      0000002
399 #define UNIX_R_OTH                      0000004
400 #define UNIX_X_GRP                      0000010
401 #define UNIX_W_GRP                      0000020
402 #define UNIX_R_GRP                      0000040
403 #define UNIX_X_USR                      0000100
404 #define UNIX_W_USR                      0000200
405 #define UNIX_R_USR                      0000400
406 #define UNIX_STICKY                     0001000
407 #define UNIX_SET_GID                    0002000
408 #define UNIX_SET_UID                    0004000
409
410 /* Masks for the above */
411 #define UNIX_OTH_MASK                   0000007
412 #define UNIX_GRP_MASK                   0000070
413 #define UNIX_USR_MASK                   0000700
414 #define UNIX_PERM_MASK                  0000777
415 #define UNIX_EXTRA_MASK                 0007000
416 #define UNIX_ALL_MASK                   0007777
417
418 #define SMB_QUERY_FILE_UNIX_LINK       0x201
419 #define SMB_SET_FILE_UNIX_LINK         0x201
420 #define SMB_SET_FILE_UNIX_HLINK        0x203
421
422 #define SMB_FIND_FILE_UNIX             0x202
423
424 /*
425  Info level for QVOLINFO - returns version of CIFS UNIX extensions, plus
426  64-bits worth of capability fun :-).
427 */
428
429 #define SMB_QUERY_CIFS_UNIX_INFO      0x200
430
431 /* Returns the following.
432
433   UINT16             major version number
434   UINT16             minor version number
435   LARGE_INTEGER      capability bitfield
436
437 */
438
439 #define CIFS_UNIX_MAJOR_VERSION 1
440 #define CIFS_UNIX_MINOR_VERSION 0
441
442 #define CIFS_UNIX_FCNTL_LOCKS_CAP           0x1
443 #define CIFS_UNIX_POSIX_ACLS_CAP            0x2
444
445 /* ... more as we think of them :-). */
446
447 #endif