1 | /** @file
|
---|
2 | * IPRT - Filesystem.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Oracle Corporation
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #ifndef ___iprt_fs_h
|
---|
27 | #define ___iprt_fs_h
|
---|
28 |
|
---|
29 | #include <iprt/cdefs.h>
|
---|
30 | #include <iprt/types.h>
|
---|
31 | #include <iprt/time.h>
|
---|
32 |
|
---|
33 |
|
---|
34 | RT_C_DECLS_BEGIN
|
---|
35 |
|
---|
36 | /** @defgroup grp_rt_fs RTFs - Filesystem and Volume
|
---|
37 | * @ingroup grp_rt
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 |
|
---|
42 | /** @name Filesystem Object Mode Flags.
|
---|
43 | *
|
---|
44 | * There are two sets of flags: the unix mode flags and the dos attributes.
|
---|
45 | *
|
---|
46 | * APIs returning mode flags will provide both sets.
|
---|
47 | *
|
---|
48 | * When specifying mode flags to any API at least one of them must be given. If
|
---|
49 | * one set is missing the API will synthesize it from the one given if it
|
---|
50 | * requires it.
|
---|
51 | *
|
---|
52 | * Both sets match their x86 ABIs, the DOS/NT one is simply shifted up 16 bits.
|
---|
53 | * The DOS/NT range is bits 16 to 31 inclusively. The Unix range is bits 0 to 15
|
---|
54 | * (inclusively).
|
---|
55 | *
|
---|
56 | * @remarks These constants have been comitted to a binary format and must not
|
---|
57 | * be changed in any incompatible ways.
|
---|
58 | *
|
---|
59 | * @{
|
---|
60 | */
|
---|
61 |
|
---|
62 | /** Set user id on execution (S_ISUID). */
|
---|
63 | #define RTFS_UNIX_ISUID 0004000U
|
---|
64 | /** Set group id on execution (S_ISGID). */
|
---|
65 | #define RTFS_UNIX_ISGID 0002000U
|
---|
66 | /** Sticky bit (S_ISVTX / S_ISTXT). */
|
---|
67 | #define RTFS_UNIX_ISTXT 0001000U
|
---|
68 |
|
---|
69 | /** Owner RWX mask (S_IRWXU). */
|
---|
70 | #define RTFS_UNIX_IRWXU 0000700U
|
---|
71 | /** Owner readable (S_IRUSR). */
|
---|
72 | #define RTFS_UNIX_IRUSR 0000400U
|
---|
73 | /** Owner writable (S_IWUSR). */
|
---|
74 | #define RTFS_UNIX_IWUSR 0000200U
|
---|
75 | /** Owner executable (S_IXUSR). */
|
---|
76 | #define RTFS_UNIX_IXUSR 0000100U
|
---|
77 |
|
---|
78 | /** Group RWX mask (S_IRWXG). */
|
---|
79 | #define RTFS_UNIX_IRWXG 0000070U
|
---|
80 | /** Group readable (S_IRGRP). */
|
---|
81 | #define RTFS_UNIX_IRGRP 0000040U
|
---|
82 | /** Group writable (S_IWGRP). */
|
---|
83 | #define RTFS_UNIX_IWGRP 0000020U
|
---|
84 | /** Group executable (S_IXGRP). */
|
---|
85 | #define RTFS_UNIX_IXGRP 0000010U
|
---|
86 |
|
---|
87 | /** Other RWX mask (S_IRWXO). */
|
---|
88 | #define RTFS_UNIX_IRWXO 0000007U
|
---|
89 | /** Other readable (S_IROTH). */
|
---|
90 | #define RTFS_UNIX_IROTH 0000004U
|
---|
91 | /** Other writable (S_IWOTH). */
|
---|
92 | #define RTFS_UNIX_IWOTH 0000002U
|
---|
93 | /** Other executable (S_IXOTH). */
|
---|
94 | #define RTFS_UNIX_IXOTH 0000001U
|
---|
95 |
|
---|
96 | /** Named pipe (fifo) (S_IFIFO). */
|
---|
97 | #define RTFS_TYPE_FIFO 0010000U
|
---|
98 | /** Character device (S_IFCHR). */
|
---|
99 | #define RTFS_TYPE_DEV_CHAR 0020000U
|
---|
100 | /** Directory (S_IFDIR). */
|
---|
101 | #define RTFS_TYPE_DIRECTORY 0040000U
|
---|
102 | /** Block device (S_IFBLK). */
|
---|
103 | #define RTFS_TYPE_DEV_BLOCK 0060000U
|
---|
104 | /** Regular file (S_IFREG). */
|
---|
105 | #define RTFS_TYPE_FILE 0100000U
|
---|
106 | /** Symbolic link (S_IFLNK). */
|
---|
107 | #define RTFS_TYPE_SYMLINK 0120000U
|
---|
108 | /** Socket (S_IFSOCK). */
|
---|
109 | #define RTFS_TYPE_SOCKET 0140000U
|
---|
110 | /** Whiteout (S_IFWHT). */
|
---|
111 | #define RTFS_TYPE_WHITEOUT 0160000U
|
---|
112 | /** Type mask (S_IFMT). */
|
---|
113 | #define RTFS_TYPE_MASK 0170000U
|
---|
114 |
|
---|
115 | /** Unix attribute mask. */
|
---|
116 | #define RTFS_UNIX_MASK 0xffffU
|
---|
117 | /** The mask of all the NT, OS/2 and DOS attributes. */
|
---|
118 | #define RTFS_DOS_MASK (0x7fffU << RTFS_DOS_SHIFT)
|
---|
119 |
|
---|
120 | /** The shift value. */
|
---|
121 | #define RTFS_DOS_SHIFT 16
|
---|
122 | /** The mask of the OS/2 and DOS attributes. */
|
---|
123 | #define RTFS_DOS_MASK_OS2 (0x003fU << RTFS_DOS_SHIFT)
|
---|
124 | /** The mask of the NT attributes. */
|
---|
125 | #define RTFS_DOS_MASK_NT (0x7fffU << RTFS_DOS_SHIFT)
|
---|
126 |
|
---|
127 | /** Readonly object. */
|
---|
128 | #define RTFS_DOS_READONLY (0x0001U << RTFS_DOS_SHIFT)
|
---|
129 | /** Hidden object. */
|
---|
130 | #define RTFS_DOS_HIDDEN (0x0002U << RTFS_DOS_SHIFT)
|
---|
131 | /** System object. */
|
---|
132 | #define RTFS_DOS_SYSTEM (0x0004U << RTFS_DOS_SHIFT)
|
---|
133 | /** Directory. */
|
---|
134 | #define RTFS_DOS_DIRECTORY (0x0010U << RTFS_DOS_SHIFT)
|
---|
135 | /** Archived object.
|
---|
136 | * This bit is set by the filesystem after each modification of a file. */
|
---|
137 | #define RTFS_DOS_ARCHIVED (0x0020U << RTFS_DOS_SHIFT)
|
---|
138 | /** Undocumented / Reserved, used to be the FAT volume label. */
|
---|
139 | #define RTFS_DOS_NT_DEVICE (0x0040U << RTFS_DOS_SHIFT)
|
---|
140 | /** Normal object, no other attribute set (NT). */
|
---|
141 | #define RTFS_DOS_NT_NORMAL (0x0080U << RTFS_DOS_SHIFT)
|
---|
142 | /** Temporary object (NT). */
|
---|
143 | #define RTFS_DOS_NT_TEMPORARY (0x0100U << RTFS_DOS_SHIFT)
|
---|
144 | /** Sparse file (NT). */
|
---|
145 | #define RTFS_DOS_NT_SPARSE_FILE (0x0200U << RTFS_DOS_SHIFT)
|
---|
146 | /** Reparse point (NT). */
|
---|
147 | #define RTFS_DOS_NT_REPARSE_POINT (0x0400U << RTFS_DOS_SHIFT)
|
---|
148 | /** Compressed object (NT).
|
---|
149 | * For a directory, compression is the default for new files. */
|
---|
150 | #define RTFS_DOS_NT_COMPRESSED (0x0800U << RTFS_DOS_SHIFT)
|
---|
151 | /** Physically offline data (NT).
|
---|
152 | * MSDN say, don't mess with this one. */
|
---|
153 | #define RTFS_DOS_NT_OFFLINE (0x1000U << RTFS_DOS_SHIFT)
|
---|
154 | /** Not content indexed by the content indexing service (NT). */
|
---|
155 | #define RTFS_DOS_NT_NOT_CONTENT_INDEXED (0x2000U << RTFS_DOS_SHIFT)
|
---|
156 | /** Encryped object (NT).
|
---|
157 | * For a directory, encrypted is the default for new files. */
|
---|
158 | #define RTFS_DOS_NT_ENCRYPTED (0x4000U << RTFS_DOS_SHIFT)
|
---|
159 |
|
---|
160 | /** @} */
|
---|
161 |
|
---|
162 |
|
---|
163 | /** @name Filesystem Object Type Predicates.
|
---|
164 | * @{ */
|
---|
165 | /** Checks the mode flags indicate a named pipe (fifo) (S_ISFIFO). */
|
---|
166 | #define RTFS_IS_FIFO(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_FIFO )
|
---|
167 | /** Checks the mode flags indicate a character device (S_ISCHR). */
|
---|
168 | #define RTFS_IS_DEV_CHAR(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_DEV_CHAR )
|
---|
169 | /** Checks the mode flags indicate a directory (S_ISDIR). */
|
---|
170 | #define RTFS_IS_DIRECTORY(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_DIRECTORY )
|
---|
171 | /** Checks the mode flags indicate a block device (S_ISBLK). */
|
---|
172 | #define RTFS_IS_DEV_BLOCK(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_DEV_BLOCK )
|
---|
173 | /** Checks the mode flags indicate a regular file (S_ISREG). */
|
---|
174 | #define RTFS_IS_FILE(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_FILE )
|
---|
175 | /** Checks the mode flags indicate a symbolic link (S_ISLNK). */
|
---|
176 | #define RTFS_IS_SYMLINK(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_SYMLINK )
|
---|
177 | /** Checks the mode flags indicate a socket (S_ISSOCK). */
|
---|
178 | #define RTFS_IS_SOCKET(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_SOCKET )
|
---|
179 | /** Checks the mode flags indicate a whiteout (S_ISWHT). */
|
---|
180 | #define RTFS_IS_WHITEOUT(fMode) ( ((fMode) & RTFS_TYPE_MASK) == RTFS_TYPE_WHITEOUT )
|
---|
181 | /** @} */
|
---|
182 |
|
---|
183 |
|
---|
184 | /**
|
---|
185 | * Filesystem type IDs returned by RTFsQueryType.
|
---|
186 | *
|
---|
187 | * This enum is subject to changes and must not be used as part of any ABI or
|
---|
188 | * binary format (file, network, etc).
|
---|
189 | *
|
---|
190 | * @remarks When adding new entries, please update RTFsTypeName(). Also, try
|
---|
191 | * add them to the most natural group.
|
---|
192 | */
|
---|
193 | typedef enum RTFSTYPE
|
---|
194 | {
|
---|
195 | /** Unknown file system. */
|
---|
196 | RTFSTYPE_UNKNOWN = 0,
|
---|
197 |
|
---|
198 | /** Universal Disk Format. */
|
---|
199 | RTFSTYPE_UDF,
|
---|
200 | /** ISO 9660, aka Compact Disc File System (CDFS). */
|
---|
201 | RTFSTYPE_ISO9660,
|
---|
202 | /** Filesystem in Userspace. */
|
---|
203 | RTFSTYPE_FUSE,
|
---|
204 | /** VirtualBox shared folders. */
|
---|
205 | RTFSTYPE_VBOXSHF,
|
---|
206 |
|
---|
207 | /* Linux: */
|
---|
208 | RTFSTYPE_EXT,
|
---|
209 | RTFSTYPE_EXT2,
|
---|
210 | RTFSTYPE_EXT3,
|
---|
211 | RTFSTYPE_EXT4,
|
---|
212 | RTFSTYPE_XFS,
|
---|
213 | RTFSTYPE_CIFS,
|
---|
214 | RTFSTYPE_SMBFS,
|
---|
215 | RTFSTYPE_TMPFS,
|
---|
216 | RTFSTYPE_SYSFS,
|
---|
217 | RTFSTYPE_PROC,
|
---|
218 |
|
---|
219 | /* Windows: */
|
---|
220 | /** New Technology File System. */
|
---|
221 | RTFSTYPE_NTFS,
|
---|
222 | /** FAT12, FAT16 and FAT32 lumped into one basket.
|
---|
223 | * The partition size limit of FAT12 and FAT16 will be the factor
|
---|
224 | * limiting the file size (except, perhaps for the 64KB cluster case on
|
---|
225 | * non-Windows hosts). */
|
---|
226 | RTFSTYPE_FAT,
|
---|
227 |
|
---|
228 | /* Solaris: */
|
---|
229 | /** Zettabyte File System. */
|
---|
230 | RTFSTYPE_ZFS,
|
---|
231 | /** Unix File System. */
|
---|
232 | RTFSTYPE_UFS,
|
---|
233 | /** Network File System. */
|
---|
234 | RTFSTYPE_NFS,
|
---|
235 |
|
---|
236 | /* Mac OS X: */
|
---|
237 | /** Hierarchical File System. */
|
---|
238 | RTFSTYPE_HFS,
|
---|
239 | /** @todo RTFSTYPE_HFS_PLUS? */
|
---|
240 | RTFSTYPE_AUTOFS,
|
---|
241 | RTFSTYPE_DEVFS,
|
---|
242 |
|
---|
243 | /* *BSD: */
|
---|
244 |
|
---|
245 | /* OS/2: */
|
---|
246 | /** High Performance File System. */
|
---|
247 | RTFSTYPE_HPFS,
|
---|
248 | /** Journaled File System (v2). */
|
---|
249 | RTFSTYPE_JFS,
|
---|
250 |
|
---|
251 | /** The end of valid Filesystem types IDs. */
|
---|
252 | RTFSTYPE_END,
|
---|
253 | /** The usual 32-bit type blow up. */
|
---|
254 | RTFSTYPE_32BIT_HACK = 0x7fffffff
|
---|
255 | } RTFSTYPE;
|
---|
256 | /** Pointer to a Filesystem type ID. */
|
---|
257 | typedef RTFSTYPE *PRTFSTYPE;
|
---|
258 |
|
---|
259 |
|
---|
260 | /**
|
---|
261 | * The available additional information in a RTFSOBJATTR object.
|
---|
262 | */
|
---|
263 | typedef enum RTFSOBJATTRADD
|
---|
264 | {
|
---|
265 | /** No additional information is available / requested. */
|
---|
266 | RTFSOBJATTRADD_NOTHING = 1,
|
---|
267 | /** The additional unix attributes (RTFSOBJATTR::u::Unix) are available /
|
---|
268 | * requested. */
|
---|
269 | RTFSOBJATTRADD_UNIX,
|
---|
270 | /** The additional unix attributes (RTFSOBJATTR::u::UnixOwner) are
|
---|
271 | * available / requested. */
|
---|
272 | RTFSOBJATTRADD_UNIX_OWNER,
|
---|
273 | /** The additional unix attributes (RTFSOBJATTR::u::UnixGroup) are
|
---|
274 | * available / requested. */
|
---|
275 | RTFSOBJATTRADD_UNIX_GROUP,
|
---|
276 | /** The additional extended attribute size (RTFSOBJATTR::u::EASize) is available / requested. */
|
---|
277 | RTFSOBJATTRADD_EASIZE,
|
---|
278 | /** The last valid item (inclusive).
|
---|
279 | * The valid range is RTFSOBJATTRADD_NOTHING thru RTFSOBJATTRADD_LAST. */
|
---|
280 | RTFSOBJATTRADD_LAST = RTFSOBJATTRADD_EASIZE,
|
---|
281 |
|
---|
282 | /** The usual 32-bit hack. */
|
---|
283 | RTFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
|
---|
284 | } RTFSOBJATTRADD;
|
---|
285 |
|
---|
286 | /** The number of bytes reserved for the additional attribute union. */
|
---|
287 | #define RTFSOBJATTRUNION_MAX_SIZE 128
|
---|
288 |
|
---|
289 | /**
|
---|
290 | * Additional Unix Attributes (RTFSOBJATTRADD_UNIX).
|
---|
291 | */
|
---|
292 | typedef struct RTFSOBJATTRUNIX
|
---|
293 | {
|
---|
294 | /** The user owning the filesystem object (st_uid).
|
---|
295 | * This field is NIL_UID if not supported. */
|
---|
296 | RTUID uid;
|
---|
297 |
|
---|
298 | /** The group the filesystem object is assigned (st_gid).
|
---|
299 | * This field is NIL_GID if not supported. */
|
---|
300 | RTGID gid;
|
---|
301 |
|
---|
302 | /** Number of hard links to this filesystem object (st_nlink).
|
---|
303 | * This field is 1 if the filesystem doesn't support hardlinking or
|
---|
304 | * the information isn't available.
|
---|
305 | */
|
---|
306 | uint32_t cHardlinks;
|
---|
307 |
|
---|
308 | /** The device number of the device which this filesystem object resides on (st_dev).
|
---|
309 | * This field is 0 if this information is not available. */
|
---|
310 | RTDEV INodeIdDevice;
|
---|
311 |
|
---|
312 | /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
|
---|
313 | * Together with INodeIdDevice, this field can be used as a OS wide unique id
|
---|
314 | * when both their values are not 0.
|
---|
315 | * This field is 0 if the information is not available. */
|
---|
316 | RTINODE INodeId;
|
---|
317 |
|
---|
318 | /** User flags (st_flags).
|
---|
319 | * This field is 0 if this information is not available. */
|
---|
320 | uint32_t fFlags;
|
---|
321 |
|
---|
322 | /** The current generation number (st_gen).
|
---|
323 | * This field is 0 if this information is not available. */
|
---|
324 | uint32_t GenerationId;
|
---|
325 |
|
---|
326 | /** The device number of a character or block device type object (st_rdev).
|
---|
327 | * This field is 0 if the file isn't of a character or block device type and
|
---|
328 | * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
|
---|
329 | RTDEV Device;
|
---|
330 | } RTFSOBJATTRUNIX;
|
---|
331 |
|
---|
332 |
|
---|
333 | /**
|
---|
334 | * Additional Unix Attributes (RTFSOBJATTRADD_UNIX_OWNER).
|
---|
335 | *
|
---|
336 | * @remarks This interface is mainly for TAR.
|
---|
337 | */
|
---|
338 | typedef struct RTFSOBJATTRUNIXOWNER
|
---|
339 | {
|
---|
340 | /** The user owning the filesystem object (st_uid).
|
---|
341 | * This field is NIL_UID if not supported. */
|
---|
342 | RTUID uid;
|
---|
343 | /** The user name.
|
---|
344 | * Empty if not available or not supported, truncated if too long. */
|
---|
345 | char szName[RTFSOBJATTRUNION_MAX_SIZE - sizeof(RTUID)];
|
---|
346 | } RTFSOBJATTRUNIXOWNER;
|
---|
347 |
|
---|
348 |
|
---|
349 | /**
|
---|
350 | * Additional Unix Attributes (RTFSOBJATTRADD_UNIX_GROUP).
|
---|
351 | *
|
---|
352 | * @remarks This interface is mainly for TAR.
|
---|
353 | */
|
---|
354 | typedef struct RTFSOBJATTRUNIXGROUP
|
---|
355 | {
|
---|
356 | /** The user owning the filesystem object (st_uid).
|
---|
357 | * This field is NIL_GID if not supported. */
|
---|
358 | RTGID gid;
|
---|
359 | /** The group name.
|
---|
360 | * Empty if not available or not supported, truncated if too long. */
|
---|
361 | char szName[RTFSOBJATTRUNION_MAX_SIZE - sizeof(RTGID)];
|
---|
362 | } RTFSOBJATTRUNIXGROUP;
|
---|
363 |
|
---|
364 |
|
---|
365 | /**
|
---|
366 | * Filesystem object attributes.
|
---|
367 | */
|
---|
368 | typedef struct RTFSOBJATTR
|
---|
369 | {
|
---|
370 | /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*. */
|
---|
371 | RTFMODE fMode;
|
---|
372 |
|
---|
373 | /** The additional attributes available. */
|
---|
374 | RTFSOBJATTRADD enmAdditional;
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Additional attributes.
|
---|
378 | *
|
---|
379 | * Unless explicitly specified to an API, the API can provide additional
|
---|
380 | * data as it is provided by the underlying OS.
|
---|
381 | */
|
---|
382 | union RTFSOBJATTRUNION
|
---|
383 | {
|
---|
384 | /** Additional Unix Attributes - RTFSOBJATTRADD_UNIX. */
|
---|
385 | RTFSOBJATTRUNIX Unix;
|
---|
386 | /** Additional Unix Owner Attributes - RTFSOBJATTRADD_UNIX_OWNER. */
|
---|
387 | RTFSOBJATTRUNIXOWNER UnixOwner;
|
---|
388 | /** Additional Unix Group Attributes - RTFSOBJATTRADD_UNIX_GROUP. */
|
---|
389 | RTFSOBJATTRUNIXGROUP UnixGroup;
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Extended attribute size is available when RTFS_DOS_HAVE_EA_SIZE is set.
|
---|
393 | */
|
---|
394 | struct RTFSOBJATTREASIZE
|
---|
395 | {
|
---|
396 | /** Size of EAs. */
|
---|
397 | RTFOFF cb;
|
---|
398 | } EASize;
|
---|
399 | /** Reserved space. */
|
---|
400 | uint8_t abReserveSpace[128];
|
---|
401 | } u;
|
---|
402 | } RTFSOBJATTR;
|
---|
403 | /** Pointer to a filesystem object attributes structure. */
|
---|
404 | typedef RTFSOBJATTR *PRTFSOBJATTR;
|
---|
405 | /** Pointer to a const filesystem object attributes structure. */
|
---|
406 | typedef const RTFSOBJATTR *PCRTFSOBJATTR;
|
---|
407 |
|
---|
408 |
|
---|
409 | /**
|
---|
410 | * Filesystem object information structure.
|
---|
411 | *
|
---|
412 | * This is returned by the RTPathQueryInfo(), RTFileQueryInfo() and RTDirRead() APIs.
|
---|
413 | */
|
---|
414 | typedef struct RTFSOBJINFO
|
---|
415 | {
|
---|
416 | /** Logical size (st_size).
|
---|
417 | * For normal files this is the size of the file.
|
---|
418 | * For symbolic links, this is the length of the path name contained
|
---|
419 | * in the symbolic link.
|
---|
420 | * For other objects this fields needs to be specified.
|
---|
421 | */
|
---|
422 | RTFOFF cbObject;
|
---|
423 |
|
---|
424 | /** Disk allocation size (st_blocks * DEV_BSIZE). */
|
---|
425 | RTFOFF cbAllocated;
|
---|
426 |
|
---|
427 | /** Time of last access (st_atime). */
|
---|
428 | RTTIMESPEC AccessTime;
|
---|
429 |
|
---|
430 | /** Time of last data modification (st_mtime). */
|
---|
431 | RTTIMESPEC ModificationTime;
|
---|
432 |
|
---|
433 | /** Time of last status change (st_ctime).
|
---|
434 | * If not available this is set to ModificationTime.
|
---|
435 | */
|
---|
436 | RTTIMESPEC ChangeTime;
|
---|
437 |
|
---|
438 | /** Time of file birth (st_birthtime).
|
---|
439 | * If not available this is set to ChangeTime.
|
---|
440 | */
|
---|
441 | RTTIMESPEC BirthTime;
|
---|
442 |
|
---|
443 | /** Attributes. */
|
---|
444 | RTFSOBJATTR Attr;
|
---|
445 |
|
---|
446 | } RTFSOBJINFO;
|
---|
447 | /** Pointer to a filesystem object information structure. */
|
---|
448 | typedef RTFSOBJINFO *PRTFSOBJINFO;
|
---|
449 | /** Pointer to a const filesystem object information structure. */
|
---|
450 | typedef const RTFSOBJINFO *PCRTFSOBJINFO;
|
---|
451 |
|
---|
452 |
|
---|
453 | #ifdef IN_RING3
|
---|
454 |
|
---|
455 | /**
|
---|
456 | * Query the sizes of a filesystem.
|
---|
457 | *
|
---|
458 | * @returns iprt status code.
|
---|
459 | * @param pszFsPath Path within the mounted filesystem.
|
---|
460 | * @param pcbTotal Where to store the total filesystem space. (Optional)
|
---|
461 | * @param pcbFree Where to store the remaining free space in the filesystem. (Optional)
|
---|
462 | * @param pcbBlock Where to store the block size. (Optional)
|
---|
463 | * @param pcbSector Where to store the sector size. (Optional)
|
---|
464 | *
|
---|
465 | * @sa RTFileQueryFsSizes
|
---|
466 | */
|
---|
467 | RTR3DECL(int) RTFsQuerySizes(const char *pszFsPath, PRTFOFF pcbTotal, RTFOFF *pcbFree,
|
---|
468 | uint32_t *pcbBlock, uint32_t *pcbSector);
|
---|
469 |
|
---|
470 | /**
|
---|
471 | * Query the mountpoint of a filesystem.
|
---|
472 | *
|
---|
473 | * @returns iprt status code.
|
---|
474 | * @returns VERR_BUFFER_OVERFLOW if cbMountpoint isn't enough.
|
---|
475 | * @param pszFsPath Path within the mounted filesystem.
|
---|
476 | * @param pszMountpoint Where to store the mountpoint path.
|
---|
477 | * @param cbMountpoint Size of the buffer pointed to by pszMountpoint.
|
---|
478 | */
|
---|
479 | RTR3DECL(int) RTFsQueryMountpoint(const char *pszFsPath, char *pszMountpoint, size_t cbMountpoint);
|
---|
480 |
|
---|
481 | /**
|
---|
482 | * Query the label of a filesystem.
|
---|
483 | *
|
---|
484 | * @returns iprt status code.
|
---|
485 | * @returns VERR_BUFFER_OVERFLOW if cbLabel isn't enough.
|
---|
486 | * @param pszFsPath Path within the mounted filesystem.
|
---|
487 | * @param pszLabel Where to store the label.
|
---|
488 | * @param cbLabel Size of the buffer pointed to by pszLabel.
|
---|
489 | */
|
---|
490 | RTR3DECL(int) RTFsQueryLabel(const char *pszFsPath, char *pszLabel, size_t cbLabel);
|
---|
491 |
|
---|
492 | /**
|
---|
493 | * Query the serial number of a filesystem.
|
---|
494 | *
|
---|
495 | * @returns iprt status code.
|
---|
496 | * @param pszFsPath Path within the mounted filesystem.
|
---|
497 | * @param pu32Serial Where to store the serial number.
|
---|
498 | */
|
---|
499 | RTR3DECL(int) RTFsQuerySerial(const char *pszFsPath, uint32_t *pu32Serial);
|
---|
500 |
|
---|
501 | /**
|
---|
502 | * Query the name of the filesystem driver.
|
---|
503 | *
|
---|
504 | * @returns iprt status code.
|
---|
505 | * @returns VERR_BUFFER_OVERFLOW if cbFsDriver isn't enough.
|
---|
506 | * @param pszFsPath Path within the mounted filesystem.
|
---|
507 | * @param pszFsDriver Where to store the filesystem driver name.
|
---|
508 | * @param cbFsDriver Size of the buffer pointed to by pszFsDriver.
|
---|
509 | */
|
---|
510 | RTR3DECL(int) RTFsQueryDriver(const char *pszFsPath, char *pszFsDriver, size_t cbFsDriver);
|
---|
511 |
|
---|
512 | /**
|
---|
513 | * Query the name of the filesystem the file is located on.
|
---|
514 | *
|
---|
515 | * @returns iprt status code.
|
---|
516 | * @param pszFsPath Path within the mounted filesystem. It must exist.
|
---|
517 | * In case this is a symlink, the file it refers to is
|
---|
518 | * evaluated.
|
---|
519 | * @param penmType Where to store the filesystem type, this is always
|
---|
520 | * set. See RTFSTYPE for the values.
|
---|
521 | */
|
---|
522 | RTR3DECL(int) RTFsQueryType(const char *pszFsPath, PRTFSTYPE penmType);
|
---|
523 |
|
---|
524 | #endif /* IN_RING3 */
|
---|
525 |
|
---|
526 | /**
|
---|
527 | * Gets the name of a filesystem type.
|
---|
528 | *
|
---|
529 | * @returns Pointer to a read-only string containing the name.
|
---|
530 | * @param enmType A valid filesystem ID. If outside the valid range,
|
---|
531 | * the returned string will be pointing to a static
|
---|
532 | * memory buffer which will be changed on subsequent
|
---|
533 | * calls to this function by any thread.
|
---|
534 | */
|
---|
535 | RTDECL(const char *) RTFsTypeName(RTFSTYPE enmType);
|
---|
536 |
|
---|
537 | /**
|
---|
538 | * Filesystem properties.
|
---|
539 | */
|
---|
540 | typedef struct RTFSPROPERTIES
|
---|
541 | {
|
---|
542 | /** The maximum size of a filesystem object name.
|
---|
543 | * This does not include the '\\0'. */
|
---|
544 | uint32_t cbMaxComponent;
|
---|
545 |
|
---|
546 | /** True if the filesystem is remote.
|
---|
547 | * False if the filesystem is local. */
|
---|
548 | bool fRemote;
|
---|
549 |
|
---|
550 | /** True if the filesystem is case sensitive.
|
---|
551 | * False if the filesystem is case insensitive. */
|
---|
552 | bool fCaseSensitive;
|
---|
553 |
|
---|
554 | /** True if the filesystem is mounted read only.
|
---|
555 | * False if the filesystem is mounted read write. */
|
---|
556 | bool fReadOnly;
|
---|
557 |
|
---|
558 | /** True if the filesystem can encode unicode object names.
|
---|
559 | * False if it can't. */
|
---|
560 | bool fSupportsUnicode;
|
---|
561 |
|
---|
562 | /** True if the filesystem is compresses.
|
---|
563 | * False if it isn't or we don't know. */
|
---|
564 | bool fCompressed;
|
---|
565 |
|
---|
566 | /** True if the filesystem compresses of individual files.
|
---|
567 | * False if it doesn't or we don't know. */
|
---|
568 | bool fFileCompression;
|
---|
569 |
|
---|
570 | /** @todo more? */
|
---|
571 | } RTFSPROPERTIES;
|
---|
572 | /** Pointer to a filesystem properties structure. */
|
---|
573 | typedef RTFSPROPERTIES *PRTFSPROPERTIES;
|
---|
574 | /** Pointer to a const filesystem properties structure. */
|
---|
575 | typedef RTFSPROPERTIES const *PCRTFSPROPERTIES;
|
---|
576 |
|
---|
577 | #ifdef IN_RING3
|
---|
578 |
|
---|
579 | /**
|
---|
580 | * Query the properties of a mounted filesystem.
|
---|
581 | *
|
---|
582 | * @returns iprt status code.
|
---|
583 | * @param pszFsPath Path within the mounted filesystem.
|
---|
584 | * @param pProperties Where to store the properties.
|
---|
585 | */
|
---|
586 | RTR3DECL(int) RTFsQueryProperties(const char *pszFsPath, PRTFSPROPERTIES pProperties);
|
---|
587 |
|
---|
588 |
|
---|
589 | /**
|
---|
590 | * Mountpoint enumerator callback.
|
---|
591 | *
|
---|
592 | * @returns iprt status code. Failure terminates the enumeration.
|
---|
593 | * @param pszMountpoint The mountpoint name.
|
---|
594 | * @param pvUser The user argument.
|
---|
595 | */
|
---|
596 | typedef DECLCALLBACK(int) FNRTFSMOUNTPOINTENUM(const char *pszMountpoint, void *pvUser);
|
---|
597 | /** Pointer to a FNRTFSMOUNTPOINTENUM(). */
|
---|
598 | typedef FNRTFSMOUNTPOINTENUM *PFNRTFSMOUNTPOINTENUM;
|
---|
599 |
|
---|
600 | /**
|
---|
601 | * Enumerate mount points.
|
---|
602 | *
|
---|
603 | * @returns iprt status code.
|
---|
604 | * @param pfnCallback The callback function.
|
---|
605 | * @param pvUser The user argument to the callback.
|
---|
606 | */
|
---|
607 | RTR3DECL(int) RTFsMountpointsEnum(PFNRTFSMOUNTPOINTENUM pfnCallback, void *pvUser);
|
---|
608 |
|
---|
609 |
|
---|
610 | #endif /* IN_RING3 */
|
---|
611 |
|
---|
612 | /** @} */
|
---|
613 |
|
---|
614 | RT_C_DECLS_END
|
---|
615 |
|
---|
616 | #endif /* !___iprt_fs_h */
|
---|
617 |
|
---|