strate_fs_abstraction/
capabilities.rs1#[derive(Debug, Clone)]
14pub struct FsCapabilities {
15 pub read_only: bool,
18
19 pub case_sensitive: bool,
22
23 pub case_preserving: bool,
25
26 pub max_filename_len: usize,
28
29 pub max_path_len: usize,
31
32 pub supports_symlinks: bool,
35
36 pub supports_hardlinks: bool,
38
39 pub supports_sparse_files: bool,
42
43 pub max_file_size: u64,
45
46 pub supports_xattr: bool,
49
50 pub supports_acl: bool,
52
53 pub supports_nanoseconds: bool,
56
57 pub supports_crtime: bool,
59}
60
61impl FsCapabilities {
62 pub const fn read_only_linux() -> Self {
64 Self {
65 read_only: true,
66 case_sensitive: true,
67 case_preserving: true,
68 max_filename_len: 255,
69 max_path_len: 4096,
70 supports_symlinks: true,
71 supports_hardlinks: true,
72 supports_sparse_files: true,
73 max_file_size: i64::MAX as u64,
74 supports_xattr: false,
75 supports_acl: false,
76 supports_nanoseconds: true,
77 supports_crtime: false,
78 }
79 }
80
81 pub const fn writable_linux() -> Self {
83 Self {
84 read_only: false,
85 ..Self::read_only_linux()
86 }
87 }
88
89 pub const fn xfs() -> Self {
91 Self {
92 read_only: false,
93 case_sensitive: true,
94 case_preserving: true,
95 max_filename_len: 255,
96 max_path_len: 4096,
97 supports_symlinks: true,
98 supports_hardlinks: true,
99 supports_sparse_files: true,
100 max_file_size: 8 * 1024 * 1024 * 1024 * 1024 * 1024, supports_xattr: true,
102 supports_acl: true,
103 supports_nanoseconds: true,
104 supports_crtime: true, }
106 }
107
108 pub const fn ext4() -> Self {
110 Self {
111 read_only: false,
112 case_sensitive: true,
113 case_preserving: true,
114 max_filename_len: 255,
115 max_path_len: 4096,
116 supports_symlinks: true,
117 supports_hardlinks: true,
118 supports_sparse_files: true,
119 max_file_size: 16 * 1024 * 1024 * 1024 * 1024, supports_xattr: true,
121 supports_acl: true,
122 supports_nanoseconds: true,
123 supports_crtime: true,
124 }
125 }
126
127 pub const fn btrfs() -> Self {
129 Self {
130 read_only: false,
131 case_sensitive: true,
132 case_preserving: true,
133 max_filename_len: 255,
134 max_path_len: 4096,
135 supports_symlinks: true,
136 supports_hardlinks: true,
137 supports_sparse_files: true,
138 max_file_size: 16 * 1024 * 1024 * 1024 * 1024 * 1024, supports_xattr: true,
140 supports_acl: true,
141 supports_nanoseconds: true,
142 supports_crtime: true,
143 }
144 }
145
146 pub const fn can_write(&self) -> bool {
148 !self.read_only
149 }
150}
151
152impl Default for FsCapabilities {
153 fn default() -> Self {
155 Self::read_only_linux()
156 }
157}