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