ext4_view/
features.rs

1// Copyright 2024 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9// TODO: fill in more docstrings.
10#![allow(missing_docs)]
11
12use bitflags::bitflags;
13
14bitflags! {
15    /// File system features that affect whether the data can be read.
16    ///
17    /// For each of these features, the library must know how to handle
18    /// its presence or absence in order to safely read the file system,
19    /// even in read-only mode.
20    #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
21    pub struct IncompatibleFeatures: u32 {
22        const COMPRESSION = 0x1;
23
24        /// Directory entries store the file type.
25        const FILE_TYPE_IN_DIR_ENTRY = 0x2;
26
27        /// Filesystem needs recovery.
28        const RECOVERY = 0x4;
29
30        /// Filesystem has a separate journal device.
31        const SEPARATE_JOURNAL_DEVICE = 0x8;
32
33        const META_BLOCK_GROUPS = 0x10;
34        const EXTENTS = 0x40;
35        const IS_64BIT = 0x80;
36        const MULTIPLE_MOUNT_PROTECTION = 0x100;
37        const FLEXIBLE_BLOCK_GROUPS = 0x200;
38        const LARGE_EXTENDED_ATTRIBUTES_IN_INODES = 0x400;
39        const DATA_IN_DIR_ENTRY = 0x1000;
40
41        /// The superblock contains the checksum seed. If not present,
42        /// the checksum seed is calculated from the filesystem UUID
43        const CHECKSUM_SEED_IN_SUPERBLOCK = 0x2000;
44
45        const LARGE_DIRECTORIES = 0x4000;
46        const DATA_IN_INODE = 0x8000;
47        const ENCRYPTED_INODES = 0x1_0000;
48    }
49
50    /// File system features that do not prevent read-only access to the data.
51    ///
52    /// The presence or absence of these features does not prevent
53    /// loading the file system in read-only mode, even if the library
54    /// does not know how to handle some features.
55    #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
56    pub struct ReadOnlyCompatibleFeatures: u32 {
57        const SPARSE_SUPERBLOCKS = 0x1;
58        const LARGE_FILES = 0x2;
59        const BTREE_DIR = 0x4;
60        const HUGE_FILES = 0x8;
61        const GROUP_DESCRIPTOR_CHECKSUMS = 0x10;
62        const LARGE_DIRECTORIES = 0x20;
63        const LARGE_INODES = 0x40;
64        const HAS_SNAPSHOT = 0x80;
65        const QUOTA = 0x100;
66        const BIG_ALLOC = 0x200;
67        const METADATA_CHECKSUMS = 0x400;
68        const REPLICA = 0x800;
69        const READ_ONLY = 0x1000;
70        const PROJECT_QUOTAS = 0x2000;
71        const VERITY = 0x8000;
72        const ORPHAN_PRESENT = 0x1_0000;
73    }
74}
75
76bitflags! {
77    /// Optional file system features.
78    #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
79    pub struct CompatibleFeatures: u32 {
80        const HAS_JOURNAL = 0x4;
81    }
82}