kobako 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/CHANGELOG.md +335 -0
  4. data/Cargo.lock +469 -11
  5. data/README.md +43 -3
  6. data/ROADMAP.md +1 -1
  7. data/crates/kobako-runtime/CHANGELOG.md +219 -0
  8. data/crates/kobako-runtime/Cargo.toml +51 -3
  9. data/crates/kobako-runtime/README.md +7 -4
  10. data/crates/kobako-runtime/src/cred.rs +124 -0
  11. data/crates/kobako-runtime/src/dispatch.rs +4 -5
  12. data/crates/kobako-runtime/src/endpoint/buffer.rs +153 -44
  13. data/crates/kobako-runtime/src/endpoint/dispatch.rs +80 -41
  14. data/crates/kobako-runtime/src/endpoint/invoke.rs +23 -36
  15. data/crates/kobako-runtime/src/endpoint.rs +137 -36
  16. data/crates/kobako-runtime/src/errno.rs +391 -0
  17. data/crates/kobako-runtime/src/error.rs +31 -10
  18. data/crates/kobako-runtime/src/filesystem/anon_inodes.rs +52 -0
  19. data/crates/kobako-runtime/src/filesystem/bind/lookup.rs +52 -14
  20. data/crates/kobako-runtime/src/filesystem/bind/walk.rs +19 -20
  21. data/crates/kobako-runtime/src/filesystem/bind.rs +437 -245
  22. data/crates/kobako-runtime/src/filesystem/overlay/file.rs +6 -6
  23. data/crates/kobako-runtime/src/filesystem/overlay/path.rs +43 -65
  24. data/crates/kobako-runtime/src/filesystem/overlay/stack/copy_up.rs +9 -16
  25. data/crates/kobako-runtime/src/filesystem/overlay/stack/dir.rs +47 -72
  26. data/crates/kobako-runtime/src/filesystem/overlay/stack/namei.rs +12 -12
  27. data/crates/kobako-runtime/src/filesystem/overlay/stack/readdir.rs +4 -7
  28. data/crates/kobako-runtime/src/filesystem/overlay/stack.rs +121 -37
  29. data/crates/kobako-runtime/src/filesystem/overlay.rs +302 -343
  30. data/crates/kobako-runtime/src/filesystem/pipe.rs +12 -9
  31. data/crates/kobako-runtime/src/filesystem/rdir.rs +15 -32
  32. data/crates/kobako-runtime/src/filesystem/tmpfs/seed.rs +32 -0
  33. data/crates/kobako-runtime/src/filesystem/tmpfs/tmpfile.rs +3 -3
  34. data/crates/kobako-runtime/src/filesystem/tmpfs/whiteout.rs +57 -35
  35. data/crates/kobako-runtime/src/filesystem/tmpfs/xattr.rs +2 -2
  36. data/crates/kobako-runtime/src/filesystem/tmpfs.rs +172 -160
  37. data/crates/kobako-runtime/src/filesystem/wrap.rs +36 -52
  38. data/crates/kobako-runtime/src/filesystem.rs +6 -3
  39. data/crates/kobako-runtime/src/fork.rs +96 -0
  40. data/crates/kobako-runtime/src/grant.rs +3 -0
  41. data/crates/kobako-runtime/src/hashtable.rs +4 -2
  42. data/crates/kobako-runtime/src/lib.rs +18 -7
  43. data/crates/kobako-runtime/src/limits.rs +195 -0
  44. data/crates/kobako-runtime/src/locking.rs +10 -0
  45. data/crates/kobako-runtime/src/memcg.rs +383 -0
  46. data/crates/kobako-runtime/src/mount.rs +67 -9
  47. data/crates/kobako-runtime/src/net/backends.rs +43 -0
  48. data/crates/kobako-runtime/src/net/connections.rs +179 -0
  49. data/crates/kobako-runtime/src/net/credential.rs +125 -0
  50. data/crates/kobako-runtime/src/net/egress.rs +160 -0
  51. data/crates/kobako-runtime/src/net/family.rs +181 -0
  52. data/crates/kobako-runtime/src/net/http.rs +2733 -0
  53. data/crates/kobako-runtime/src/net/lookup.rs +285 -0
  54. data/crates/kobako-runtime/src/net/mock.rs +251 -0
  55. data/crates/kobako-runtime/src/net/namespace.rs +1366 -0
  56. data/crates/kobako-runtime/src/net/reactor.rs +531 -0
  57. data/crates/kobako-runtime/src/net/resolv/darwin.rs +275 -0
  58. data/crates/kobako-runtime/src/net/resolv/stub/tests.rs +469 -0
  59. data/crates/kobako-runtime/src/net/resolv/stub.rs +536 -0
  60. data/crates/kobako-runtime/src/net/resolv/windows.rs +248 -0
  61. data/crates/kobako-runtime/src/net/resolv.rs +227 -0
  62. data/crates/kobako-runtime/src/net/socket.rs +870 -0
  63. data/crates/kobako-runtime/src/net/tcp.rs +1588 -0
  64. data/crates/kobako-runtime/src/net/tls.rs +58 -0
  65. data/crates/kobako-runtime/src/net/transport.rs +279 -0
  66. data/crates/kobako-runtime/src/net/udp.rs +1003 -0
  67. data/crates/kobako-runtime/src/net.rs +42 -0
  68. data/crates/kobako-runtime/src/network/builder.rs +177 -0
  69. data/crates/kobako-runtime/src/network/ruleset.rs +777 -0
  70. data/crates/kobako-runtime/src/network.rs +551 -0
  71. data/crates/kobako-runtime/src/policy.rs +16 -0
  72. data/crates/kobako-runtime/src/profile.rs +29 -144
  73. data/crates/kobako-runtime/src/runtime.rs +3 -5
  74. data/crates/kobako-runtime/src/sched.rs +130 -29
  75. data/crates/kobako-runtime/src/security/entry_policy.rs +22 -0
  76. data/crates/kobako-runtime/src/{vfs/cred.rs → security/hooks.rs} +52 -144
  77. data/crates/kobako-runtime/src/security/mount_policy.rs +158 -0
  78. data/crates/kobako-runtime/src/security.rs +101 -196
  79. data/crates/kobako-runtime/src/snapshot.rs +121 -2
  80. data/crates/kobako-runtime/src/vfs/attr.rs +5 -5
  81. data/crates/kobako-runtime/src/vfs/dentry.rs +143 -89
  82. data/crates/kobako-runtime/src/vfs/file.rs +199 -203
  83. data/crates/kobako-runtime/src/vfs/inode.rs +41 -45
  84. data/crates/kobako-runtime/src/vfs/kern_path.rs +38 -42
  85. data/crates/kobako-runtime/src/vfs/mount.rs +10 -9
  86. data/crates/kobako-runtime/src/vfs/namei.rs +829 -700
  87. data/crates/kobako-runtime/src/vfs/namespace.rs +162 -0
  88. data/crates/kobako-runtime/src/vfs/open_files.rs +69 -0
  89. data/crates/kobako-runtime/src/vfs/openat2.rs +3 -3
  90. data/crates/kobako-runtime/src/vfs/path.rs +6 -6
  91. data/crates/kobako-runtime/src/vfs/readdir.rs +6 -6
  92. data/crates/kobako-runtime/src/vfs/stat.rs +159 -23
  93. data/crates/kobako-runtime/src/vfs/super_block.rs +18 -14
  94. data/crates/kobako-runtime/src/vfs/utimes.rs +37 -27
  95. data/crates/kobako-runtime/src/vfs.rs +9 -6
  96. data/crates/kobako-runtime/src/wait.rs +356 -0
  97. data/crates/kobako-transport/CHANGELOG.md +31 -0
  98. data/crates/kobako-transport/Cargo.toml +1 -1
  99. data/crates/kobako-transport/README.md +3 -4
  100. data/crates/kobako-transport/src/abi.rs +78 -72
  101. data/crates/kobako-transport/src/envelope/bytes.rs +17 -6
  102. data/crates/kobako-transport/src/envelope/call.rs +32 -4
  103. data/crates/kobako-transport/src/envelope/error_record.rs +21 -0
  104. data/crates/kobako-transport/src/envelope/name.rs +99 -0
  105. data/crates/kobako-transport/src/envelope/outcome.rs +9 -9
  106. data/crates/kobako-transport/src/envelope/preamble.rs +24 -21
  107. data/crates/kobako-transport/src/envelope/reply.rs +27 -27
  108. data/crates/kobako-transport/src/envelope/unsupported.rs +10 -10
  109. data/crates/kobako-transport/src/envelope.rs +13 -8
  110. data/crates/kobako-wasmtime/CHANGELOG.md +161 -0
  111. data/crates/kobako-wasmtime/Cargo.toml +26 -7
  112. data/crates/kobako-wasmtime/README.md +3 -2
  113. data/crates/kobako-wasmtime/build/preview2.rs +1339 -0
  114. data/crates/kobako-wasmtime/build.rs +16 -0
  115. data/crates/kobako-wasmtime/src/abi.rs +17 -37
  116. data/crates/kobako-wasmtime/src/ambient.rs +33 -18
  117. data/crates/kobako-wasmtime/src/cache.rs +23 -15
  118. data/crates/kobako-wasmtime/src/config.rs +52 -68
  119. data/crates/kobako-wasmtime/src/driver.rs +48 -63
  120. data/crates/kobako-wasmtime/src/exports.rs +143 -17
  121. data/crates/kobako-wasmtime/src/guest.rs +12 -6
  122. data/crates/kobako-wasmtime/src/guest_binary.rs +14 -0
  123. data/crates/kobako-wasmtime/src/imports.rs +42 -18
  124. data/crates/kobako-wasmtime/src/instance_pre.rs +4 -4
  125. data/crates/kobako-wasmtime/src/invocation.rs +74 -12
  126. data/crates/kobako-wasmtime/src/lib.rs +5 -3
  127. data/crates/kobako-wasmtime/src/limiter.rs +70 -5
  128. data/crates/kobako-wasmtime/src/preview1/descriptors.rs +309 -0
  129. data/crates/kobako-wasmtime/src/preview1/differential/mount.rs +5 -15
  130. data/crates/kobako-wasmtime/src/preview1/differential.rs +27 -31
  131. data/crates/kobako-wasmtime/src/preview1/errno.rs +55 -66
  132. data/crates/kobako-wasmtime/src/preview1/fd.rs +327 -296
  133. data/crates/kobako-wasmtime/src/preview1/memory.rs +21 -12
  134. data/crates/kobako-wasmtime/src/preview1/mount_view/wrap.rs +34 -53
  135. data/crates/kobako-wasmtime/src/preview1/mount_view.rs +231 -217
  136. data/crates/kobako-wasmtime/src/preview1/path.rs +56 -121
  137. data/crates/kobako-wasmtime/src/preview1/poll.rs +244 -120
  138. data/crates/kobako-wasmtime/src/preview1/sock.rs +10 -8
  139. data/crates/kobako-wasmtime/src/preview1/testsuite.rs +5 -15
  140. data/crates/kobako-wasmtime/src/preview1.rs +46 -42
  141. data/crates/kobako-wasmtime/src/preview2/abi.rs +227 -0
  142. data/crates/kobako-wasmtime/src/preview2/error.rs +118 -0
  143. data/crates/kobako-wasmtime/src/preview2/filesystem.rs +122 -0
  144. data/crates/kobako-wasmtime/src/preview2/host.rs +3959 -0
  145. data/crates/kobako-wasmtime/src/preview2/http.rs +1503 -0
  146. data/crates/kobako-wasmtime/src/preview2/io.rs +315 -0
  147. data/crates/kobako-wasmtime/src/preview2/sockets.rs +379 -0
  148. data/crates/kobako-wasmtime/src/preview2/table.rs +305 -0
  149. data/crates/kobako-wasmtime/src/preview2.rs +57 -0
  150. data/crates/kobako-wasmtime/src/trap.rs +24 -9
  151. data/crates/kobako-wasmtime/src/wasi.rs +210 -81
  152. data/crates/kobako-wasmtime/wit/deps/cli.wit +233 -0
  153. data/crates/kobako-wasmtime/wit/deps/clocks.wit +162 -0
  154. data/crates/kobako-wasmtime/wit/deps/filesystem.wit +589 -0
  155. data/crates/kobako-wasmtime/wit/deps/http.wit +733 -0
  156. data/crates/kobako-wasmtime/wit/deps/io.wit +299 -0
  157. data/crates/kobako-wasmtime/wit/deps/random.wit +92 -0
  158. data/crates/kobako-wasmtime/wit/deps/sockets.wit +949 -0
  159. data/data/kobako.wasm +0 -0
  160. data/ext/kobako/Cargo.toml +1 -1
  161. data/ext/kobako/src/{runtime/errors.rs → errors.rs} +34 -26
  162. data/ext/kobako/src/{runtime/escape.rs → escape.rs} +42 -11
  163. data/ext/kobako/src/{runtime/filesystem → filesystem}/grants.rs +30 -26
  164. data/ext/kobako/src/{runtime/filesystem → filesystem}/ruby.rs +149 -168
  165. data/ext/kobako/src/{runtime/filesystem.rs → filesystem.rs} +24 -15
  166. data/ext/kobako/src/gvl.rs +306 -0
  167. data/ext/kobako/src/lib.rs +64 -3
  168. data/ext/kobako/src/network/mock.rs +187 -0
  169. data/ext/kobako/src/network.rs +591 -0
  170. data/ext/kobako/src/runtime/bridge.rs +30 -29
  171. data/ext/kobako/src/runtime/snapshot.rs +4 -4
  172. data/ext/kobako/src/runtime.rs +221 -143
  173. data/ext/kobako/src/wire.rs +42 -0
  174. data/lib/kobako/catalog/extensions.rb +14 -2
  175. data/lib/kobako/catalog/flags.rb +3 -5
  176. data/lib/kobako/catalog/grants.rb +5 -4
  177. data/lib/kobako/catalog/handles.rb +5 -27
  178. data/lib/kobako/catalog/mount.rb +11 -3
  179. data/lib/kobako/catalog/network.rb +35 -0
  180. data/lib/kobako/catalog/replacements.rb +28 -0
  181. data/lib/kobako/catalog/services.rb +5 -19
  182. data/lib/kobako/catalog/snippets.rb +3 -18
  183. data/lib/kobako/catalog.rb +3 -0
  184. data/lib/kobako/codec/{utils.rb → boundary.rb} +4 -2
  185. data/lib/kobako/codec/decoder.rb +4 -4
  186. data/lib/kobako/codec/ext_types.rb +3 -3
  187. data/lib/kobako/codec/handle_walk.rb +3 -43
  188. data/lib/kobako/codec/value_budget.rb +132 -40
  189. data/lib/kobako/codec.rb +1 -1
  190. data/lib/kobako/context.rb +24 -11
  191. data/lib/kobako/errors.rb +15 -12
  192. data/lib/kobako/extension.rb +3 -2
  193. data/lib/kobako/filesystem.rb +9 -2
  194. data/lib/kobako/handle.rb +2 -2
  195. data/lib/kobako/names.rb +28 -0
  196. data/lib/kobako/network.rb +210 -0
  197. data/lib/kobako/outcome.rb +7 -7
  198. data/lib/kobako/pool.rb +45 -23
  199. data/lib/kobako/runtime.rb +3 -2
  200. data/lib/kobako/sandbox.rb +92 -35
  201. data/lib/kobako/sandbox_options.rb +41 -106
  202. data/lib/kobako/transport/argument_wrap.rb +64 -0
  203. data/lib/kobako/transport/block_failure.rb +1 -1
  204. data/lib/kobako/transport/dispatcher.rb +6 -6
  205. data/lib/kobako/transport/exposure.rb +26 -15
  206. data/lib/kobako/transport/reflection.rb +21 -4
  207. data/lib/kobako/transport/run.rb +8 -23
  208. data/lib/kobako/transport/yielder.rb +2 -9
  209. data/lib/kobako/transport.rb +1 -0
  210. data/lib/kobako/version.rb +1 -1
  211. data/lib/kobako.rb +6 -2
  212. data/release-please-config.json +15 -0
  213. data/sig/core/thread.rbs +6 -0
  214. data/sig/kobako/catalog/extensions.rbs +2 -0
  215. data/sig/kobako/catalog/grants.rbs +7 -4
  216. data/sig/kobako/catalog/handles.rbs +0 -2
  217. data/sig/kobako/catalog/mount.rbs +3 -1
  218. data/sig/kobako/catalog/network.rbs +20 -0
  219. data/sig/kobako/catalog/replacements.rbs +14 -0
  220. data/sig/kobako/catalog/services.rbs +0 -4
  221. data/sig/kobako/catalog/snippets.rbs +0 -2
  222. data/sig/kobako/codec/{utils.rbs → boundary.rbs} +2 -2
  223. data/sig/kobako/codec/handle_walk.rbs +0 -6
  224. data/sig/kobako/codec/value_budget.rbs +47 -4
  225. data/sig/kobako/context.rbs +3 -1
  226. data/sig/kobako/errors.rbs +4 -4
  227. data/sig/kobako/filesystem.rbs +21 -3
  228. data/sig/kobako/network.rbs +115 -0
  229. data/sig/kobako/outcome.rbs +1 -1
  230. data/sig/kobako/pool.rbs +7 -3
  231. data/sig/kobako/runtime.rbs +32 -3
  232. data/sig/kobako/sandbox.rbs +19 -2
  233. data/sig/kobako/sandbox_options.rbs +29 -38
  234. data/sig/kobako/transport/argument_wrap.rbs +15 -0
  235. data/sig/kobako/transport/error.rbs +1 -1
  236. data/sig/kobako/transport/exposure.rbs +2 -4
  237. data/sig/kobako/transport/reflection.rbs +10 -0
  238. data/sig/kobako/transport/run.rbs +0 -2
  239. data/sig/kobako/transport/yielder.rbs +0 -3
  240. data/sig/kobako/transport.rbs +1 -1
  241. data/sig/kobako.rbs +13 -0
  242. metadata +84 -35
  243. data/crates/kobako-runtime/src/endpoint/capture.rs +0 -115
  244. data/crates/kobako-runtime/src/endpoint/memory_cap.rs +0 -238
  245. data/crates/kobako-runtime/src/filesystem/path.rs +0 -21
  246. data/crates/kobako-runtime/src/vfs/errno.rs +0 -153
  247. data/crates/kobako-runtime/tests/linux_baseline/calls.rs +0 -171
  248. data/crates/kobako-runtime/tests/linux_baseline/concurrent.rs +0 -276
  249. data/crates/kobako-runtime/tests/linux_baseline/kobako.rs +0 -323
  250. data/crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt +0 -16
  251. data/crates/kobako-runtime/tests/linux_baseline/linux.rs +0 -449
  252. data/crates/kobako-runtime/tests/linux_baseline/main.rs +0 -611
  253. data/crates/kobako-runtime/tests/linux_baseline/permissions.rs +0 -236
  254. data/crates/kobako-wasmtime/src/descriptors.rs +0 -200
  255. data/crates/kobako-wasmtime/tests/integration/compile_posture.rs +0 -43
  256. data/crates/kobako-wasmtime/tests/integration/guest_file.rs +0 -1085
  257. data/crates/kobako-wasmtime/tests/integration/main.rs +0 -29
  258. data/crates/kobako-wasmtime/tests/integration/preamble_flags.rs +0 -70
  259. data/crates/kobako-wasmtime/tests/integration/snippet_compile.rs +0 -95
  260. data/crates/kobako-wasmtime/tests/integration/support/mod.rs +0 -30
  261. data/crates/kobako-wasmtime/tests/integration/unanswered_call.rs +0 -86
  262. data/crates/kobako-wasmtime/tests/integration/unsupported_call.rs +0 -51
  263. data/ext/kobako/src/runtime/gvl.rs +0 -147
  264. data/lib/kobako/constant_name.rb +0 -8
  265. data/sig/kobako/constant_name.rbs +0 -3
  266. /data/ext/kobako/src/{runtime/pinned_value.rs → pinned_value.rs} +0 -0
@@ -19,7 +19,7 @@ use std::sync::Arc;
19
19
 
20
20
  use super::rdir::Rdir;
21
21
  use super::{
22
- DentryOperations, FileOperations, FileSystemType, FileType, Filesystem, FilesystemError, Iattr,
22
+ DentryOperations, Errno, FileOperations, FileSystemType, FileType, Filesystem, Iattr,
23
23
  InodeOperations, Kstat, Lookup, OpenHow, RenameFlag, Tmpfs,
24
24
  };
25
25
  use crate::vfs::{
@@ -64,17 +64,14 @@ impl Overlay {
64
64
  /// Layers, a stack too deep, and one instance as two Layers, as
65
65
  /// overlayfs answers overlapping layers; as gVisor's does, it refuses an
66
66
  /// upper that is no Tmpfs.
67
- pub fn new(
68
- lower: Vec<Arc<Filesystem>>,
69
- upper: Option<Arc<Filesystem>>,
70
- ) -> Result<Self, FilesystemError> {
67
+ pub fn new(lower: Vec<Arc<Filesystem>>, upper: Option<Arc<Filesystem>>) -> Result<Self, Errno> {
71
68
  let layers: Vec<_> = lower.iter().chain(&upper).collect();
72
69
  let overlapping = layers
73
70
  .iter()
74
71
  .enumerate()
75
72
  .any(|(at, layer)| layers[..at].iter().any(|seen| Arc::ptr_eq(seen, layer)));
76
73
  if overlapping {
77
- return Err(FilesystemError::InvalidInput);
74
+ return Err(Errno::InvalidInput);
78
75
  }
79
76
  let too_few = if upper.is_some() { 1 } else { 2 };
80
77
  let upper_tmpfs = upper.as_ref().is_none_or(|upper| {
@@ -96,7 +93,7 @@ impl Overlay {
96
93
  || !upper_tmpfs
97
94
  || stack_depth > MAX_STACK_DEPTH
98
95
  {
99
- return Err(FilesystemError::InvalidInput);
96
+ return Err(Errno::InvalidInput);
100
97
  }
101
98
  Ok(Self {
102
99
  fs: OverlayFs::new(lower, upper)?,
@@ -115,7 +112,7 @@ fn real_of(dentry: &Dentry) -> Option<(Arc<Dentry>, Arc<Inode>)> {
115
112
 
116
113
  /// Whether `real`, a Layer's dentry, still names what it recorded, as
117
114
  /// `ovl_revalidate_real` asks it.
118
- fn ovl_revalidate_real(real: &Dentry) -> Result<bool, FilesystemError> {
115
+ fn ovl_revalidate_real(real: &Dentry) -> Result<bool, Errno> {
119
116
  match real.ops() {
120
117
  Some(ops) => ops.revalidate(real.parent().inode_ops()?.as_ref(), real),
121
118
  None => Ok(true),
@@ -127,11 +124,7 @@ fn ovl_revalidate_real(real: &Dentry) -> Result<bool, FilesystemError> {
127
124
  /// stands for what each Layer holds there, as `ovl_clear_empty` drops a dentry
128
125
  /// whose upper no longer matches.
129
126
  impl DentryOperations for Overlay {
130
- fn revalidate(
131
- &self,
132
- _dir: &dyn InodeOperations,
133
- dentry: &Dentry,
134
- ) -> Result<bool, FilesystemError> {
127
+ fn revalidate(&self, _dir: &dyn InodeOperations, dentry: &Dentry) -> Result<bool, Errno> {
135
128
  let Some(inode) = dentry.inode() else {
136
129
  return Ok(matches!(self.lookup(dentry)?, Lookup::Absent));
137
130
  };
@@ -192,8 +185,8 @@ impl Overlay {
192
185
 
193
186
  /// What the Layer the entry's name is found in reports, under the identity
194
187
  /// the view recorded.
195
- fn real_getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
196
- let (real, inode) = real_of(dentry).ok_or(FilesystemError::NotFound)?;
188
+ fn real_getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
189
+ let (real, inode) = real_of(dentry).ok_or(Errno::NotFound)?;
197
190
  let found = real.getattr()?;
198
191
  Ok(match inode.identity() {
199
192
  Some(identity) => identity.onto(found),
@@ -203,18 +196,18 @@ impl Overlay {
203
196
  }
204
197
 
205
198
  impl InodeOperations for OverlayRegular {
206
- fn getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
199
+ fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
207
200
  self.0.real_getattr(dentry)
208
201
  }
209
202
 
210
203
  /// Copied up first, as `ovl_setattr` does, so a lower Layer stays as it
211
204
  /// was whatever its Filesystem would keep.
212
- fn setattr(&self, dentry: &Dentry, attr: &Iattr) -> Result<(), FilesystemError> {
205
+ fn setattr(&self, dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
213
206
  let overlay = &self.0;
214
207
  overlay
215
208
  .fs
216
209
  .copy_up_file(&overlay.fs.parent(dentry)?, dentry, false)?;
217
- let (real, _) = real_of(dentry).ok_or(FilesystemError::NotFound)?;
210
+ let (real, _) = real_of(dentry).ok_or(Errno::NotFound)?;
218
211
  // The open's truncate never reached the upper's open, so the upper must
219
212
  // empty the file itself, and the view's open file is none of the upper's,
220
213
  // as `ovl_setattr` clears `ATTR_OPEN` and `ATTR_FILE`.
@@ -230,24 +223,20 @@ impl InodeOperations for OverlayRegular {
230
223
  )
231
224
  }
232
225
 
233
- fn open(
234
- &self,
235
- dentry: &Dentry,
236
- how: &OpenHow,
237
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
226
+ fn open(&self, dentry: &Dentry, how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
238
227
  let fs = &self.0.fs;
239
228
  fs.open(&fs.parent(dentry)?, dentry, how)
240
229
  }
241
230
  }
242
231
 
243
232
  impl InodeOperations for OverlayLink {
244
- fn getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
233
+ fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
245
234
  self.0.real_getattr(dentry)
246
235
  }
247
236
 
248
237
  /// Where the link points, as `ovl_get_link` asks the real dentry.
249
- fn get_link(&self, dentry: &Dentry) -> Result<String, FilesystemError> {
250
- let (real, _) = real_of(dentry).ok_or(FilesystemError::NotFound)?;
238
+ fn get_link(&self, dentry: &Dentry) -> Result<String, Errno> {
239
+ let (real, _) = real_of(dentry).ok_or(Errno::NotFound)?;
251
240
  real.get_link()
252
241
  }
253
242
  }
@@ -257,7 +246,7 @@ impl FileSystemType for Overlay {
257
246
  /// Its root takes the identity its topmost Layer's root recorded, as
258
247
  /// `ovl_get_root` reads a real root's `i_ino`, so making the view asks no
259
248
  /// Layer anything.
260
- fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), FilesystemError> {
249
+ fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
261
250
  sb.set_default_d_op(self.clone());
262
251
  if !self.fs.has_upper() {
263
252
  sb.set_rdonly();
@@ -279,13 +268,13 @@ impl FileSystemType for Overlay {
279
268
  /// is handed, as `ovl_dir_inode_operations` answers for one.
280
269
  impl InodeOperations for Overlay {
281
270
  /// It reports its merged Layers.
282
- fn getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
271
+ fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
283
272
  self.fs.dir_getattr(&self.fs.dir(dentry)?.level())
284
273
  }
285
274
 
286
275
  /// Copied up first, as `ovl_setattr` does for any entry, so a lower Layer
287
276
  /// stays as it was.
288
- fn setattr(&self, dentry: &Dentry, attr: &Iattr) -> Result<(), FilesystemError> {
277
+ fn setattr(&self, dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
289
278
  let upper = self.fs.upper_dir(&self.fs.dir(dentry)?)?;
290
279
  let held = upper.dentry().inode_lock()?;
291
280
  notify_change(upper.dentry(), &held, attr)
@@ -294,11 +283,11 @@ impl InodeOperations for Overlay {
294
283
  /// The entry as a Layer spells it, as `ovl_lookup` hands
295
284
  /// `d_splice_alias` the inode it made, a name no Layer could hold refused
296
285
  /// before any is asked, as it compares `namelen`.
297
- fn lookup(&self, dentry: &Dentry) -> Result<Lookup, FilesystemError> {
286
+ fn lookup(&self, dentry: &Dentry) -> Result<Lookup, Errno> {
298
287
  let level = self.fs.parent(dentry)?.level();
299
288
  let name = dentry.name();
300
289
  if name.len() > NAME_MAX {
301
- return Err(FilesystemError::InvalidFilename);
290
+ return Err(Errno::InvalidFilename);
302
291
  }
303
292
  let Some(found) = self.fs.lookup_layer(&level, &name)? else {
304
293
  return Ok(Lookup::Absent);
@@ -316,11 +305,7 @@ impl InodeOperations for Overlay {
316
305
  }
317
306
  }
318
307
 
319
- fn open(
320
- &self,
321
- dentry: &Dentry,
322
- _how: &OpenHow,
323
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
308
+ fn open(&self, dentry: &Dentry, _how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
324
309
  let _real = self
325
310
  .fs
326
311
  .dir(dentry)?
@@ -339,24 +324,24 @@ impl InodeOperations for Overlay {
339
324
 
340
325
  /// What was made is found through the view's own lookup, as `ovl_instantiate`
341
326
  /// records the inode for the real dentry.
342
- fn create(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
327
+ fn create(&self, dentry: &Dentry) -> Result<(), Errno> {
343
328
  self.fs.create(&self.fs.parent(dentry)?, &dentry.name())?;
344
329
  match self.lookup(dentry)? {
345
330
  Lookup::Found(inode) => dentry.add(Some(inode)),
346
- _ => return Err(FilesystemError::NotFound),
331
+ _ => return Err(Errno::NotFound),
347
332
  }
348
333
  Ok(())
349
334
  }
350
335
 
351
- fn mkdir(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
336
+ fn mkdir(&self, dentry: &Dentry) -> Result<(), Errno> {
352
337
  self.fs.mkdir(&self.fs.parent(dentry)?, &dentry.name())
353
338
  }
354
339
 
355
- fn rmdir(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
340
+ fn rmdir(&self, dentry: &Dentry) -> Result<(), Errno> {
356
341
  self.fs.rmdir(&self.fs.parent(dentry)?, dentry)
357
342
  }
358
343
 
359
- fn unlink(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
344
+ fn unlink(&self, dentry: &Dentry) -> Result<(), Errno> {
360
345
  self.fs.unlink(&self.fs.parent(dentry)?, dentry)
361
346
  }
362
347
 
@@ -364,16 +349,16 @@ impl InodeOperations for Overlay {
364
349
  /// it are open. Only its upper takes a flag, which it asks itself.
365
350
  fn rename(
366
351
  &self,
367
- from: &Dentry,
368
- _to_dir: &dyn InodeOperations,
369
- to: &Dentry,
370
- flag: Option<RenameFlag>,
371
- ) -> Result<(), FilesystemError> {
372
- if flag.is_some() {
373
- return Err(FilesystemError::InvalidInput);
352
+ old: &Dentry,
353
+ _new_dir: &dyn InodeOperations,
354
+ new: &Dentry,
355
+ flags: Option<RenameFlag>,
356
+ ) -> Result<(), Errno> {
357
+ if flags.is_some() {
358
+ return Err(Errno::InvalidInput);
374
359
  }
375
360
  self.fs
376
- .rename(&self.fs.parent(from)?, from, &self.fs.parent(to)?, to)
361
+ .rename(&self.fs.parent(old)?, old, &self.fs.parent(new)?, new)
377
362
  }
378
363
  }
379
364
 
@@ -394,31 +379,23 @@ impl FileOperations for OverlayDir {
394
379
  pos: u64,
395
380
  offset: i64,
396
381
  whence: Whence,
397
- ) -> Result<u64, FilesystemError> {
382
+ ) -> Result<u64, Errno> {
398
383
  generic_file_llseek(dentry, pos, offset, whence)
399
384
  }
400
385
 
401
- fn read_iter(
402
- &mut self,
403
- _iocb: &mut super::Kiocb,
404
- _buf: &mut [u8],
405
- ) -> Result<usize, FilesystemError> {
386
+ fn read_iter(&mut self, _iocb: &mut super::Kiocb, _buf: &mut [u8]) -> Result<usize, Errno> {
406
387
  generic_read_dir()
407
388
  }
408
389
 
409
- fn iterate_shared(
410
- &mut self,
411
- dentry: &Dentry,
412
- ctx: &mut DirContext<'_>,
413
- ) -> Result<(), FilesystemError> {
390
+ fn iterate_shared(&mut self, dentry: &Dentry, ctx: &mut DirContext<'_>) -> Result<(), Errno> {
414
391
  let (fs, cache) = (&self.fs, &mut self.cache);
415
- cache.iterate(dentry, ctx, || fs.dir_read_merged(&fs.dir(dentry)?.level()))
392
+ cache.iterate_shared(dentry, ctx, || fs.dir_read_merged(&fs.dir(dentry)?.level()))
416
393
  }
417
394
 
418
395
  /// Its Layers answer for what they hold, and its upper is a Tmpfs, so
419
396
  /// nothing is left to make durable, as `ovl_dir_fsync` finds with no upper
420
397
  /// of its own to sync.
421
- fn fsync(&mut self, _datasync: bool) -> Result<(), FilesystemError> {
398
+ fn fsync(&mut self, _datasync: bool) -> Result<(), Errno> {
422
399
  Ok(())
423
400
  }
424
401
  }
@@ -451,11 +428,7 @@ mod tests {
451
428
  struct CountsLookups(AtomicUsize);
452
429
 
453
430
  impl Hook for CountsLookups {
454
- fn lookup(
455
- &self,
456
- inner: &dyn InodeOperations,
457
- dentry: &Dentry,
458
- ) -> Result<Lookup, FilesystemError> {
431
+ fn lookup(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Lookup, Errno> {
459
432
  self.0.fetch_add(1, Ordering::SeqCst);
460
433
  inner.lookup(dentry)
461
434
  }
@@ -470,11 +443,9 @@ mod tests {
470
443
  let lower: Tmpfs = [("file", "x")].into_iter().collect();
471
444
  let counts = Arc::new(CountsLookups::default());
472
445
  let view = at(Overlay::new(
473
- vec![
474
- Filesystem::new(Arc::new(Wrap::new(Arc::new(lower), counts.clone())))
475
- .expect("the instance must stand"),
476
- ],
477
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
446
+ vec![Filesystem::new(Wrap::new(Arc::new(lower), counts.clone()))
447
+ .expect("the instance must stand")],
448
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
478
449
  )
479
450
  .expect("the Overlay must stack"));
480
451
  let asks = |path: &str| {
@@ -505,9 +476,9 @@ mod tests {
505
476
  on(&upper).vfs_lstat("upper/dir").err(),
506
477
  ),
507
478
  (
508
- Some(FilesystemError::InvalidFilename),
509
- Some(FilesystemError::InvalidFilename),
510
- Some(FilesystemError::NotFound),
479
+ Some(Errno::InvalidFilename),
480
+ Some(Errno::InvalidFilename),
481
+ Some(Errno::NotFound),
511
482
  ),
512
483
  "a stat and a make of a name past NAME_MAX in a lower directory, through an Overlay, \
513
484
  must answer ENAMETOOLONG and leave that directory uncopied"
@@ -520,8 +491,8 @@ mod tests {
520
491
  let lower: Tmpfs = [("file", "x")].into_iter().collect();
521
492
  let upper = Tmpfs::new();
522
493
  let overlay = at(Overlay::new(
523
- vec![Filesystem::new(Arc::new(lower)).expect("the instance must stand")],
524
- Some(Filesystem::new(Arc::new(upper)).expect("the instance must stand")),
494
+ vec![Filesystem::new(lower).expect("the instance must stand")],
495
+ Some(Filesystem::new(upper).expect("the instance must stand")),
525
496
  )
526
497
  .expect("the Overlay must stack"));
527
498
  assert_eq!(
@@ -552,7 +523,7 @@ mod tests {
552
523
  fn read_from(file: &mut dyn FileOperations) -> Vec<u8> {
553
524
  let mut buf = vec![0; 64];
554
525
  let read = file
555
- .read_iter(&mut Kiocb::at(0), &mut buf)
526
+ .read_iter(&mut Kiocb::new(0), &mut buf)
556
527
  .expect("the file must read");
557
528
  buf.truncate(read);
558
529
  buf
@@ -562,7 +533,7 @@ mod tests {
562
533
  read_from(open_to_read(fs, path).as_mut())
563
534
  }
564
535
 
565
- fn write(fs: &KernPath, path: &str, contents: &[u8]) -> Result<(), FilesystemError> {
536
+ fn write(fs: &KernPath, path: &str, contents: &[u8]) -> Result<(), Errno> {
566
537
  fs.open_or_create(
567
538
  path,
568
539
  &OpenHow {
@@ -571,19 +542,19 @@ mod tests {
571
542
  ..OpenHow::default()
572
543
  },
573
544
  )?
574
- .write_iter(&mut Kiocb::at(0), contents)
545
+ .write_iter(&mut Kiocb::new(0), contents)
575
546
  .map(drop)
576
547
  }
577
548
 
578
549
  /// Write at the start of what stands at `path`, so a copy up brings its
579
550
  /// bytes along.
580
- fn write_over(fs: &KernPath, path: &str, contents: &[u8]) -> Result<(), FilesystemError> {
551
+ fn write_over(fs: &KernPath, path: &str, contents: &[u8]) -> Result<(), Errno> {
581
552
  let how = OpenHow {
582
553
  write: true,
583
554
  ..OpenHow::default()
584
555
  };
585
556
  fs.open(path, &how)?
586
- .write_iter(&mut Kiocb::at(0), contents)
557
+ .write_iter(&mut Kiocb::new(0), contents)
587
558
  .map(drop)
588
559
  }
589
560
 
@@ -621,10 +592,7 @@ mod tests {
621
592
  overlay.vfs_mkdir("made").err(),
622
593
  on(&top).vfs_lstat("made").err()
623
594
  ),
624
- (
625
- Some(FilesystemError::ReadOnlyFilesystem),
626
- Some(FilesystemError::NotFound)
627
- ),
595
+ (Some(Errno::ReadOnlyFilesystem), Some(Errno::NotFound)),
628
596
  "OverlayFs::mkdir with no upper, reached beneath the VFS's read-only answer, must \
629
597
  answer EROFS and make nothing in its topmost lower Layer"
630
598
  );
@@ -634,12 +602,8 @@ mod tests {
634
602
  /// let change.
635
603
  struct RecordsChanges(Arc<Mutex<Vec<String>>>);
636
604
 
637
- impl crate::vfs::SecurityOperations for RecordsChanges {
638
- fn inode_permission(
639
- &self,
640
- dentry: &Dentry,
641
- mask: crate::vfs::Mask,
642
- ) -> Result<(), FilesystemError> {
605
+ impl crate::security::SecurityOperations for RecordsChanges {
606
+ fn inode_permission(&self, dentry: &Dentry, mask: crate::vfs::Mask) -> Result<(), Errno> {
643
607
  if mask.contains(crate::vfs::Mask::WRITE) {
644
608
  self.0.lock().expect("never poisoned").push(dentry.name());
645
609
  }
@@ -655,12 +619,12 @@ mod tests {
655
619
  let overlay = over(tmpfs_with("f", "x"), Arc::new(Tmpfs::new()));
656
620
  let mount = crate::mount::Mount::new(
657
621
  "/data",
658
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
622
+ Filesystem::new(overlay).expect("the instance must stand"),
659
623
  crate::mount::Access::ReadWrite,
660
624
  )
661
625
  .expect("/data is a guest path");
662
626
  let asked = Arc::new(Mutex::new(Vec::new()));
663
- let cred = crate::vfs::Cred::new(vec![Arc::new(RecordsChanges(asked.clone()))]);
627
+ let cred = crate::cred::Cred::new(vec![Arc::new(RecordsChanges(asked.clone()))]);
664
628
  let root = crate::vfs::Path::root(mount.mnt());
665
629
  let made = crate::vfs::filename_mkdirat(&cred, &root, "d");
666
630
  assert_eq!(
@@ -748,7 +712,7 @@ mod tests {
748
712
  kind(&overlay, "dirlink/inner"),
749
713
  names(&overlay, "dirlink").len()
750
714
  ),
751
- (Err(FilesystemError::NotFound), 0),
715
+ (Err(Errno::NotFound), 0),
752
716
  "a name beneath a directory an upper Layer holds, where a lower Layer holds a link, \
753
717
  through vfs_lstat and its listing must show nothing the link leads to"
754
718
  );
@@ -774,7 +738,7 @@ mod tests {
774
738
  overlay.open_dir("dirlink").map(drop),
775
739
  overlay.vfs_readlink("dirlink")
776
740
  ),
777
- (Err(FilesystemError::FilesystemLoop), Ok("dir".to_string())),
741
+ (Err(Errno::FilesystemLoop), Ok("dir".to_string())),
778
742
  "a link a Bind Layer holds, opened through Overlay::open_dir, must be a \
779
743
  link loop, and through vfs_readlink must answer where it points"
780
744
  );
@@ -817,9 +781,9 @@ mod tests {
817
781
  host.0.join("dirlink").is_symlink()
818
782
  ),
819
783
  (
820
- (Err(FilesystemError::NotADirectory), Ok(()), Ok(())),
821
- Some(FilesystemError::NotFound),
822
- Some(FilesystemError::NotFound),
784
+ (Err(Errno::NotADirectory), Ok(()), Ok(())),
785
+ Some(Errno::NotFound),
786
+ Some(Errno::NotFound),
823
787
  true
824
788
  ),
825
789
  "a link a read-only Bind Layer holds, removed through vfs_rmdir and \
@@ -847,10 +811,7 @@ mod tests {
847
811
  write(&overlay, "pipe", b"upper"),
848
812
  overlay.rename("pipe", &overlay, "moved")
849
813
  ),
850
- (
851
- Err(FilesystemError::PermissionDenied),
852
- Err(FilesystemError::CrossesDevices)
853
- ),
814
+ (Err(Errno::PermissionDenied), Err(Errno::CrossesDevices)),
854
815
  "a FIFO a read-only Bind Layer holds, written or renamed through an Overlay, must \
855
816
  be refused as permission denied and as crossing devices"
856
817
  );
@@ -882,8 +843,8 @@ mod tests {
882
843
  file_type("made"),
883
844
  ),
884
845
  (
885
- Err(FilesystemError::IsADirectory),
886
- Err(FilesystemError::NotADirectory),
846
+ Err(Errno::IsADirectory),
847
+ Err(Errno::NotADirectory),
887
848
  Ok(FileType::Fifo),
888
849
  Ok(FileType::Dir)
889
850
  ),
@@ -897,21 +858,21 @@ mod tests {
897
858
  struct KeepsTimes(Arc<AtomicUsize>);
898
859
 
899
860
  impl FileSystemType for KeepsTimes {
900
- fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), FilesystemError> {
861
+ fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
901
862
  sb.d_make_root(Inode::new(&Kstat::new(FileType::Dir, 0), self));
902
863
  Ok(())
903
864
  }
904
865
  }
905
866
 
906
867
  impl InodeOperations for KeepsTimes {
907
- fn getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
868
+ fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
908
869
  Ok(match dentry.name().as_str() {
909
870
  "file" => Kstat::new(FileType::RegFile, 0).with_identity(1, 2),
910
871
  _ => Kstat::new(FileType::Dir, 0).with_identity(1, 1),
911
872
  })
912
873
  }
913
874
 
914
- fn lookup(&self, dentry: &Dentry) -> Result<Lookup, FilesystemError> {
875
+ fn lookup(&self, dentry: &Dentry) -> Result<Lookup, Errno> {
915
876
  Ok(match dentry.name().as_str() {
916
877
  "file" => Lookup::Found(Inode::new(
917
878
  &Kstat::new(FileType::RegFile, 0).with_identity(1, 2),
@@ -921,23 +882,19 @@ mod tests {
921
882
  })
922
883
  }
923
884
 
924
- fn setattr(&self, _dentry: &Dentry, _attr: &Iattr) -> Result<(), FilesystemError> {
885
+ fn setattr(&self, _dentry: &Dentry, _attr: &Iattr) -> Result<(), Errno> {
925
886
  self.0.fetch_add(1, Ordering::SeqCst);
926
887
  Ok(())
927
888
  }
928
889
 
929
- fn open(
930
- &self,
931
- _dentry: &Dentry,
932
- _how: &OpenHow,
933
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
890
+ fn open(&self, _dentry: &Dentry, _how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
934
891
  struct Empty;
935
892
  impl FileOperations for Empty {
936
893
  fn read_iter(
937
894
  &mut self,
938
895
  _iocb: &mut Kiocb,
939
896
  _buf: &mut [u8],
940
- ) -> Result<usize, FilesystemError> {
897
+ ) -> Result<usize, Errno> {
941
898
  Ok(0)
942
899
  }
943
900
  }
@@ -952,14 +909,13 @@ mod tests {
952
909
  let asked = Arc::new(AtomicUsize::new(0));
953
910
  let upper = Arc::new(Tmpfs::new());
954
911
  let overlay = Overlay::new(
955
- vec![Filesystem::new(Arc::new(KeepsTimes(asked.clone())))
956
- .expect("the instance must stand")],
912
+ vec![Filesystem::new(KeepsTimes(asked.clone())).expect("the instance must stand")],
957
913
  Some(Filesystem::new(upper.clone()).expect("the instance must stand")),
958
914
  )
959
915
  .unwrap_or_else(|_| panic!("the Overlay must make"));
960
916
  let mount = crate::mount::Mount::new(
961
917
  "/data",
962
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
918
+ Filesystem::new(overlay).expect("the instance must stand"),
963
919
  crate::mount::Access::ReadWrite,
964
920
  )
965
921
  .expect("/data is a guest path");
@@ -968,7 +924,7 @@ mod tests {
968
924
  &crate::vfs::Path::root(mount.mnt()),
969
925
  "file",
970
926
  false,
971
- &Iattr::times(None, Some(crate::filesystem::SetTime::Now)),
927
+ &Iattr::for_times(None, Some(crate::filesystem::SetTime::Now)),
972
928
  );
973
929
  assert_eq!(
974
930
  (
@@ -990,8 +946,8 @@ mod tests {
990
946
  let deep = vec!["a"; 1500].join("/");
991
947
  let lower: Tmpfs = [(format!("{deep}/file"), "x")].into_iter().collect();
992
948
  let overlay = Overlay::new(
993
- vec![Filesystem::new(Arc::new(lower)).expect("the instance must stand")],
994
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
949
+ vec![Filesystem::new(lower).expect("the instance must stand")],
950
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
995
951
  )
996
952
  .unwrap_or_else(|_| panic!("the Overlay must make"));
997
953
  let made = std::thread::Builder::new()
@@ -1025,7 +981,7 @@ mod tests {
1025
981
  overlay.rename("link", &overlay, "moved"),
1026
982
  read(&overlay, "target")
1027
983
  ),
1028
- (Err(FilesystemError::CrossesDevices), b"lower".to_vec()),
984
+ (Err(Errno::CrossesDevices), b"lower".to_vec()),
1029
985
  "a rename of a link a read-only Bind Layer holds, through an Overlay, must be refused \
1030
986
  as crossing devices and leave the target as it was"
1031
987
  );
@@ -1052,7 +1008,7 @@ mod tests {
1052
1008
  }
1053
1009
  )
1054
1010
  .map(drop),
1055
- Err(FilesystemError::FilesystemLoop),
1011
+ Err(Errno::FilesystemLoop),
1056
1012
  "a lower file beneath a dangling link a higher Bind Layer holds at its path, \
1057
1013
  opened through Overlay::open, must be refused as the link, the file unreached"
1058
1014
  );
@@ -1076,7 +1032,7 @@ mod tests {
1076
1032
  .map(|metadata| metadata.file_type),
1077
1033
  overlay.open_dir("dirlink").map(drop)
1078
1034
  ),
1079
- (Ok(FileType::Symlink), Err(FilesystemError::FilesystemLoop)),
1035
+ (Ok(FileType::Symlink), Err(Errno::FilesystemLoop)),
1080
1036
  "a directory a higher Bind Layer holds as a link, looked up and opened through an \
1081
1037
  Overlay, must stand as the link, so none of a lower Layer's entries beneath it show"
1082
1038
  );
@@ -1096,7 +1052,7 @@ mod tests {
1096
1052
  overlay.vfs_lstat("f").err(),
1097
1053
  on(&lower).vfs_lstat("f/g").is_ok()
1098
1054
  ),
1099
- (Ok(()), Some(FilesystemError::NotFound), true),
1055
+ (Ok(()), Some(Errno::NotFound), true),
1100
1056
  "a file a higher Layer holds over a lower Layer's directory, removed through \
1101
1057
  vfs_unlink, must leave the path gone from the view and the lower \
1102
1058
  directory as it was"
@@ -1150,7 +1106,7 @@ mod tests {
1150
1106
  .and_then(|dir| dir.iterate_dir())
1151
1107
  .map(|entries| entries.len())
1152
1108
  ),
1153
- (Ok(()), Some(FilesystemError::NotFound), Ok(0)),
1109
+ (Ok(()), Some(Errno::NotFound), Ok(0)),
1154
1110
  "a directory made again through an Overlay where a lower Layer's one was removed, \
1155
1111
  renamed through Overlay::rename, must move and leave nothing of the lower one behind"
1156
1112
  );
@@ -1162,7 +1118,7 @@ mod tests {
1162
1118
  let (overlay, _) = overlay_on(Arc::new(Tmpfs::new()));
1163
1119
  assert_eq!(
1164
1120
  overlay.rename("dir/file", &overlay, "dir/file/x"),
1165
- Err(FilesystemError::NotADirectory),
1121
+ Err(Errno::NotADirectory),
1166
1122
  "a file renamed through Overlay::rename to a path beneath itself must be refused as \
1167
1123
  no directory, as rename(2) refuses it"
1168
1124
  );
@@ -1185,10 +1141,7 @@ mod tests {
1185
1141
  overlay.create("dangling", &exclusive).map(drop),
1186
1142
  overlay.vfs_mkdir("dangling")
1187
1143
  ),
1188
- (
1189
- Err(FilesystemError::AlreadyExists),
1190
- Err(FilesystemError::AlreadyExists)
1191
- ),
1144
+ (Err(Errno::AlreadyExists), Err(Errno::AlreadyExists)),
1192
1145
  "an exclusive create and a create_dir at a dangling link a lower Bind Layer \
1193
1146
  holds, through an Overlay, must find it already there"
1194
1147
  );
@@ -1242,7 +1195,7 @@ mod tests {
1242
1195
  .expect("the file must be removed");
1243
1196
  assert_eq!(
1244
1197
  overlay.vfs_lstat("dir/file"),
1245
- Err(FilesystemError::NotFound),
1198
+ Err(Errno::NotFound),
1246
1199
  "a lower file removed through vfs_unlink must no longer be found there"
1247
1200
  );
1248
1201
  }
@@ -1283,7 +1236,7 @@ mod tests {
1283
1236
  overwrite(&overlay, "new", b"made");
1284
1237
  assert_eq!(
1285
1238
  (read(&on(&upper), "upper/new"), on(&lower).vfs_lstat("new")),
1286
- (b"made".to_vec(), Err(FilesystemError::NotFound)),
1239
+ (b"made".to_vec(), Err(Errno::NotFound)),
1287
1240
  "a file created through Overlay::open must land in the upper alone"
1288
1241
  );
1289
1242
  }
@@ -1316,7 +1269,7 @@ mod tests {
1316
1269
  let lower = Arc::new([("dir/old", "x")].into_iter().collect::<Tmpfs>());
1317
1270
  let overlay = Arc::new(over(lower.clone(), Arc::new(Tmpfs::new())));
1318
1271
  let filesystem = Filesystem::new(overlay.clone()).expect("the instance must stand");
1319
- let root = filesystem.s_root();
1272
+ let root = filesystem.root().expect(crate::vfs::MADE_ROOT).clone();
1320
1273
  let dir = lookup_one_unlocked(&Default::default(), &filesystem, &root, "dir")
1321
1274
  .expect("the directory must be found");
1322
1275
  let layer = on(&lower);
@@ -1356,7 +1309,7 @@ mod tests {
1356
1309
  let lower = Arc::new([("dir/file", "x")].into_iter().collect::<Tmpfs>());
1357
1310
  let overlay = Arc::new(over(lower, Arc::new(Tmpfs::new())));
1358
1311
  let filesystem = Filesystem::new(overlay.clone()).expect("the instance must stand");
1359
- let root = filesystem.s_root();
1312
+ let root = filesystem.root().expect(crate::vfs::MADE_ROOT).clone();
1360
1313
  let dir = lookup_one_unlocked(&Default::default(), &filesystem, &root, "dir")
1361
1314
  .expect("the directory must be found");
1362
1315
  let file = lookup_one_unlocked(&Default::default(), &filesystem, &dir, "file")
@@ -1398,7 +1351,7 @@ mod tests {
1398
1351
  let rebuilt = at(over(lower, upper));
1399
1352
  assert_eq!(
1400
1353
  rebuilt.vfs_lstat("dir/file"),
1401
- Err(FilesystemError::NotFound),
1354
+ Err(Errno::NotFound),
1402
1355
  "a lower file removed through an Overlay over a Tmpfs must stay gone from a new Overlay over the same Layers"
1403
1356
  );
1404
1357
  }
@@ -1460,7 +1413,7 @@ mod tests {
1460
1413
  });
1461
1414
  assert_ne!(
1462
1415
  answered,
1463
- Some(FilesystemError::Interrupted),
1416
+ Some(Errno::Interrupted),
1464
1417
  "vfs::filename_renameat2 through an Overlay whose upper another Mount changed must \
1465
1418
  answer within its bound"
1466
1419
  );
@@ -1507,7 +1460,7 @@ mod tests {
1507
1460
  let overlay = lowers(tmpfs_with("dir/file", "lower"), Arc::new(Tmpfs::new()));
1508
1461
  let mount = crate::mount::Mount::new(
1509
1462
  "/data",
1510
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
1463
+ Filesystem::new(overlay).expect("the instance must stand"),
1511
1464
  crate::mount::Access::ReadWrite,
1512
1465
  )
1513
1466
  .expect("/data is a guest path");
@@ -1526,7 +1479,7 @@ mod tests {
1526
1479
  let written = crate::vfs::kern_path::filp_open(&Arc::default(), &root, "dir/file", &how);
1527
1480
  assert_eq!(
1528
1481
  (written.err(), mount.mnt().is_readonly()),
1529
- (Some(FilesystemError::ReadOnlyFilesystem), true),
1482
+ (Some(Errno::ReadOnlyFilesystem), true),
1530
1483
  "a file opened to write through an Overlay with no upper on a read-write Mount must \
1531
1484
  be refused as read-only"
1532
1485
  );
@@ -1537,13 +1490,9 @@ mod tests {
1537
1490
  struct RefusesLongName;
1538
1491
 
1539
1492
  impl crate::filesystem::wrap::Hook for RefusesLongName {
1540
- fn lookup(
1541
- &self,
1542
- inner: &dyn InodeOperations,
1543
- dentry: &Dentry,
1544
- ) -> Result<Lookup, FilesystemError> {
1493
+ fn lookup(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Lookup, Errno> {
1545
1494
  match dentry.name().as_str() {
1546
- "long" => Err(FilesystemError::InvalidFilename),
1495
+ "long" => Err(Errno::InvalidFilename),
1547
1496
  _ => inner.lookup(dentry),
1548
1497
  }
1549
1498
  }
@@ -1633,11 +1582,7 @@ mod tests {
1633
1582
  read(&overlay, "b"),
1634
1583
  std::fs::read(host.0.join("b")).expect("the host file must be read"),
1635
1584
  ),
1636
- (
1637
- Err(FilesystemError::NotFound),
1638
- b"two".to_vec(),
1639
- b"one".to_vec()
1640
- ),
1585
+ (Err(Errno::NotFound), b"two".to_vec(), b"one".to_vec()),
1641
1586
  "a hard link in a lower Layer written and moved onto its other name through an \
1642
1587
  Overlay must leave only the new name, holding what was written, and the lower Layer \
1643
1588
  as it was"
@@ -1652,7 +1597,7 @@ mod tests {
1652
1597
  use crate::vfs::{filename_renameat2, filename_rmdir, filename_unlinkat};
1653
1598
  let (_mount, root) = mounted_with_no_upper();
1654
1599
  let cred = Arc::default();
1655
- let read_only = || Err(FilesystemError::ReadOnlyFilesystem);
1600
+ let read_only = || Err(Errno::ReadOnlyFilesystem);
1656
1601
  assert_eq!(
1657
1602
  (
1658
1603
  filename_renameat2(&cred, &root, "dir/file", &root, "dir/file"),
@@ -1669,7 +1614,7 @@ mod tests {
1669
1614
  fn refusal(
1670
1615
  lower: Vec<Arc<dyn FileSystemType>>,
1671
1616
  upper: Option<Arc<dyn FileSystemType>>,
1672
- ) -> Option<FilesystemError> {
1617
+ ) -> Option<Errno> {
1673
1618
  let instance = |fs| Filesystem::new(fs).expect("the instance must stand");
1674
1619
  Overlay::new(
1675
1620
  lower.into_iter().map(instance).collect(),
@@ -1687,7 +1632,7 @@ mod tests {
1687
1632
  let bind = super::super::Bind::new(&host).expect("the host directory must open");
1688
1633
  assert_eq!(
1689
1634
  refusal(vec![Arc::new(Tmpfs::new())], Some(Arc::new(bind))),
1690
- Some(FilesystemError::InvalidInput),
1635
+ Some(Errno::InvalidInput),
1691
1636
  "Overlay::new with a Bind as its upper must be refused as invalid input"
1692
1637
  );
1693
1638
  }
@@ -1697,17 +1642,14 @@ mod tests {
1697
1642
  // @behavior FS-148
1698
1643
  #[test]
1699
1644
  fn an_overlay_refuses_one_instance_as_two_layers() {
1700
- let instance = || Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand");
1645
+ let instance = || Filesystem::new(Tmpfs::new()).expect("the instance must stand");
1701
1646
  let (shared, doubled) = (instance(), instance());
1702
1647
  assert_eq!(
1703
1648
  (
1704
1649
  Overlay::new(vec![shared.clone()], Some(shared)).err(),
1705
1650
  Overlay::new(vec![doubled.clone(), doubled, instance()], None).err(),
1706
1651
  ),
1707
- (
1708
- Some(FilesystemError::InvalidInput),
1709
- Some(FilesystemError::InvalidInput),
1710
- ),
1652
+ (Some(Errno::InvalidInput), Some(Errno::InvalidInput),),
1711
1653
  "Overlay::new with one instance as its upper and a lower Layer, or as two lower \
1712
1654
  Layers, must be refused as invalid input"
1713
1655
  );
@@ -1718,7 +1660,7 @@ mod tests {
1718
1660
  fn an_overlay_without_an_upper_needs_two_lower_layers() {
1719
1661
  assert_eq!(
1720
1662
  refusal(vec![Arc::new(Tmpfs::new())], None),
1721
- Some(FilesystemError::InvalidInput),
1663
+ Some(Errno::InvalidInput),
1722
1664
  "Overlay::new with one lower Layer and no upper must be refused as invalid input"
1723
1665
  );
1724
1666
  }
@@ -1735,7 +1677,7 @@ mod tests {
1735
1677
  refusal(vec![first], Some(Arc::new(Tmpfs::new()))),
1736
1678
  refusal(vec![second], Some(Arc::new(Tmpfs::new())))
1737
1679
  ),
1738
- (None, Some(FilesystemError::InvalidInput)),
1680
+ (None, Some(Errno::InvalidInput)),
1739
1681
  "Overlay::new over an Overlay must make a view, and over an Overlay over an Overlay \
1740
1682
  must be refused as invalid input"
1741
1683
  );
@@ -1751,7 +1693,7 @@ mod tests {
1751
1693
  };
1752
1694
  assert_eq!(
1753
1695
  (refusal(layers(500), None), refusal(layers(501), None)),
1754
- (None, Some(FilesystemError::InvalidInput)),
1696
+ (None, Some(Errno::InvalidInput)),
1755
1697
  "Overlay::new must take 500 lower Layers and refuse 501 as invalid input"
1756
1698
  );
1757
1699
  }
@@ -1761,7 +1703,7 @@ mod tests {
1761
1703
  fn an_overlay_needs_a_lower_layer() {
1762
1704
  assert_eq!(
1763
1705
  refusal(Vec::new(), Some(Arc::new(Tmpfs::new()))),
1764
- Some(FilesystemError::InvalidInput),
1706
+ Some(Errno::InvalidInput),
1765
1707
  "Overlay::new with an upper and no lower Layer must be refused as invalid input"
1766
1708
  );
1767
1709
  }
@@ -1786,11 +1728,7 @@ mod tests {
1786
1728
  overlay.vfs_lstat("dir/file"),
1787
1729
  read(&on(&lower), "dir/file"),
1788
1730
  ),
1789
- (
1790
- b"lower".to_vec(),
1791
- Err(FilesystemError::NotFound),
1792
- b"lower".to_vec()
1793
- ),
1731
+ (b"lower".to_vec(), Err(Errno::NotFound), b"lower".to_vec()),
1794
1732
  );
1795
1733
  }
1796
1734
 
@@ -1838,8 +1776,8 @@ mod tests {
1838
1776
  inner: &dyn InodeOperations,
1839
1777
  dentry: &Dentry,
1840
1778
  how: &OpenHow,
1841
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
1842
- if dentry.kind() == Ok(FileType::Dir) && !dentry.is_root() {
1779
+ ) -> Result<Box<dyn FileOperations>, Errno> {
1780
+ if dentry.file_type() == Ok(FileType::Dir) && !dentry.is_root() {
1843
1781
  self.start();
1844
1782
  }
1845
1783
  inner.open(dentry, how)
@@ -1859,10 +1797,10 @@ mod tests {
1859
1797
  .expect("the seed must go");
1860
1798
  let mount = crate::mount::Mount::new(
1861
1799
  "/data",
1862
- Filesystem::new(Arc::new(over(
1800
+ Filesystem::new(over(
1863
1801
  Arc::new(Wrap::new(tmpfs, interleave.clone())),
1864
1802
  Arc::new(Tmpfs::new()),
1865
- )))
1803
+ ))
1866
1804
  .expect("the instance must stand"),
1867
1805
  crate::mount::Access::ReadWrite,
1868
1806
  )
@@ -1892,7 +1830,7 @@ mod tests {
1892
1830
  // @behavior FS-038
1893
1831
  #[test]
1894
1832
  fn a_change_through_an_overlay_from_inside_one_answers_a_deadlock() {
1895
- type Answers = (bool, Result<(), FilesystemError>);
1833
+ type Answers = (bool, Result<(), Errno>);
1896
1834
 
1897
1835
  struct Reenters {
1898
1836
  overlay: Mutex<Option<crate::vfs::Path>>,
@@ -1904,7 +1842,7 @@ mod tests {
1904
1842
  &self,
1905
1843
  inner: &dyn InodeOperations,
1906
1844
  dentry: &Dentry,
1907
- ) -> Result<Kstat, FilesystemError> {
1845
+ ) -> Result<Kstat, Errno> {
1908
1846
  let reentering = self.overlay.lock().unwrap().take();
1909
1847
  if let Some(overlay) = reentering {
1910
1848
  *self.answer.lock().unwrap() = Some((
@@ -1924,10 +1862,10 @@ mod tests {
1924
1862
  let tmpfs: Tmpfs = [("note", "x")].into_iter().collect();
1925
1863
  let mount = crate::mount::Mount::new(
1926
1864
  "/data",
1927
- Filesystem::new(Arc::new(over(
1865
+ Filesystem::new(over(
1928
1866
  Arc::new(Wrap::new(Arc::new(tmpfs), layer.clone())),
1929
1867
  Arc::new(Tmpfs::new()),
1930
- )))
1868
+ ))
1931
1869
  .expect("the instance must stand"),
1932
1870
  crate::mount::Access::ReadWrite,
1933
1871
  )
@@ -1939,7 +1877,7 @@ mod tests {
1939
1877
  let answers = layer.answer.lock().unwrap().take();
1940
1878
  assert_eq!(
1941
1879
  answers,
1942
- Some((true, Err(FilesystemError::Deadlock))),
1880
+ Some((true, Err(Errno::Deadlock))),
1943
1881
  "a read through an Overlay made from inside one of its own reads on the same thread \
1944
1882
  must answer, and a change must answer Deadlock rather than wait forever"
1945
1883
  );
@@ -1968,7 +1906,7 @@ mod tests {
1968
1906
  let (overlay, _) = full_over_lower(&[("dir/file", "upper")], 2);
1969
1907
  assert_eq!(
1970
1908
  (overlay.vfs_unlink("dir/file"), read(&overlay, "dir/file")),
1971
- (Err(FilesystemError::StorageFull), b"upper".to_vec()),
1909
+ (Err(Errno::StorageFull), b"upper".to_vec()),
1972
1910
  "a file removed through vfs_unlink whose whiteout finds no room must stay as \
1973
1911
  it was"
1974
1912
  );
@@ -1990,10 +1928,7 @@ mod tests {
1990
1928
  .expect("the directory must be removed");
1991
1929
  assert_eq!(
1992
1930
  (overlay.vfs_mkdir("gone"), overlay.vfs_lstat("gone")),
1993
- (
1994
- Err(FilesystemError::StorageFull),
1995
- Err(FilesystemError::NotFound)
1996
- ),
1931
+ (Err(Errno::StorageFull), Err(Errno::NotFound)),
1997
1932
  "a directory made through vfs_mkdir over a whiteout, with no room left, \
1998
1933
  must be refused as out of space and leave the name hidden"
1999
1934
  );
@@ -2012,8 +1947,8 @@ mod tests {
2012
1947
  read(&overlay, "dir/file")
2013
1948
  ),
2014
1949
  (
2015
- Err(FilesystemError::StorageFull),
2016
- Err(FilesystemError::NotFound),
1950
+ Err(Errno::StorageFull),
1951
+ Err(Errno::NotFound),
2017
1952
  b"lower".to_vec()
2018
1953
  ),
2019
1954
  "a file renamed through Overlay::rename whose whiteout finds no room must stay where \
@@ -2030,10 +1965,7 @@ mod tests {
2030
1965
  overlay.rename("dir", &overlay, "moved"),
2031
1966
  overlay.vfs_lstat("moved")
2032
1967
  ),
2033
- (
2034
- Err(FilesystemError::CrossesDevices),
2035
- Err(FilesystemError::NotFound)
2036
- ),
1968
+ (Err(Errno::CrossesDevices), Err(Errno::NotFound)),
2037
1969
  "a directory a lower Layer holds renamed through Overlay::rename must be refused \
2038
1970
  as crossing devices, as overlayfs refuses it"
2039
1971
  );
@@ -2057,8 +1989,8 @@ mod tests {
2057
1989
  read(&overlay, "dir/file")
2058
1990
  ),
2059
1991
  (
2060
- Err(FilesystemError::IsADirectory),
2061
- Err(FilesystemError::DirectoryNotEmpty),
1992
+ Err(Errno::IsADirectory),
1993
+ Err(Errno::DirectoryNotEmpty),
2062
1994
  b"lower".to_vec()
2063
1995
  ),
2064
1996
  "a rename through Overlay::rename onto a directory only a lower Layer shows must \
@@ -2129,7 +2061,7 @@ mod tests {
2129
2061
  .expect("the emptied directory must be removed");
2130
2062
  assert_eq!(
2131
2063
  (names(&on(&upper), "work"), kind(&overlay, "dir")),
2132
- (Vec::<String>::new(), Err(FilesystemError::NotFound)),
2064
+ (Vec::<String>::new(), Err(Errno::NotFound)),
2133
2065
  "vfs_rmdir of a lower directory whose file vfs_unlink removed \
2134
2066
  must leave the upper Tmpfs's work empty and the directory gone"
2135
2067
  );
@@ -2196,9 +2128,9 @@ mod tests {
2196
2128
  /// An Overlay over an empty lower Layer under the Tmpfs `upper`, and
2197
2129
  /// that same Tmpfs mounted on its own, each reached through the VFS.
2198
2130
  fn beside_its_upper(upper: Tmpfs) -> (crate::vfs::Path, crate::vfs::Path) {
2199
- let upper = Filesystem::new(Arc::new(upper)).expect("the instance must stand");
2131
+ let upper = Filesystem::new(upper).expect("the instance must stand");
2200
2132
  let overlay = Overlay::new(
2201
- vec![Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")],
2133
+ vec![Filesystem::new(Tmpfs::new()).expect("the instance must stand")],
2202
2134
  Some(upper.clone()),
2203
2135
  )
2204
2136
  .expect("an upper over a lower Layer must make a view");
@@ -2209,7 +2141,7 @@ mod tests {
2209
2141
  crate::vfs::Path::root(mount.mnt())
2210
2142
  };
2211
2143
  (
2212
- root(Filesystem::new(Arc::new(overlay)).expect("the instance must stand")),
2144
+ root(Filesystem::new(overlay).expect("the instance must stand")),
2213
2145
  root(upper),
2214
2146
  )
2215
2147
  }
@@ -2259,46 +2191,6 @@ mod tests {
2259
2191
  );
2260
2192
  }
2261
2193
 
2262
- // The make holds only the directory it makes in, so only the removal
2263
- // holding that directory too, and removing it only once empty, keeps
2264
- // what the make made from going with it. The two land in the same
2265
- // instant only a few times in this many tries.
2266
- // @behavior FS-132
2267
- #[test]
2268
- fn a_removal_through_an_overlay_waits_for_a_change_in_that_directory() {
2269
- let (overlay, upper) = beside_its_upper([("upper/a/.keep", "")].into_iter().collect());
2270
- let stop = Arc::new(AtomicBool::new(false));
2271
- let churning = {
2272
- let stop = stop.clone();
2273
- thread::spawn(move || {
2274
- while !stop.load(Ordering::SeqCst) {
2275
- let _ = crate::vfs::filename_mkdirat(&Arc::default(), &overlay, "a/b");
2276
- let _ = crate::vfs::filename_rmdir(&Arc::default(), &overlay, "a/b");
2277
- }
2278
- })
2279
- };
2280
- let mut lost = 0;
2281
- for _ in 0..100_000 {
2282
- if crate::vfs::filename_mkdirat(&Arc::default(), &upper, "upper/a/b/made").is_ok() {
2283
- match crate::vfs::vfs_fstatat(&Arc::default(), &upper, "upper/a/b/made", false) {
2284
- Ok(_) => {
2285
- let _ =
2286
- crate::vfs::filename_rmdir(&Arc::default(), &upper, "upper/a/b/made");
2287
- }
2288
- Err(_) => lost += 1,
2289
- }
2290
- }
2291
- }
2292
- stop.store(true, Ordering::SeqCst);
2293
- churning.join().expect("the Overlay's calls must not panic");
2294
- assert_eq!(
2295
- lost, 0,
2296
- "vfs::filename_mkdirat in a directory through a Mount of an Overlay's upper Tmpfs, while \
2297
- vfs::filename_rmdir removes that directory through the Overlay, must leave every \
2298
- directory it made standing"
2299
- );
2300
- }
2301
-
2302
2194
  // The upper has room for the copy's entry but for less than
2303
2195
  // the lower file's bytes, so the copy fails part way.
2304
2196
  // @behavior FS-046
@@ -2313,8 +2205,8 @@ mod tests {
2313
2205
  read(&overlay, "dir/file")
2314
2206
  ),
2315
2207
  (
2316
- Err(FilesystemError::StorageFull),
2317
- Err(FilesystemError::NotFound),
2208
+ Err(Errno::StorageFull),
2209
+ Err(Errno::NotFound),
2318
2210
  b"lower".to_vec()
2319
2211
  ),
2320
2212
  "a write through Overlay::open whose copy up runs out of room must leave no partial \
@@ -2322,18 +2214,71 @@ mod tests {
2322
2214
  );
2323
2215
  }
2324
2216
 
2217
+ // The run's deadline has passed before the write asks, so the copy up
2218
+ // stops before its first chunk.
2219
+ // @behavior FS-213
2220
+ #[test]
2221
+ fn a_copy_up_past_its_runs_deadline_answers_eintr() {
2222
+ let upper = Arc::new(Tmpfs::new());
2223
+ let (overlay, _) = overlay_on(upper.clone());
2224
+ let written = crate::sched::run_task(Some(std::time::Instant::now()), || {
2225
+ write_over(&overlay, "dir/file", b"x")
2226
+ });
2227
+ assert_eq!(
2228
+ (
2229
+ written,
2230
+ on(&upper).vfs_lstat("upper/dir/file"),
2231
+ read(&overlay, "dir/file")
2232
+ ),
2233
+ (
2234
+ Err(Errno::Interrupted),
2235
+ Err(Errno::NotFound),
2236
+ b"lower".to_vec()
2237
+ ),
2238
+ "a write through Overlay::open whose run's deadline passed must answer EINTR before \
2239
+ copying, and leave the lower file showing"
2240
+ );
2241
+ }
2242
+
2243
+ /// A Tmpfs reporting `file` two bytes long, though it holds more.
2244
+ struct ReportsTwoBytes;
2245
+
2246
+ impl Hook for ReportsTwoBytes {
2247
+ fn getattr(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Kstat, Errno> {
2248
+ let mut stat = inner.getattr(dentry)?;
2249
+ if dentry.name() == "file" {
2250
+ stat.size = 2;
2251
+ }
2252
+ Ok(stat)
2253
+ }
2254
+ }
2255
+
2256
+ // The lower file reads past the size its stat reported, as one growing
2257
+ // while it is copied does.
2258
+ // @behavior FS-214
2259
+ #[test]
2260
+ fn a_copy_up_takes_the_size_the_lower_file_reported() {
2261
+ let tmpfs: Tmpfs = [("file", "lower")].into_iter().collect();
2262
+ let lower = Wrap::new(Arc::new(tmpfs), Arc::new(ReportsTwoBytes));
2263
+ let upper = Arc::new(Tmpfs::new());
2264
+ let overlay = at(over(Arc::new(lower), upper.clone()));
2265
+ write_over(&overlay, "file", b"L").expect("the copy up and the write must land");
2266
+ assert_eq!(
2267
+ read(&on(&upper), "upper/file"),
2268
+ b"Lo".to_vec(),
2269
+ "a lower file copied up through Overlay::open must bring the bytes its stat reported, \
2270
+ not all it reads"
2271
+ );
2272
+ }
2273
+
2325
2274
  /// A Tmpfs answering a stat of `dir` at any depth with an I/O failure,
2326
2275
  /// though it opens `dir` as any other directory.
2327
2276
  struct StatsNoDir;
2328
2277
 
2329
2278
  impl Hook for StatsNoDir {
2330
- fn getattr(
2331
- &self,
2332
- inner: &dyn InodeOperations,
2333
- dentry: &Dentry,
2334
- ) -> Result<Kstat, FilesystemError> {
2279
+ fn getattr(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Kstat, Errno> {
2335
2280
  if dentry.name() == "dir" {
2336
- return Err(FilesystemError::Other("dir has no stat".to_string()));
2281
+ return Err(Errno::Other("dir has no stat".to_string()));
2337
2282
  }
2338
2283
  inner.getattr(dentry)
2339
2284
  }
@@ -2347,13 +2292,9 @@ mod tests {
2347
2292
  }
2348
2293
 
2349
2294
  impl Hook for Vanishes {
2350
- fn getattr(
2351
- &self,
2352
- inner: &dyn InodeOperations,
2353
- dentry: &Dentry,
2354
- ) -> Result<Kstat, FilesystemError> {
2295
+ fn getattr(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Kstat, Errno> {
2355
2296
  if dentry.name() == "file" && self.seen.swap(true, Ordering::SeqCst) {
2356
- return Err(FilesystemError::NotFound);
2297
+ return Err(Errno::NotFound);
2357
2298
  }
2358
2299
  inner.getattr(dentry)
2359
2300
  }
@@ -2386,28 +2327,28 @@ mod tests {
2386
2327
  &mut self,
2387
2328
  dentry: &Dentry,
2388
2329
  ctx: &mut DirContext<'_>,
2389
- ) -> Result<(), FilesystemError> {
2330
+ ) -> Result<(), Errno> {
2390
2331
  let entries = match folded_path_of(dentry).as_str() {
2391
2332
  "" => self.0.iterate_dir(),
2392
2333
  at => self.0.open_dir(at)?.iterate_dir(),
2393
2334
  }?;
2394
- crate::filesystem::Rdir::default().iterate(dentry, ctx, || Ok(entries))
2335
+ crate::filesystem::Rdir::default().iterate_shared(dentry, ctx, || Ok(entries))
2395
2336
  }
2396
2337
  }
2397
2338
 
2398
2339
  impl FileSystemType for FoldsCase {
2399
- fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), FilesystemError> {
2340
+ fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
2400
2341
  sb.d_make_root(Inode::new(&Kstat::new(FileType::Dir, 0), self));
2401
2342
  Ok(())
2402
2343
  }
2403
2344
  }
2404
2345
 
2405
2346
  impl InodeOperations for FoldsCase {
2406
- fn getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
2347
+ fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
2407
2348
  self.root.vfs_lstat(&folded_path_of(dentry))
2408
2349
  }
2409
2350
 
2410
- fn lookup(&self, dentry: &Dentry) -> Result<Lookup, FilesystemError> {
2351
+ fn lookup(&self, dentry: &Dentry) -> Result<Lookup, Errno> {
2411
2352
  let name = dentry.name();
2412
2353
  let lower = name.to_lowercase();
2413
2354
  match self.root.vfs_lstat(&folded_path_of(dentry)) {
@@ -2416,23 +2357,19 @@ mod tests {
2416
2357
  inode: Inode::new(&found, Arc::new(self.clone())),
2417
2358
  }),
2418
2359
  Ok(found) => Ok(Lookup::Found(Inode::new(&found, Arc::new(self.clone())))),
2419
- Err(FilesystemError::NotFound) => Ok(Lookup::Absent),
2360
+ Err(Errno::NotFound) => Ok(Lookup::Absent),
2420
2361
  Err(err) => Err(err),
2421
2362
  }
2422
2363
  }
2423
2364
 
2424
- fn open(
2425
- &self,
2426
- dentry: &Dentry,
2427
- how: &OpenHow,
2428
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
2429
- if dentry.kind() == Ok(FileType::Dir) {
2365
+ fn open(&self, dentry: &Dentry, how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
2366
+ if dentry.file_type() == Ok(FileType::Dir) {
2430
2367
  return Ok(Box::new(FoldedDir(self.root.clone())));
2431
2368
  }
2432
2369
  self.root.open(&folded_path_of(dentry), how)
2433
2370
  }
2434
2371
 
2435
- fn atomic_open(&self, dentry: &Dentry, how: &OpenHow) -> Result<Finish, FilesystemError> {
2372
+ fn atomic_open(&self, dentry: &Dentry, how: &OpenHow) -> Result<Finish, Errno> {
2436
2373
  if dentry.in_lookup() {
2437
2374
  let found = self.lookup(dentry)?;
2438
2375
  if !how.create || !matches!(found, Lookup::Absent) {
@@ -2449,32 +2386,32 @@ mod tests {
2449
2386
  })
2450
2387
  }
2451
2388
 
2452
- fn mkdir(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
2389
+ fn mkdir(&self, dentry: &Dentry) -> Result<(), Errno> {
2453
2390
  self.root.vfs_mkdir(&folded_path_of(dentry))
2454
2391
  }
2455
2392
 
2456
- fn rmdir(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
2393
+ fn rmdir(&self, dentry: &Dentry) -> Result<(), Errno> {
2457
2394
  self.root.vfs_rmdir(&folded_path_of(dentry))
2458
2395
  }
2459
2396
 
2460
- fn unlink(&self, dentry: &Dentry) -> Result<(), FilesystemError> {
2397
+ fn unlink(&self, dentry: &Dentry) -> Result<(), Errno> {
2461
2398
  self.root.vfs_unlink(&folded_path_of(dentry))
2462
2399
  }
2463
2400
 
2464
2401
  fn rename(
2465
2402
  &self,
2466
- from: &Dentry,
2467
- _to_dir: &dyn InodeOperations,
2468
- to: &Dentry,
2469
- _flag: Option<RenameFlag>,
2470
- ) -> Result<(), FilesystemError> {
2403
+ old: &Dentry,
2404
+ _new_dir: &dyn InodeOperations,
2405
+ new: &Dentry,
2406
+ _flags: Option<RenameFlag>,
2407
+ ) -> Result<(), Errno> {
2471
2408
  self.root
2472
- .rename(&folded_path_of(from), &self.root, &folded_path_of(to))
2409
+ .rename(&folded_path_of(old), &self.root, &folded_path_of(new))
2473
2410
  }
2474
2411
  }
2475
2412
 
2476
2413
  /// What `path` names through `fs`, or why it names nothing.
2477
- fn kind(fs: &KernPath, path: &str) -> Result<FileType, FilesystemError> {
2414
+ fn kind(fs: &KernPath, path: &str) -> Result<FileType, Errno> {
2478
2415
  fs.vfs_lstat(path).map(|metadata| metadata.file_type)
2479
2416
  }
2480
2417
 
@@ -2504,7 +2441,7 @@ mod tests {
2504
2441
  (
2505
2442
  Ok(FileType::RegFile),
2506
2443
  Ok(FileType::RegFile),
2507
- Err(FilesystemError::NotFound)
2444
+ Err(Errno::NotFound)
2508
2445
  ),
2509
2446
  "files made through directories Overlay::open_dir opened before Overlay::rename moved \
2510
2447
  the outer one must stand beneath its new path"
@@ -2525,7 +2462,7 @@ mod tests {
2525
2462
  dir.iterate_dir().map(|entries| entries.len()),
2526
2463
  names(&overlay, "dir").len()
2527
2464
  ),
2528
- (Err(FilesystemError::NotFound), Ok(0), 0),
2465
+ (Err(Errno::NotFound), Ok(0), 0),
2529
2466
  "a directory Overlay::open_dir opened, once vfs_rmdir removed it and another \
2530
2467
  was made in its place, must make nothing, list nothing, and leave the new one empty"
2531
2468
  );
@@ -2569,7 +2506,7 @@ mod tests {
2569
2506
  inner: &dyn InodeOperations,
2570
2507
  dentry: &Dentry,
2571
2508
  how: &OpenHow,
2572
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
2509
+ ) -> Result<Box<dyn FileOperations>, Errno> {
2573
2510
  let opened = inner.open(dentry, how);
2574
2511
  let run = self.0.lock().expect("never poisoned").take();
2575
2512
  if let Some(run) = run {
@@ -2610,14 +2547,13 @@ mod tests {
2610
2547
  use crate::vfs::{self, OpenHow, Path};
2611
2548
  let asked = Arc::new(AtomicUsize::new(0));
2612
2549
  let overlay = Overlay::new(
2613
- vec![Filesystem::new(Arc::new(KeepsTimes(asked.clone())))
2614
- .expect("the instance must stand")],
2615
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2550
+ vec![Filesystem::new(KeepsTimes(asked.clone())).expect("the instance must stand")],
2551
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
2616
2552
  )
2617
2553
  .expect("the Overlay must stack");
2618
2554
  let mount = Mount::new(
2619
2555
  "/data",
2620
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2556
+ Filesystem::new(overlay).expect("the instance must stand"),
2621
2557
  Access::ReadWrite,
2622
2558
  )
2623
2559
  .expect("/data is a guest path");
@@ -2641,11 +2577,11 @@ mod tests {
2641
2577
  let answer = vfs::do_utimes_fd(
2642
2578
  &cred,
2643
2579
  held.path(),
2644
- &Iattr::times(None, Some(crate::vfs::SetTime::Now)),
2580
+ &Iattr::for_times(None, Some(crate::vfs::SetTime::Now)),
2645
2581
  );
2646
2582
  assert_eq!(
2647
2583
  (answer, asked.load(Ordering::SeqCst)),
2648
- (Err(FilesystemError::AlreadyExists), 0),
2584
+ (Err(Errno::AlreadyExists), 0),
2649
2585
  "vfs::do_utimes_fd on a held lower file whose name another entry took must answer \
2650
2586
  EEXIST and leave the lower Layer unasked"
2651
2587
  );
@@ -2660,13 +2596,13 @@ mod tests {
2660
2596
  use crate::vfs::{self, OpenHow, Path};
2661
2597
  let lower: Tmpfs = [("d/f", "removed")].into_iter().collect();
2662
2598
  let overlay = Overlay::new(
2663
- vec![Filesystem::new(Arc::new(lower)).expect("the instance must stand")],
2664
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2599
+ vec![Filesystem::new(lower).expect("the instance must stand")],
2600
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
2665
2601
  )
2666
2602
  .expect("the Overlay must stack");
2667
2603
  let mount = Mount::new(
2668
2604
  "/data",
2669
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2605
+ Filesystem::new(overlay).expect("the instance must stand"),
2670
2606
  Access::ReadWrite,
2671
2607
  )
2672
2608
  .expect("/data is a guest path");
@@ -2684,17 +2620,14 @@ mod tests {
2684
2620
  let answer = vfs::do_utimes_fd(
2685
2621
  &cred,
2686
2622
  held.path(),
2687
- &Iattr::times(None, Some(crate::vfs::SetTime::Now)),
2623
+ &Iattr::for_times(None, Some(crate::vfs::SetTime::Now)),
2688
2624
  );
2689
2625
  assert_eq!(
2690
2626
  (
2691
2627
  answer,
2692
2628
  vfs::vfs_fstatat(&cred, &root, "d/f", false).map(|_| ())
2693
2629
  ),
2694
- (
2695
- Err(FilesystemError::NotFound),
2696
- Err(FilesystemError::NotFound)
2697
- ),
2630
+ (Err(Errno::NotFound), Err(Errno::NotFound)),
2698
2631
  "vfs::do_utimes_fd on a held lower file whose directory was removed and made again \
2699
2632
  must answer ENOENT and leave the file out of the view"
2700
2633
  );
@@ -2705,11 +2638,7 @@ mod tests {
2705
2638
  struct SlowsDirectory(AtomicBool);
2706
2639
 
2707
2640
  impl Hook for SlowsDirectory {
2708
- fn getattr(
2709
- &self,
2710
- inner: &dyn InodeOperations,
2711
- dentry: &Dentry,
2712
- ) -> Result<Kstat, FilesystemError> {
2641
+ fn getattr(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Kstat, Errno> {
2713
2642
  if dentry.name() == "e" && self.0.swap(false, Ordering::SeqCst) {
2714
2643
  thread::sleep(Duration::from_millis(100));
2715
2644
  }
@@ -2728,16 +2657,14 @@ mod tests {
2728
2657
  let lower: Tmpfs = [("d/e/f", "1"), ("d/e/g", "2")].into_iter().collect();
2729
2658
  let hook = Arc::new(SlowsDirectory(AtomicBool::new(false)));
2730
2659
  let overlay = Overlay::new(
2731
- vec![
2732
- Filesystem::new(Arc::new(Wrap::new(Arc::new(lower), hook.clone())))
2733
- .expect("the instance must stand"),
2734
- ],
2735
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2660
+ vec![Filesystem::new(Wrap::new(Arc::new(lower), hook.clone()))
2661
+ .expect("the instance must stand")],
2662
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
2736
2663
  )
2737
2664
  .expect("the Overlay must stack");
2738
2665
  let mount = Mount::new(
2739
2666
  "/data",
2740
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2667
+ Filesystem::new(overlay).expect("the instance must stand"),
2741
2668
  Access::ReadWrite,
2742
2669
  )
2743
2670
  .expect("/data is a guest path");
@@ -2776,19 +2703,16 @@ mod tests {
2776
2703
 
2777
2704
  /// What a removal and an open to write answer racing over one lower file,
2778
2705
  /// with what the descriptor the open made reports of itself.
2779
- fn race_removal_with_a_write() -> (
2780
- Result<(), FilesystemError>,
2781
- Option<Result<FileType, FilesystemError>>,
2782
- ) {
2706
+ fn race_removal_with_a_write() -> (Result<(), Errno>, Option<Result<FileType, Errno>>) {
2783
2707
  let lower: Tmpfs = [("d/f", "lower")].into_iter().collect();
2784
2708
  let overlay = Overlay::new(
2785
- vec![Filesystem::new(Arc::new(lower)).expect("the instance must stand")],
2786
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2709
+ vec![Filesystem::new(lower).expect("the instance must stand")],
2710
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
2787
2711
  )
2788
2712
  .expect("the Overlay must stack");
2789
2713
  let mount = Mount::new(
2790
2714
  "/data",
2791
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2715
+ Filesystem::new(overlay).expect("the instance must stand"),
2792
2716
  Access::ReadWrite,
2793
2717
  )
2794
2718
  .expect("/data is a guest path");
@@ -2819,6 +2743,46 @@ mod tests {
2819
2743
  })
2820
2744
  }
2821
2745
 
2746
+ // The make holds only the directory it makes in, so only the removal
2747
+ // holding that directory too, and removing it only once empty, keeps
2748
+ // what the make made from going with it. The two land in the same
2749
+ // instant only a few times in this many tries.
2750
+ // @behavior FS-132
2751
+ #[test]
2752
+ #[ignore = "a stress witness; run by rake crates:stress"]
2753
+ fn a_removal_through_an_overlay_waits_for_a_change_in_that_directory() {
2754
+ let (overlay, upper) = beside_its_upper([("upper/a/.keep", "")].into_iter().collect());
2755
+ let stop = Arc::new(AtomicBool::new(false));
2756
+ let churning = {
2757
+ let stop = stop.clone();
2758
+ thread::spawn(move || {
2759
+ while !stop.load(Ordering::SeqCst) {
2760
+ let _ = vfs::filename_mkdirat(&Arc::default(), &overlay, "a/b");
2761
+ let _ = vfs::filename_rmdir(&Arc::default(), &overlay, "a/b");
2762
+ }
2763
+ })
2764
+ };
2765
+ let mut lost = 0;
2766
+ for _ in 0..100_000 {
2767
+ if vfs::filename_mkdirat(&Arc::default(), &upper, "upper/a/b/made").is_ok() {
2768
+ match vfs::vfs_fstatat(&Arc::default(), &upper, "upper/a/b/made", false) {
2769
+ Ok(_) => {
2770
+ let _ = vfs::filename_rmdir(&Arc::default(), &upper, "upper/a/b/made");
2771
+ }
2772
+ Err(_) => lost += 1,
2773
+ }
2774
+ }
2775
+ }
2776
+ stop.store(true, Ordering::SeqCst);
2777
+ churning.join().expect("the Overlay's calls must not panic");
2778
+ assert_eq!(
2779
+ lost, 0,
2780
+ "vfs::filename_mkdirat in a directory through a Mount of an Overlay's upper \
2781
+ Tmpfs, while vfs::filename_rmdir removes that directory through the Overlay, \
2782
+ must leave every directory it made standing"
2783
+ );
2784
+ }
2785
+
2822
2786
  // A removal deciding how to hide the name before the copy up landed asked
2823
2787
  // the rename to find nothing there.
2824
2788
  // @behavior FS-182
@@ -2860,21 +2824,21 @@ mod tests {
2860
2824
  struct HoldsFifo(Arc<AtomicUsize>);
2861
2825
 
2862
2826
  impl FileSystemType for HoldsFifo {
2863
- fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), FilesystemError> {
2827
+ fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
2864
2828
  sb.d_make_root(Inode::new(&Kstat::new(FileType::Dir, 0), self));
2865
2829
  Ok(())
2866
2830
  }
2867
2831
  }
2868
2832
 
2869
2833
  impl InodeOperations for HoldsFifo {
2870
- fn getattr(&self, dentry: &Dentry) -> Result<Kstat, FilesystemError> {
2834
+ fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
2871
2835
  Ok(match dentry.name().as_str() {
2872
2836
  "pipe" => Kstat::new(FileType::Fifo, 0).with_identity(1, 2),
2873
2837
  _ => Kstat::new(FileType::Dir, 0).with_identity(1, 1),
2874
2838
  })
2875
2839
  }
2876
2840
 
2877
- fn lookup(&self, dentry: &Dentry) -> Result<Lookup, FilesystemError> {
2841
+ fn lookup(&self, dentry: &Dentry) -> Result<Lookup, Errno> {
2878
2842
  Ok(match dentry.name().as_str() {
2879
2843
  "pipe" => Lookup::Found(Inode::new(
2880
2844
  &Kstat::new(FileType::Fifo, 0).with_identity(1, 2),
@@ -2884,13 +2848,9 @@ mod tests {
2884
2848
  })
2885
2849
  }
2886
2850
 
2887
- fn open(
2888
- &self,
2889
- _dentry: &Dentry,
2890
- _how: &OpenHow,
2891
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
2851
+ fn open(&self, _dentry: &Dentry, _how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
2892
2852
  self.0.fetch_add(1, Ordering::SeqCst);
2893
- Err(FilesystemError::Interrupted)
2853
+ Err(Errno::Interrupted)
2894
2854
  }
2895
2855
  }
2896
2856
 
@@ -2903,14 +2863,13 @@ mod tests {
2903
2863
  use crate::vfs::{self, Path};
2904
2864
  let opened = Arc::new(AtomicUsize::new(0));
2905
2865
  let overlay = Overlay::new(
2906
- vec![Filesystem::new(Arc::new(HoldsFifo(opened.clone())))
2907
- .expect("the instance must stand")],
2908
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2866
+ vec![Filesystem::new(HoldsFifo(opened.clone())).expect("the instance must stand")],
2867
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
2909
2868
  )
2910
2869
  .expect("the Overlay must stack");
2911
2870
  let mount = Mount::new(
2912
2871
  "/data",
2913
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2872
+ Filesystem::new(overlay).expect("the instance must stand"),
2914
2873
  Access::ReadWrite,
2915
2874
  )
2916
2875
  .expect("/data is a guest path");
@@ -2919,11 +2878,11 @@ mod tests {
2919
2878
  &Path::root(mount.mnt()),
2920
2879
  "pipe",
2921
2880
  false,
2922
- &Iattr::times(None, Some(crate::vfs::SetTime::Now)),
2881
+ &Iattr::for_times(None, Some(crate::vfs::SetTime::Now)),
2923
2882
  );
2924
2883
  assert_eq!(
2925
2884
  (answer, opened.load(Ordering::SeqCst)),
2926
- (Err(FilesystemError::PermissionDenied), 0),
2885
+ (Err(Errno::PermissionDenied), 0),
2927
2886
  "vfs::do_utimes_pathon a FIFO a lower Layer holds through an Overlay must answer EACCES \
2928
2887
  and open nothing"
2929
2888
  );
@@ -2936,10 +2895,10 @@ mod tests {
2936
2895
  #[test]
2937
2896
  fn a_whiteout_in_a_directory_one_layer_shows_names_nothing() {
2938
2897
  let lower: Tmpfs = [("file", "x")].into_iter().collect();
2939
- let first_upper = Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand");
2898
+ let first_upper = Filesystem::new(Tmpfs::new()).expect("the instance must stand");
2940
2899
  let first = kern_path(Arc::new(
2941
2900
  Overlay::new(
2942
- vec![Filesystem::new(Arc::new(lower)).expect("the instance must stand")],
2901
+ vec![Filesystem::new(lower).expect("the instance must stand")],
2943
2902
  Some(first_upper.clone()),
2944
2903
  )
2945
2904
  .expect("the Overlay must stack"),
@@ -2947,12 +2906,12 @@ mod tests {
2947
2906
  first.vfs_unlink("file").expect("the file must be removed");
2948
2907
  let second = at(Overlay::new(
2949
2908
  vec![first_upper],
2950
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2909
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
2951
2910
  )
2952
2911
  .expect("the Overlay must stack"));
2953
2912
  assert_eq!(
2954
2913
  second.vfs_lstat("upper/file").err(),
2955
- Some(FilesystemError::NotFound),
2914
+ Some(Errno::NotFound),
2956
2915
  "a stat through an Overlay of a whiteout in a directory one Layer shows must answer \
2957
2916
  ENOENT, as the listing shows nothing there"
2958
2917
  );
@@ -2969,7 +2928,7 @@ mod tests {
2969
2928
  let overlay = at(over(Arc::new(lower), Arc::new(Tmpfs::new())));
2970
2929
  assert_eq!(
2971
2930
  overlay.rename("dir", &overlay, "full"),
2972
- Err(FilesystemError::CrossesDevices),
2931
+ Err(Errno::CrossesDevices),
2973
2932
  "a rename through an Overlay of a lower Layer's directory onto one holding entries \
2974
2933
  must answer EXDEV, as ovl_rename_start asks whether it can move first"
2975
2934
  );
@@ -2985,13 +2944,13 @@ mod tests {
2985
2944
  let lower: Tmpfs = [("file", vec![b'x'; 1 << 20])].into_iter().collect();
2986
2945
  let upper = Tmpfs::new().with_size(Some(4096)).with_nr_inodes(None);
2987
2946
  let overlay = Overlay::new(
2988
- vec![Filesystem::new(Arc::new(lower)).expect("the instance must stand")],
2989
- Some(Filesystem::new(Arc::new(upper)).expect("the instance must stand")),
2947
+ vec![Filesystem::new(lower).expect("the instance must stand")],
2948
+ Some(Filesystem::new(upper).expect("the instance must stand")),
2990
2949
  )
2991
2950
  .expect("the Overlay must stack");
2992
2951
  let mount = Mount::new(
2993
2952
  "/data",
2994
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2953
+ Filesystem::new(overlay).expect("the instance must stand"),
2995
2954
  Access::ReadWrite,
2996
2955
  )
2997
2956
  .expect("/data is a guest path");
@@ -3026,18 +2985,18 @@ mod tests {
3026
2985
  std::fs::create_dir_all(&deep).expect("the host tree must be made");
3027
2986
  std::fs::create_dir_all(host.join("held")).expect("the host tree must be made");
3028
2987
  std::fs::write(host.join("held/f"), "x").expect("the host file must be written");
3029
- let lower = Filesystem::new(Arc::new(
2988
+ let lower = Filesystem::new(
3030
2989
  crate::filesystem::Bind::new(&host).expect("the host directory must open"),
3031
- ))
2990
+ )
3032
2991
  .expect("the instance must stand");
3033
2992
  let overlay = Overlay::new(
3034
2993
  vec![lower],
3035
- Some(Filesystem::new(Arc::new(Tmpfs::new())).expect("the instance must stand")),
2994
+ Some(Filesystem::new(Tmpfs::new()).expect("the instance must stand")),
3036
2995
  )
3037
2996
  .expect("the Overlay must stack");
3038
2997
  let mount = Mount::new(
3039
2998
  "/data",
3040
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
2999
+ Filesystem::new(overlay).expect("the instance must stand"),
3041
3000
  Access::Read,
3042
3001
  )
3043
3002
  .expect("/data is a guest path");
@@ -3160,8 +3119,8 @@ mod tests {
3160
3119
  _inner: &dyn InodeOperations,
3161
3120
  _dentry: &Dentry,
3162
3121
  _how: &OpenHow,
3163
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
3164
- Err(FilesystemError::PermissionDenied)
3122
+ ) -> Result<Box<dyn FileOperations>, Errno> {
3123
+ Err(Errno::PermissionDenied)
3165
3124
  }
3166
3125
  }
3167
3126
 
@@ -3179,7 +3138,7 @@ mod tests {
3179
3138
  );
3180
3139
  let mount = Mount::new(
3181
3140
  "/data",
3182
- Filesystem::new(Arc::new(overlay)).expect("the instance must stand"),
3141
+ Filesystem::new(overlay).expect("the instance must stand"),
3183
3142
  Access::Read,
3184
3143
  )
3185
3144
  .expect("/data is a guest path");
@@ -3196,7 +3155,7 @@ mod tests {
3196
3155
  );
3197
3156
  assert_eq!(
3198
3157
  answer.err(),
3199
- Some(FilesystemError::PermissionDenied),
3158
+ Some(Errno::PermissionDenied),
3200
3159
  "vfs::do_file_open of an Overlay's directory whose Layer refuses its open must answer \
3201
3160
  what the Layer answered"
3202
3161
  );
@@ -3210,7 +3169,7 @@ mod tests {
3210
3169
  let overlay = at(over(Arc::new(lower), Arc::new(Tmpfs::new())));
3211
3170
  assert_eq!(
3212
3171
  overlay.rename("file", &overlay, "moved"),
3213
- Err(FilesystemError::NotFound),
3172
+ Err(Errno::NotFound),
3214
3173
  "a file renamed through Overlay::rename that its Layer loses during the call must \
3215
3174
  answer not found"
3216
3175
  );
@@ -3302,7 +3261,7 @@ mod tests {
3302
3261
  inner: &dyn InodeOperations,
3303
3262
  dentry: &Dentry,
3304
3263
  how: &OpenHow,
3305
- ) -> Result<Box<dyn FileOperations>, FilesystemError> {
3264
+ ) -> Result<Box<dyn FileOperations>, Errno> {
3306
3265
  if !self.opening.swap(true, Ordering::SeqCst) {
3307
3266
  thread::sleep(Duration::from_millis(100));
3308
3267
  }
@@ -3394,7 +3353,7 @@ mod tests {
3394
3353
  tmpfs_with("dir/lower", "x"),
3395
3354
  tmpfs_with("upper/dir/upper", "x"),
3396
3355
  ));
3397
- let identity = |metadata: Result<Kstat, FilesystemError>| {
3356
+ let identity = |metadata: Result<Kstat, Errno>| {
3398
3357
  let metadata = metadata.expect("the directory must stand");
3399
3358
  (metadata.dev, metadata.ino)
3400
3359
  };
@@ -3418,15 +3377,15 @@ mod tests {
3418
3377
  inner: &dyn InodeOperations,
3419
3378
  dentry: &Dentry,
3420
3379
  mask: Mask,
3421
- ) -> Result<(), FilesystemError> {
3380
+ ) -> Result<(), Errno> {
3422
3381
  if dentry.name() == self.name && mask.contains(self.mask) {
3423
- return Err(FilesystemError::PermissionDenied);
3382
+ return Err(Errno::PermissionDenied);
3424
3383
  }
3425
3384
  inner.permission(dentry, mask)
3426
3385
  }
3427
3386
  }
3428
3387
 
3429
- type LayerCall = fn(&KernPath) -> Result<(), FilesystemError>;
3388
+ type LayerCall = fn(&KernPath) -> Result<(), Errno>;
3430
3389
 
3431
3390
  // Only a Layer of the Host App's own answers `permission`, so each call is
3432
3391
  // made over a lower Layer refusing just the one ask that call makes of it.
@@ -3459,7 +3418,7 @@ mod tests {
3459
3418
  let view = at(over(Arc::new(lower), Arc::new(Tmpfs::new())));
3460
3419
  assert_eq!(
3461
3420
  run(&view),
3462
- Err(FilesystemError::PermissionDenied),
3421
+ Err(Errno::PermissionDenied),
3463
3422
  "{call} through an Overlay over a Layer whose permission refuses {mask:?} of \
3464
3423
  `{name}` must answer that refusal, as overlayfs asks inode_permission of the \
3465
3424
  real inode"