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