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 | RTFSTYPE_OCFS2,
|
---|
219 |
|
---|
220 | /* Windows: */
|
---|
221 | /** New Technology File System. */
|
---|
222 | RTFSTYPE_NTFS,
|
---|
223 | /** FAT12, FAT16 and FAT32 lumped into one basket.
|
---|
224 | * The partition size limit of FAT12 and FAT16 will be the factor
|
---|
225 | * limiting the file size (except, perhaps for the 64KB cluster case on
|
---|
226 | * non-Windows hosts). */
|
---|
227 | RTFSTYPE_FAT,
|
---|
228 |
|
---|
229 | /* Solaris: */
|
---|
230 | /** Zettabyte File System. */
|
---|
231 | RTFSTYPE_ZFS,
|
---|
232 | /** Unix File System. */
|
---|
233 | RTFSTYPE_UFS,
|
---|
234 | /** Network File System. */
|
---|
235 | RTFSTYPE_NFS,
|
---|
236 |
|
---|
237 | /* Mac OS X: */
|
---|
238 | /** Hierarchical File System. */
|
---|
239 | RTFSTYPE_HFS,
|
---|
240 | /** @todo RTFSTYPE_HFS_PLUS? */
|
---|
241 | RTFSTYPE_AUTOFS,
|
---|
242 | RTFSTYPE_DEVFS,
|
---|
243 |
|
---|
244 | /* *BSD: */
|
---|
245 |
|
---|
246 | /* OS/2: */
|
---|
247 | /** High Performance File System. */
|
---|
248 | RTFSTYPE_HPFS,
|
---|
249 | /** Journaled File System (v2). */
|
---|
250 | RTFSTYPE_JFS,
|
---|
251 |
|
---|
252 | /** The end of valid Filesystem types IDs. */
|
---|
253 | RTFSTYPE_END,
|
---|
254 | /** The usual 32-bit type blow up. */
|
---|
255 | RTFSTYPE_32BIT_HACK = 0x7fffffff
|
---|
256 | } RTFSTYPE;
|
---|
257 | /** Pointer to a Filesystem type ID. */
|
---|
258 | typedef RTFSTYPE *PRTFSTYPE;
|
---|
259 |
|
---|
260 |
|
---|
261 | /**
|
---|
262 | * The available additional information in a RTFSOBJATTR object.
|
---|
263 | */
|
---|
264 | typedef enum RTFSOBJATTRADD
|
---|
265 | {
|
---|
266 | /** No additional information is available / requested. */
|
---|
267 | RTFSOBJATTRADD_NOTHING = 1,
|
---|
268 | /** The additional unix attributes (RTFSOBJATTR::u::Unix) are available /
|
---|
269 | * requested. */
|
---|
270 | RTFSOBJATTRADD_UNIX,
|
---|
271 | /** The additional unix attributes (RTFSOBJATTR::u::UnixOwner) are
|
---|
272 | * available / requested. */
|
---|
273 | RTFSOBJATTRADD_UNIX_OWNER,
|
---|
274 | /** The additional unix attributes (RTFSOBJATTR::u::UnixGroup) are
|
---|
275 | * available / requested. */
|
---|
276 | RTFSOBJATTRADD_UNIX_GROUP,
|
---|
277 | /** The additional extended attribute size (RTFSOBJATTR::u::EASize) is available / requested. */
|
---|
278 | RTFSOBJATTRADD_EASIZE,
|
---|
279 | /** The last valid item (inclusive).
|
---|
280 | * The valid range is RTFSOBJATTRADD_NOTHING thru RTFSOBJATTRADD_LAST. */
|
---|
281 | RTFSOBJATTRADD_LAST = RTFSOBJATTRADD_EASIZE,
|
---|
282 |
|
---|
283 | /** The usual 32-bit hack. */
|
---|
284 | RTFSOBJATTRADD_32BIT_SIZE_HACK = 0x7fffffff
|
---|
285 | } RTFSOBJATTRADD;
|
---|
286 |
|
---|
287 | /** The number of bytes reserved for the additional attribute union. */
|
---|
288 | #define RTFSOBJATTRUNION_MAX_SIZE 128
|
---|
289 |
|
---|
290 | /**
|
---|
291 | * Additional Unix Attributes (RTFSOBJATTRADD_UNIX).
|
---|
292 | */
|
---|
293 | typedef struct RTFSOBJATTRUNIX
|
---|
294 | {
|
---|
295 | /** The user owning the filesystem object (st_uid).
|
---|
296 | * This field is NIL_UID if not supported. */
|
---|
297 | RTUID uid;
|
---|
298 |
|
---|
299 | /** The group the filesystem object is assigned (st_gid).
|
---|
300 | * This field is NIL_GID if not supported. */
|
---|
301 | RTGID gid;
|
---|
302 |
|
---|
303 | /** Number of hard links to this filesystem object (st_nlink).
|
---|
304 | * This field is 1 if the filesystem doesn't support hardlinking or
|
---|
305 | * the information isn't available.
|
---|
306 | */
|
---|
307 | uint32_t cHardlinks;
|
---|
308 |
|
---|
309 | /** The device number of the device which this filesystem object resides on (st_dev).
|
---|
310 | * This field is 0 if this information is not available. */
|
---|
311 | RTDEV INodeIdDevice;
|
---|
312 |
|
---|
313 | /** The unique identifier (within the filesystem) of this filesystem object (st_ino).
|
---|
314 | * Together with INodeIdDevice, this field can be used as a OS wide unique id
|
---|
315 | * when both their values are not 0.
|
---|
316 | * This field is 0 if the information is not available. */
|
---|
317 | RTINODE INodeId;
|
---|
318 |
|
---|
319 | /** User flags (st_flags).
|
---|
320 | * This field is 0 if this information is not available. */
|
---|
321 | uint32_t fFlags;
|
---|
322 |
|
---|
323 | /** The current generation number (st_gen).
|
---|
324 | * This field is 0 if this information is not available. */
|
---|
325 | uint32_t GenerationId;
|
---|
326 |
|
---|
327 | /** The device number of a character or block device type object (st_rdev).
|
---|
328 | * This field is 0 if the file isn't of a character or block device type and
|
---|
329 | * when the OS doesn't subscribe to the major+minor device idenfication scheme. */
|
---|
330 | RTDEV Device;
|
---|
331 | } RTFSOBJATTRUNIX;
|
---|
332 |
|
---|
333 |
|
---|
334 | /**
|
---|
335 | * Additional Unix Attributes (RTFSOBJATTRADD_UNIX_OWNER).
|
---|
336 | *
|
---|
337 | * @remarks This interface is mainly for TAR.
|
---|
338 | */
|
---|
339 | typedef struct RTFSOBJATTRUNIXOWNER
|
---|
340 | {
|
---|
341 | /** The user owning the filesystem object (st_uid).
|
---|
342 | * This field is NIL_UID if not supported. */
|
---|
343 | RTUID uid;
|
---|
344 | /** The user name.
|
---|
345 | * Empty if not available or not supported, truncated if too long. */
|
---|
346 | char szName[RTFSOBJATTRUNION_MAX_SIZE - sizeof(RTUID)];
|
---|
347 | } RTFSOBJATTRUNIXOWNER;
|
---|
348 |
|
---|
349 |
|
---|
350 | /**
|
---|
351 | * Additional Unix Attributes (RTFSOBJATTRADD_UNIX_GROUP).
|
---|
352 | *
|
---|
353 | * @remarks This interface is mainly for TAR.
|
---|
354 | */
|
---|
355 | typedef struct RTFSOBJATTRUNIXGROUP
|
---|
356 | {
|
---|
357 | /** The user owning the filesystem object (st_uid).
|
---|
358 | * This field is NIL_GID if not supported. */
|
---|
359 | RTGID gid;
|
---|
360 | /** The group name.
|
---|
361 | * Empty if not available or not supported, truncated if too long. */
|
---|
362 | char szName[RTFSOBJATTRUNION_MAX_SIZE - sizeof(RTGID)];
|
---|
363 | } RTFSOBJATTRUNIXGROUP;
|
---|
364 |
|
---|
365 |
|
---|
366 | /**
|
---|
367 | * Filesystem object attributes.
|
---|
368 | */
|
---|
369 | typedef struct RTFSOBJATTR
|
---|
370 | {
|
---|
371 | /** Mode flags (st_mode). RTFS_UNIX_*, RTFS_TYPE_*, and RTFS_DOS_*. */
|
---|
372 | RTFMODE fMode;
|
---|
373 |
|
---|
374 | /** The additional attributes available. */
|
---|
375 | RTFSOBJATTRADD enmAdditional;
|
---|
376 |
|
---|
377 | /**
|
---|
378 | * Additional attributes.
|
---|
379 | *
|
---|
380 | * Unless explicitly specified to an API, the API can provide additional
|
---|
381 | * data as it is provided by the underlying OS.
|
---|
382 | */
|
---|
383 | union RTFSOBJATTRUNION
|
---|
384 | {
|
---|
385 | /** Additional Unix Attributes - RTFSOBJATTRADD_UNIX. */
|
---|
386 | RTFSOBJATTRUNIX Unix;
|
---|
387 | /** Additional Unix Owner Attributes - RTFSOBJATTRADD_UNIX_OWNER. */
|
---|
388 | RTFSOBJATTRUNIXOWNER UnixOwner;
|
---|
389 | /** Additional Unix Group Attributes - RTFSOBJATTRADD_UNIX_GROUP. */
|
---|
390 | RTFSOBJATTRUNIXGROUP UnixGroup;
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Extended attribute size is available when RTFS_DOS_HAVE_EA_SIZE is set.
|
---|
394 | */
|
---|
395 | struct RTFSOBJATTREASIZE
|
---|
396 | {
|
---|
397 | /** Size of EAs. */
|
---|
398 | RTFOFF cb;
|
---|
399 | } EASize;
|
---|
400 | /** Reserved space. */
|
---|
401 | uint8_t abReserveSpace[128];
|
---|
402 | } u;
|
---|
403 | } RTFSOBJATTR;
|
---|
404 | /** Pointer to a filesystem object attributes structure. */
|
---|
405 | typedef RTFSOBJATTR *PRTFSOBJATTR;
|
---|
406 | /** Pointer to a const filesystem object attributes structure. */
|
---|
407 | typedef const RTFSOBJATTR *PCRTFSOBJATTR;
|
---|
408 |
|
---|
409 |
|
---|
410 | /**
|
---|
411 | * Filesystem object information structure.
|
---|
412 | *
|
---|
413 | * This is returned by the RTPathQueryInfo(), RTFileQueryInfo() and RTDirRead() APIs.
|
---|
414 | */
|
---|
415 | typedef struct RTFSOBJINFO
|
---|
416 | {
|
---|
417 | /** Logical size (st_size).
|
---|
418 | * For normal files this is the size of the file.
|
---|
419 | * For symbolic links, this is the length of the path name contained
|
---|
420 | * in the symbolic link.
|
---|
421 | * For other objects this fields needs to be specified.
|
---|
422 | */
|
---|
423 | RTFOFF cbObject;
|
---|
424 |
|
---|
425 | /** Disk allocation size (st_blocks * DEV_BSIZE). */
|
---|
426 | RTFOFF cbAllocated;
|
---|
427 |
|
---|
428 | /** Time of last access (st_atime). */
|
---|
429 | RTTIMESPEC AccessTime;
|
---|
430 |
|
---|
431 | /** Time of last data modification (st_mtime). */
|
---|
432 | RTTIMESPEC ModificationTime;
|
---|
433 |
|
---|
434 | /** Time of last status change (st_ctime).
|
---|
435 | * If not available this is set to ModificationTime.
|
---|
436 | */
|
---|
437 | RTTIMESPEC ChangeTime;
|
---|
438 |
|
---|
439 | /** Time of file birth (st_birthtime).
|
---|
440 | * If not available this is set to ChangeTime.
|
---|
441 | */
|
---|
442 | RTTIMESPEC BirthTime;
|
---|
443 |
|
---|
444 | /** Attributes. */
|
---|
445 | RTFSOBJATTR Attr;
|
---|
446 |
|
---|
447 | } RTFSOBJINFO;
|
---|
448 | /** Pointer to a filesystem object information structure. */
|
---|
449 | typedef RTFSOBJINFO *PRTFSOBJINFO;
|
---|
450 | /** Pointer to a const filesystem object information structure. */
|
---|
451 | typedef const RTFSOBJINFO *PCRTFSOBJINFO;
|
---|
452 |
|
---|
453 |
|
---|
454 | #ifdef IN_RING3
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * Query the sizes of a filesystem.
|
---|
458 | *
|
---|
459 | * @returns iprt status code.
|
---|
460 | * @param pszFsPath Path within the mounted filesystem.
|
---|
461 | * @param pcbTotal Where to store the total filesystem space. (Optional)
|
---|
462 | * @param pcbFree Where to store the remaining free space in the filesystem. (Optional)
|
---|
463 | * @param pcbBlock Where to store the block size. (Optional)
|
---|
464 | * @param pcbSector Where to store the sector size. (Optional)
|
---|
465 | *
|
---|
466 | * @sa RTFileQueryFsSizes
|
---|
467 | */
|
---|
468 | RTR3DECL(int) RTFsQuerySizes(const char *pszFsPath, PRTFOFF pcbTotal, RTFOFF *pcbFree,
|
---|
469 | uint32_t *pcbBlock, uint32_t *pcbSector);
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Query the mountpoint of a filesystem.
|
---|
473 | *
|
---|
474 | * @returns iprt status code.
|
---|
475 | * @returns VERR_BUFFER_OVERFLOW if cbMountpoint isn't enough.
|
---|
476 | * @param pszFsPath Path within the mounted filesystem.
|
---|
477 | * @param pszMountpoint Where to store the mountpoint path.
|
---|
478 | * @param cbMountpoint Size of the buffer pointed to by pszMountpoint.
|
---|
479 | */
|
---|
480 | RTR3DECL(int) RTFsQueryMountpoint(const char *pszFsPath, char *pszMountpoint, size_t cbMountpoint);
|
---|
481 |
|
---|
482 | /**
|
---|
483 | * Query the label of a filesystem.
|
---|
484 | *
|
---|
485 | * @returns iprt status code.
|
---|
486 | * @returns VERR_BUFFER_OVERFLOW if cbLabel isn't enough.
|
---|
487 | * @param pszFsPath Path within the mounted filesystem.
|
---|
488 | * @param pszLabel Where to store the label.
|
---|
489 | * @param cbLabel Size of the buffer pointed to by pszLabel.
|
---|
490 | */
|
---|
491 | RTR3DECL(int) RTFsQueryLabel(const char *pszFsPath, char *pszLabel, size_t cbLabel);
|
---|
492 |
|
---|
493 | /**
|
---|
494 | * Query the serial number of a filesystem.
|
---|
495 | *
|
---|
496 | * @returns iprt status code.
|
---|
497 | * @param pszFsPath Path within the mounted filesystem.
|
---|
498 | * @param pu32Serial Where to store the serial number.
|
---|
499 | */
|
---|
500 | RTR3DECL(int) RTFsQuerySerial(const char *pszFsPath, uint32_t *pu32Serial);
|
---|
501 |
|
---|
502 | /**
|
---|
503 | * Query the name of the filesystem driver.
|
---|
504 | *
|
---|
505 | * @returns iprt status code.
|
---|
506 | * @returns VERR_BUFFER_OVERFLOW if cbFsDriver isn't enough.
|
---|
507 | * @param pszFsPath Path within the mounted filesystem.
|
---|
508 | * @param pszFsDriver Where to store the filesystem driver name.
|
---|
509 | * @param cbFsDriver Size of the buffer pointed to by pszFsDriver.
|
---|
510 | */
|
---|
511 | RTR3DECL(int) RTFsQueryDriver(const char *pszFsPath, char *pszFsDriver, size_t cbFsDriver);
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Query the name of the filesystem the file is located on.
|
---|
515 | *
|
---|
516 | * @returns iprt status code.
|
---|
517 | * @param pszFsPath Path within the mounted filesystem. It must exist.
|
---|
518 | * In case this is a symlink, the file it refers to is
|
---|
519 | * evaluated.
|
---|
520 | * @param penmType Where to store the filesystem type, this is always
|
---|
521 | * set. See RTFSTYPE for the values.
|
---|
522 | */
|
---|
523 | RTR3DECL(int) RTFsQueryType(const char *pszFsPath, PRTFSTYPE penmType);
|
---|
524 |
|
---|
525 | #endif /* IN_RING3 */
|
---|
526 |
|
---|
527 | /**
|
---|
528 | * Gets the name of a filesystem type.
|
---|
529 | *
|
---|
530 | * @returns Pointer to a read-only string containing the name.
|
---|
531 | * @param enmType A valid filesystem ID. If outside the valid range,
|
---|
532 | * the returned string will be pointing to a static
|
---|
533 | * memory buffer which will be changed on subsequent
|
---|
534 | * calls to this function by any thread.
|
---|
535 | */
|
---|
536 | RTDECL(const char *) RTFsTypeName(RTFSTYPE enmType);
|
---|
537 |
|
---|
538 | /**
|
---|
539 | * Filesystem properties.
|
---|
540 | */
|
---|
541 | typedef struct RTFSPROPERTIES
|
---|
542 | {
|
---|
543 | /** The maximum size of a filesystem object name.
|
---|
544 | * This does not include the '\\0'. */
|
---|
545 | uint32_t cbMaxComponent;
|
---|
546 |
|
---|
547 | /** True if the filesystem is remote.
|
---|
548 | * False if the filesystem is local. */
|
---|
549 | bool fRemote;
|
---|
550 |
|
---|
551 | /** True if the filesystem is case sensitive.
|
---|
552 | * False if the filesystem is case insensitive. */
|
---|
553 | bool fCaseSensitive;
|
---|
554 |
|
---|
555 | /** True if the filesystem is mounted read only.
|
---|
556 | * False if the filesystem is mounted read write. */
|
---|
557 | bool fReadOnly;
|
---|
558 |
|
---|
559 | /** True if the filesystem can encode unicode object names.
|
---|
560 | * False if it can't. */
|
---|
561 | bool fSupportsUnicode;
|
---|
562 |
|
---|
563 | /** True if the filesystem is compresses.
|
---|
564 | * False if it isn't or we don't know. */
|
---|
565 | bool fCompressed;
|
---|
566 |
|
---|
567 | /** True if the filesystem compresses of individual files.
|
---|
568 | * False if it doesn't or we don't know. */
|
---|
569 | bool fFileCompression;
|
---|
570 |
|
---|
571 | /** @todo more? */
|
---|
572 | } RTFSPROPERTIES;
|
---|
573 | /** Pointer to a filesystem properties structure. */
|
---|
574 | typedef RTFSPROPERTIES *PRTFSPROPERTIES;
|
---|
575 | /** Pointer to a const filesystem properties structure. */
|
---|
576 | typedef RTFSPROPERTIES const *PCRTFSPROPERTIES;
|
---|
577 |
|
---|
578 | #ifdef IN_RING3
|
---|
579 |
|
---|
580 | /**
|
---|
581 | * Query the properties of a mounted filesystem.
|
---|
582 | *
|
---|
583 | * @returns iprt status code.
|
---|
584 | * @param pszFsPath Path within the mounted filesystem.
|
---|
585 | * @param pProperties Where to store the properties.
|
---|
586 | */
|
---|
587 | RTR3DECL(int) RTFsQueryProperties(const char *pszFsPath, PRTFSPROPERTIES pProperties);
|
---|
588 |
|
---|
589 |
|
---|
590 | /**
|
---|
591 | * Mountpoint enumerator callback.
|
---|
592 | *
|
---|
593 | * @returns iprt status code. Failure terminates the enumeration.
|
---|
594 | * @param pszMountpoint The mountpoint name.
|
---|
595 | * @param pvUser The user argument.
|
---|
596 | */
|
---|
597 | typedef DECLCALLBACK(int) FNRTFSMOUNTPOINTENUM(const char *pszMountpoint, void *pvUser);
|
---|
598 | /** Pointer to a FNRTFSMOUNTPOINTENUM(). */
|
---|
599 | typedef FNRTFSMOUNTPOINTENUM *PFNRTFSMOUNTPOINTENUM;
|
---|
600 |
|
---|
601 | /**
|
---|
602 | * Enumerate mount points.
|
---|
603 | *
|
---|
604 | * @returns iprt status code.
|
---|
605 | * @param pfnCallback The callback function.
|
---|
606 | * @param pvUser The user argument to the callback.
|
---|
607 | */
|
---|
608 | RTR3DECL(int) RTFsMountpointsEnum(PFNRTFSMOUNTPOINTENUM pfnCallback, void *pvUser);
|
---|
609 |
|
---|
610 |
|
---|
611 | #endif /* IN_RING3 */
|
---|
612 |
|
---|
613 | /** @} */
|
---|
614 |
|
---|
615 | RT_C_DECLS_END
|
---|
616 |
|
---|
617 | #endif /* !___iprt_fs_h */
|
---|
618 |
|
---|