1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use bitflags::bitflags;

// TODO: fill in more docstrings.

bitflags! {
    /// File system features that affect whether the data can be read.
    ///
    /// For each of these features, the library must know how to handle
    /// its presence or absence in order to safely read the file system,
    /// even in read-only mode.
    #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
    pub struct IncompatibleFeatures: u32 {
        const COMPRESSION = 0x1;

        /// Directory entries store the file type.
        const FILE_TYPE_IN_DIR_ENTRY = 0x2;

        /// Filesystem needs recovery.
        const RECOVERY = 0x4;

        /// Filesystem has a separate journal device.
        const SEPARATE_JOURNAL_DEVICE = 0x8;

        const META_BLOCK_GROUPS = 0x10;
        const EXTENTS = 0x40;
        const IS_64BIT = 0x80;
        const MULTIPLE_MOUNT_PROTECTION = 0x100;
        const FLEXIBLE_BLOCK_GROUPS = 0x200;
        const LARGE_EXTENDED_ATTRIBUTES_IN_INODES = 0x400;
        const DATA_IN_DIR_ENTRY = 0x1000;

        /// The superblock contains the checksum seed. If not present,
        /// the checksum seed is calculated from the filesystem UUID
        const CHECKSUM_SEED_IN_SUPERBLOCK = 0x2000;

        const LARGE_DIRECTORIES = 0x4000;
        const DATA_IN_INODE = 0x8000;
        const ENCRYPTED_INODES = 0x1_0000;
    }

    /// File system features that do not prevent read-only access to the data.
    ///
    /// The presence or absence of these features does not prevent
    /// loading the file system in read-only mode, even if the library
    /// does not know how to handle some features.
    #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
    pub struct ReadOnlyCompatibleFeatures: u32 {
        const SPARSE_SUPERBLOCKS = 0x1;
        const LARGE_FILES = 0x2;
        const BTREE_DIR = 0x4;
        const HUGE_FILES = 0x8;
        const GROUP_DESCRIPTOR_CHECKSUMS = 0x10;
        const LARGE_DIRECTORIES = 0x20;
        const LARGE_INODES = 0x40;
        const HAS_SNAPSHOT = 0x80;
        const QUOTA = 0x100;
        const BIG_ALLOC = 0x200;
        const METADATA_CHECKSUMS = 0x400;
        const REPLICA = 0x800;
        const READ_ONLY = 0x1000;
        const PROJECT_QUOTAS = 0x2000;
        const VERITY = 0x8000;
        const ORPHAN_PRESENT = 0x1_0000;
    }
}