kobako 0.29.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.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +552 -10
- data/Cargo.lock +595 -139
- data/README.md +126 -564
- data/ROADMAP.md +3 -2
- data/crates/kobako-runtime/CHANGELOG.md +488 -1
- data/crates/kobako-runtime/Cargo.toml +73 -15
- data/crates/kobako-runtime/README.md +11 -4
- data/crates/kobako-runtime/src/cred.rs +124 -0
- data/crates/kobako-runtime/src/dispatch.rs +5 -6
- data/crates/kobako-runtime/src/endpoint/buffer.rs +301 -0
- data/crates/kobako-runtime/src/endpoint/dispatch.rs +292 -0
- data/crates/kobako-runtime/src/endpoint/invoke.rs +181 -0
- data/crates/kobako-runtime/src/endpoint.rs +267 -0
- data/crates/kobako-runtime/src/errno.rs +391 -0
- data/crates/kobako-runtime/src/error.rs +31 -10
- data/crates/kobako-runtime/src/filesystem/anon_inodes.rs +52 -0
- data/crates/kobako-runtime/src/filesystem/bind/fid.rs +82 -0
- data/crates/kobako-runtime/src/filesystem/bind/lookup.rs +274 -0
- data/crates/kobako-runtime/src/filesystem/bind/walk.rs +248 -0
- data/crates/kobako-runtime/src/filesystem/bind.rs +2857 -0
- data/crates/kobako-runtime/src/filesystem/overlay/file.rs +89 -0
- data/crates/kobako-runtime/src/filesystem/overlay/inode.rs +106 -0
- data/crates/kobako-runtime/src/filesystem/overlay/path.rs +263 -0
- data/crates/kobako-runtime/src/filesystem/overlay/stack/copy_up.rs +128 -0
- data/crates/kobako-runtime/src/filesystem/overlay/stack/dir.rs +238 -0
- data/crates/kobako-runtime/src/filesystem/overlay/stack/namei.rs +135 -0
- data/crates/kobako-runtime/src/filesystem/overlay/stack/readdir.rs +54 -0
- data/crates/kobako-runtime/src/filesystem/overlay/stack.rs +316 -739
- data/crates/kobako-runtime/src/filesystem/overlay.rs +2627 -1154
- data/crates/kobako-runtime/src/filesystem/pipe.rs +224 -0
- data/crates/kobako-runtime/src/filesystem/rdir.rs +84 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/seed.rs +32 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/tmpfile.rs +32 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/whiteout.rs +107 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/xattr.rs +22 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs.rs +1997 -0
- data/crates/kobako-runtime/src/filesystem/wrap.rs +208 -0
- data/crates/kobako-runtime/src/filesystem.rs +25 -388
- data/crates/kobako-runtime/src/fork.rs +96 -0
- data/crates/kobako-runtime/src/grant.rs +3 -0
- data/crates/kobako-runtime/src/hashtable.rs +46 -0
- data/crates/kobako-runtime/src/lib.rs +27 -11
- data/crates/kobako-runtime/src/limits.rs +195 -0
- data/crates/kobako-runtime/src/locking/seqlock.rs +66 -0
- data/crates/kobako-runtime/src/locking.rs +228 -0
- data/crates/kobako-runtime/src/memcg.rs +383 -0
- data/crates/kobako-runtime/src/mount.rs +86 -101
- data/crates/kobako-runtime/src/net/backends.rs +43 -0
- data/crates/kobako-runtime/src/net/connections.rs +179 -0
- data/crates/kobako-runtime/src/net/credential.rs +125 -0
- data/crates/kobako-runtime/src/net/egress.rs +160 -0
- data/crates/kobako-runtime/src/net/family.rs +181 -0
- data/crates/kobako-runtime/src/net/http.rs +2733 -0
- data/crates/kobako-runtime/src/net/lookup.rs +285 -0
- data/crates/kobako-runtime/src/net/mock.rs +251 -0
- data/crates/kobako-runtime/src/net/namespace.rs +1366 -0
- data/crates/kobako-runtime/src/net/reactor.rs +531 -0
- data/crates/kobako-runtime/src/net/resolv/darwin.rs +275 -0
- data/crates/kobako-runtime/src/net/resolv/stub/tests.rs +469 -0
- data/crates/kobako-runtime/src/net/resolv/stub.rs +536 -0
- data/crates/kobako-runtime/src/net/resolv/windows.rs +248 -0
- data/crates/kobako-runtime/src/net/resolv.rs +227 -0
- data/crates/kobako-runtime/src/net/socket.rs +870 -0
- data/crates/kobako-runtime/src/net/tcp.rs +1588 -0
- data/crates/kobako-runtime/src/net/tls.rs +58 -0
- data/crates/kobako-runtime/src/net/transport.rs +279 -0
- data/crates/kobako-runtime/src/net/udp.rs +1003 -0
- data/crates/kobako-runtime/src/net.rs +42 -0
- data/crates/kobako-runtime/src/network/builder.rs +177 -0
- data/crates/kobako-runtime/src/network/ruleset.rs +777 -0
- data/crates/kobako-runtime/src/network.rs +551 -0
- data/crates/kobako-runtime/src/policy.rs +16 -0
- data/crates/kobako-runtime/src/profile.rs +37 -16
- data/crates/kobako-runtime/src/runtime.rs +3 -5
- data/crates/kobako-runtime/src/sched.rs +311 -0
- data/crates/kobako-runtime/src/security/entry_policy.rs +22 -0
- data/crates/kobako-runtime/src/security/hooks.rs +242 -0
- data/crates/kobako-runtime/src/security/mount_policy.rs +158 -0
- data/crates/kobako-runtime/src/security.rs +601 -0
- data/crates/kobako-runtime/src/snapshot.rs +121 -2
- data/crates/kobako-runtime/src/vfs/attr.rs +162 -0
- data/crates/kobako-runtime/src/vfs/dentry.rs +1466 -0
- data/crates/kobako-runtime/src/vfs/file.rs +1911 -0
- data/crates/kobako-runtime/src/vfs/inode.rs +425 -0
- data/crates/kobako-runtime/src/vfs/kern_path.rs +213 -0
- data/crates/kobako-runtime/src/vfs/mount.rs +60 -0
- data/crates/kobako-runtime/src/vfs/namei.rs +5837 -0
- data/crates/kobako-runtime/src/vfs/namespace.rs +162 -0
- data/crates/kobako-runtime/src/vfs/open_files.rs +69 -0
- data/crates/kobako-runtime/src/vfs/openat2.rs +116 -0
- data/crates/kobako-runtime/src/vfs/path.rs +64 -0
- data/crates/kobako-runtime/src/vfs/readdir.rs +163 -0
- data/crates/kobako-runtime/src/vfs/stat.rs +293 -0
- data/crates/kobako-runtime/src/vfs/super_block.rs +126 -0
- data/crates/kobako-runtime/src/vfs/utimes.rs +299 -0
- data/crates/kobako-runtime/src/vfs.rs +63 -0
- data/crates/kobako-runtime/src/wait.rs +356 -0
- data/crates/kobako-transport/CHANGELOG.md +39 -2
- data/crates/kobako-transport/Cargo.toml +3 -3
- data/crates/kobako-transport/README.md +8 -8
- data/crates/kobako-transport/src/abi.rs +78 -72
- data/crates/kobako-transport/src/envelope/bytes.rs +49 -30
- data/crates/kobako-transport/src/envelope/call.rs +37 -9
- data/crates/kobako-transport/src/envelope/compile_reply.rs +2 -2
- data/crates/kobako-transport/src/envelope/error_record.rs +24 -3
- data/crates/kobako-transport/src/envelope/fault.rs +2 -2
- data/crates/kobako-transport/src/envelope/name.rs +99 -0
- data/crates/kobako-transport/src/envelope/outcome.rs +11 -11
- data/crates/kobako-transport/src/envelope/preamble.rs +34 -31
- data/crates/kobako-transport/src/envelope/reply.rs +29 -29
- data/crates/kobako-transport/src/envelope/request.rs +2 -2
- data/crates/kobako-transport/src/envelope/run.rs +1 -1
- data/crates/kobako-transport/src/envelope/unsupported.rs +12 -12
- data/crates/kobako-transport/src/envelope.rs +15 -10
- data/crates/kobako-wasmtime/CHANGELOG.md +315 -8
- data/crates/kobako-wasmtime/Cargo.toml +35 -15
- data/crates/kobako-wasmtime/README.md +11 -6
- data/crates/kobako-wasmtime/build/preview2.rs +1339 -0
- data/crates/kobako-wasmtime/build.rs +16 -0
- data/crates/kobako-wasmtime/src/abi.rs +19 -47
- data/crates/kobako-wasmtime/src/ambient.rs +33 -19
- data/crates/kobako-wasmtime/src/cache.rs +28 -20
- data/crates/kobako-wasmtime/src/config.rs +59 -60
- data/crates/kobako-wasmtime/src/driver.rs +63 -145
- data/crates/kobako-wasmtime/src/exports.rs +147 -32
- data/crates/kobako-wasmtime/src/guest.rs +44 -0
- data/crates/kobako-wasmtime/src/guest_binary.rs +14 -0
- data/crates/kobako-wasmtime/src/imports.rs +48 -18
- data/crates/kobako-wasmtime/src/instance_pre.rs +7 -7
- data/crates/kobako-wasmtime/src/invocation.rs +93 -51
- data/crates/kobako-wasmtime/src/lib.rs +6 -7
- data/crates/kobako-wasmtime/src/limiter.rs +52 -211
- data/crates/kobako-wasmtime/src/preview1/descriptors.rs +309 -0
- data/crates/kobako-wasmtime/src/preview1/differential/mount.rs +70 -57
- data/crates/kobako-wasmtime/src/preview1/differential.rs +137 -27
- data/crates/kobako-wasmtime/src/preview1/errno.rs +90 -233
- data/crates/kobako-wasmtime/src/preview1/fd.rs +1301 -522
- data/crates/kobako-wasmtime/src/preview1/memory.rs +126 -150
- data/crates/kobako-wasmtime/src/preview1/mount_view/wrap.rs +192 -0
- data/crates/kobako-wasmtime/src/preview1/mount_view.rs +1989 -708
- data/crates/kobako-wasmtime/src/preview1/path.rs +181 -365
- data/crates/kobako-wasmtime/src/preview1/poll.rs +345 -173
- data/crates/kobako-wasmtime/src/preview1/sock.rs +10 -25
- data/crates/kobako-wasmtime/src/preview1/testsuite-expected.txt +6 -0
- data/crates/kobako-wasmtime/src/preview1/testsuite.rs +147 -0
- data/crates/kobako-wasmtime/src/preview1.rs +471 -416
- data/crates/kobako-wasmtime/src/preview2/abi.rs +227 -0
- data/crates/kobako-wasmtime/src/preview2/error.rs +118 -0
- data/crates/kobako-wasmtime/src/preview2/filesystem.rs +122 -0
- data/crates/kobako-wasmtime/src/preview2/host.rs +3959 -0
- data/crates/kobako-wasmtime/src/preview2/http.rs +1503 -0
- data/crates/kobako-wasmtime/src/preview2/io.rs +315 -0
- data/crates/kobako-wasmtime/src/preview2/sockets.rs +379 -0
- data/crates/kobako-wasmtime/src/preview2/table.rs +305 -0
- data/crates/kobako-wasmtime/src/preview2.rs +57 -0
- data/crates/kobako-wasmtime/src/trap.rs +31 -16
- data/crates/kobako-wasmtime/src/wasi.rs +238 -93
- data/crates/kobako-wasmtime/wit/deps/cli.wit +233 -0
- data/crates/kobako-wasmtime/wit/deps/clocks.wit +162 -0
- data/crates/kobako-wasmtime/wit/deps/filesystem.wit +589 -0
- data/crates/kobako-wasmtime/wit/deps/http.wit +733 -0
- data/crates/kobako-wasmtime/wit/deps/io.wit +299 -0
- data/crates/kobako-wasmtime/wit/deps/random.wit +92 -0
- data/crates/kobako-wasmtime/wit/deps/sockets.wit +949 -0
- data/crates/kobako-wasmtime/witx/typenames.witx +750 -0
- data/crates/kobako-wasmtime/witx/wasi_snapshot_preview1.witx +441 -0
- data/data/kobako.wasm +0 -0
- data/ext/kobako/Cargo.toml +1 -1
- data/ext/kobako/src/{runtime/errors.rs → errors.rs} +35 -27
- data/ext/kobako/src/escape.rs +98 -0
- data/ext/kobako/src/{runtime/filesystem → filesystem}/grants.rs +36 -16
- data/ext/kobako/src/filesystem/ruby.rs +689 -0
- data/ext/kobako/src/filesystem.rs +217 -0
- data/ext/kobako/src/gvl.rs +306 -0
- data/ext/kobako/src/lib.rs +64 -3
- data/ext/kobako/src/network/mock.rs +187 -0
- data/ext/kobako/src/network.rs +591 -0
- data/ext/kobako/src/runtime/bridge.rs +31 -30
- data/ext/kobako/src/runtime/snapshot.rs +5 -5
- data/ext/kobako/src/runtime.rs +221 -138
- data/ext/kobako/src/wire.rs +42 -0
- data/lib/kobako/catalog/extensions.rb +19 -7
- data/lib/kobako/catalog/flags.rb +4 -6
- data/lib/kobako/catalog/grants.rb +5 -4
- data/lib/kobako/catalog/handles.rb +9 -31
- data/lib/kobako/catalog/mount.rb +12 -12
- data/lib/kobako/catalog/network.rb +35 -0
- data/lib/kobako/catalog/replacements.rb +28 -0
- data/lib/kobako/catalog/services.rb +7 -21
- data/lib/kobako/catalog/snippets.rb +10 -25
- data/lib/kobako/catalog.rb +4 -1
- data/lib/kobako/codec/{utils.rb → boundary.rb} +5 -3
- data/lib/kobako/codec/decoder.rb +12 -12
- data/lib/kobako/codec/ext_types.rb +5 -7
- data/lib/kobako/codec/handle_walk.rb +5 -47
- data/lib/kobako/codec/nesting.rb +7 -7
- data/lib/kobako/codec/value_budget.rb +134 -42
- data/lib/kobako/codec.rb +1 -1
- data/lib/kobako/context.rb +28 -15
- data/lib/kobako/errors.rb +15 -12
- data/lib/kobako/extension.rb +3 -2
- data/lib/kobako/filesystem.rb +53 -15
- data/lib/kobako/handle.rb +2 -2
- data/lib/kobako/names.rb +28 -0
- data/lib/kobako/network.rb +210 -0
- data/lib/kobako/outcome.rb +7 -7
- data/lib/kobako/payload/arguments.rb +2 -2
- data/lib/kobako/pool.rb +47 -25
- data/lib/kobako/runtime.rb +3 -2
- data/lib/kobako/sandbox.rb +113 -56
- data/lib/kobako/sandbox_options.rb +41 -107
- data/lib/kobako/snippet/bytecode.rb +1 -1
- data/lib/kobako/snippet/source.rb +1 -1
- data/lib/kobako/transport/argument_wrap.rb +64 -0
- data/lib/kobako/transport/block_failure.rb +1 -1
- data/lib/kobako/transport/dispatcher.rb +10 -10
- data/lib/kobako/transport/exposure.rb +28 -17
- data/lib/kobako/transport/reflection.rb +28 -11
- data/lib/kobako/transport/run.rb +13 -28
- data/lib/kobako/transport/yielder.rb +3 -10
- data/lib/kobako/transport.rb +1 -0
- data/lib/kobako/version.rb +1 -1
- data/lib/kobako.rb +38 -0
- data/release-please-config.json +16 -0
- data/sig/core/thread.rbs +6 -0
- data/sig/kobako/catalog/extensions.rbs +5 -3
- data/sig/kobako/catalog/grants.rbs +7 -4
- data/sig/kobako/catalog/handles.rbs +2 -4
- data/sig/kobako/catalog/mount.rbs +3 -5
- data/sig/kobako/catalog/network.rbs +20 -0
- data/sig/kobako/catalog/replacements.rbs +14 -0
- data/sig/kobako/catalog/services.rbs +1 -5
- data/sig/kobako/catalog/snippets.rbs +3 -5
- data/sig/kobako/catalog.rbs +1 -1
- data/sig/kobako/codec/boundary.rbs +9 -0
- data/sig/kobako/codec/decoder.rbs +1 -1
- data/sig/kobako/codec/handle_walk.rbs +0 -6
- data/sig/kobako/codec/nesting.rbs +2 -2
- data/sig/kobako/codec/value_budget.rbs +48 -5
- data/sig/kobako/codec.rbs +1 -2
- data/sig/kobako/context.rbs +4 -2
- data/sig/kobako/errors.rbs +4 -4
- data/sig/kobako/filesystem.rbs +38 -15
- data/sig/kobako/guest_yielder.rbs +1 -1
- data/sig/kobako/network.rbs +115 -0
- data/sig/kobako/outcome.rbs +1 -1
- data/sig/kobako/payload/arguments.rbs +1 -1
- data/sig/kobako/pool.rbs +8 -4
- data/sig/kobako/runtime.rbs +32 -3
- data/sig/kobako/sandbox.rbs +22 -7
- data/sig/kobako/sandbox_options.rbs +29 -38
- data/sig/kobako/transport/argument_wrap.rbs +15 -0
- data/sig/kobako/transport/dispatcher.rbs +2 -2
- data/sig/kobako/transport/error.rbs +1 -1
- data/sig/kobako/transport/exposure.rbs +3 -5
- data/sig/kobako/transport/reflection.rbs +12 -2
- data/sig/kobako/transport/run.rbs +3 -5
- data/sig/kobako/transport/yielder.rbs +0 -3
- data/sig/kobako/transport.rbs +2 -2
- data/sig/kobako.rbs +13 -0
- metadata +131 -34
- data/crates/kobako-runtime/src/filesystem/directory/spelling.rs +0 -194
- data/crates/kobako-runtime/src/filesystem/directory.rs +0 -1082
- data/crates/kobako-runtime/src/filesystem/memory.rs +0 -1100
- data/crates/kobako-runtime/src/filesystem/overlay/exclusive.rs +0 -88
- data/crates/kobako-runtime/src/filesystem/path.rs +0 -60
- data/crates/kobako-runtime/src/filesystem/temporary.rs +0 -167
- data/crates/kobako-wasmtime/src/capture.rs +0 -96
- data/crates/kobako-wasmtime/src/descriptors.rs +0 -167
- data/crates/kobako-wasmtime/src/dispatch.rs +0 -125
- data/crates/kobako-wasmtime/src/guest_mem.rs +0 -271
- data/crates/kobako-wasmtime/src/io.rs +0 -89
- data/crates/kobako-wasmtime/src/preview1/args.rs +0 -60
- data/crates/kobako-wasmtime/src/preview1/beneath.rs +0 -188
- data/crates/kobako-wasmtime/tests/compile_posture.rs +0 -43
- data/crates/kobako-wasmtime/tests/guest_file.rs +0 -1054
- data/crates/kobako-wasmtime/tests/preamble_flags.rs +0 -70
- data/crates/kobako-wasmtime/tests/snippet_compile.rs +0 -95
- data/crates/kobako-wasmtime/tests/support/mod.rs +0 -30
- data/crates/kobako-wasmtime/tests/unanswered_call.rs +0 -86
- data/crates/kobako-wasmtime/tests/unsupported_call.rs +0 -51
- data/ext/kobako/src/runtime/escape.rs +0 -53
- data/ext/kobako/src/runtime/filesystem/ruby.rs +0 -400
- data/ext/kobako/src/runtime/filesystem.rs +0 -236
- data/ext/kobako/src/runtime/gvl.rs +0 -112
- data/lib/kobako/constant_name.rb +0 -8
- data/sig/kobako/codec/utils.rbs +0 -9
- data/sig/kobako/constant_name.rbs +0 -3
- /data/ext/kobako/src/{runtime/pinned_value.rs → pinned_value.rs} +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
//! A test's Filesystem over another: every call forwards to the entry it
|
|
2
|
+
//! wraps unless its `Hook` steps in, and every entry a lookup finds is
|
|
3
|
+
//! wrapped too, as a Filesystem wrapping another must. It makes a file
|
|
4
|
+
//! through `create` and leaves the open to the VFS, as overlayfs does, so an
|
|
5
|
+
//! open's lookup reaches the `Hook` as any lookup does. It hands the
|
|
6
|
+
//! Filesystem beneath the dentry it is handed, where overlayfs hands a real
|
|
7
|
+
//! one, so what that Filesystem makes is recorded unwrapped and later calls
|
|
8
|
+
//! on it reach that Filesystem past the `Hook`.
|
|
9
|
+
|
|
10
|
+
use std::any::Any;
|
|
11
|
+
use std::sync::Arc;
|
|
12
|
+
|
|
13
|
+
use super::{
|
|
14
|
+
DentryOperations, Errno, FileOperations, FileSystemType, Filesystem, Iattr, InodeOperations,
|
|
15
|
+
Kstat, Lookup, Mask, OpenHow, RenameFlag,
|
|
16
|
+
};
|
|
17
|
+
use crate::vfs::{Dentry, Inode};
|
|
18
|
+
|
|
19
|
+
/// What a test changes of the Filesystem beneath it.
|
|
20
|
+
pub(crate) trait Hook: Send + Sync + 'static {
|
|
21
|
+
fn permission(
|
|
22
|
+
&self,
|
|
23
|
+
inner: &dyn InodeOperations,
|
|
24
|
+
dentry: &Dentry,
|
|
25
|
+
mask: Mask,
|
|
26
|
+
) -> Result<(), Errno> {
|
|
27
|
+
inner.permission(dentry, mask)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fn revalidate(
|
|
31
|
+
&self,
|
|
32
|
+
ops: &dyn DentryOperations,
|
|
33
|
+
dir: &dyn InodeOperations,
|
|
34
|
+
dentry: &Dentry,
|
|
35
|
+
) -> Result<bool, Errno> {
|
|
36
|
+
ops.revalidate(dir, dentry)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fn getattr(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
40
|
+
inner.getattr(dentry)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fn lookup(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Lookup, Errno> {
|
|
44
|
+
inner.lookup(dentry)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fn open(
|
|
48
|
+
&self,
|
|
49
|
+
inner: &dyn InodeOperations,
|
|
50
|
+
dentry: &Dentry,
|
|
51
|
+
how: &OpenHow,
|
|
52
|
+
) -> Result<Box<dyn FileOperations>, Errno> {
|
|
53
|
+
inner.open(dentry, how)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
fn mkdir(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<(), Errno> {
|
|
57
|
+
inner.mkdir(dentry)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fn rmdir(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<(), Errno> {
|
|
61
|
+
inner.rmdir(dentry)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
fn unlink(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<(), Errno> {
|
|
65
|
+
inner.unlink(dentry)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fn rename(
|
|
69
|
+
&self,
|
|
70
|
+
inner: &dyn InodeOperations,
|
|
71
|
+
old: &Dentry,
|
|
72
|
+
new_dir: &dyn InodeOperations,
|
|
73
|
+
new: &Dentry,
|
|
74
|
+
flags: Option<RenameFlag>,
|
|
75
|
+
) -> Result<(), Errno> {
|
|
76
|
+
inner.rename(old, new_dir, new, flags)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// A Filesystem over the one `fs` makes, with `hook` stepping in.
|
|
81
|
+
pub(crate) struct Wrap<H> {
|
|
82
|
+
fs: Arc<dyn FileSystemType>,
|
|
83
|
+
hook: Arc<H>,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
impl<H: Hook> Wrap<H> {
|
|
87
|
+
pub(crate) fn new(fs: Arc<dyn FileSystemType>, hook: Arc<H>) -> Self {
|
|
88
|
+
Self { fs, hook }
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
impl<H: Hook> FileSystemType for Wrap<H> {
|
|
93
|
+
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
|
|
94
|
+
self.fs.clone().fill_super(sb)?;
|
|
95
|
+
if let Some(ops) = sb.d_op().cloned() {
|
|
96
|
+
sb.set_default_d_op(Arc::new(WrapDentry {
|
|
97
|
+
ops,
|
|
98
|
+
hook: self.hook.clone(),
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
if let Some(root) = sb.root().and_then(|root| root.inode()) {
|
|
102
|
+
let wrapped = WrapInode {
|
|
103
|
+
inner: root.ops().clone(),
|
|
104
|
+
hook: self.hook.clone(),
|
|
105
|
+
};
|
|
106
|
+
sb.d_make_root(root.with_ops(Arc::new(wrapped)));
|
|
107
|
+
}
|
|
108
|
+
Ok(())
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/// `inner`, an entry of the Filesystem beneath, with `hook` stepping in.
|
|
113
|
+
struct WrapInode<H> {
|
|
114
|
+
inner: Arc<dyn InodeOperations>,
|
|
115
|
+
hook: Arc<H>,
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
impl<H: Hook> WrapInode<H> {
|
|
119
|
+
/// `found` with the entry it names wrapped too.
|
|
120
|
+
fn wrap(&self, found: Lookup) -> Lookup {
|
|
121
|
+
let wrapped = |inode: Arc<Inode>| {
|
|
122
|
+
let ops = Self {
|
|
123
|
+
inner: inode.ops().clone(),
|
|
124
|
+
hook: self.hook.clone(),
|
|
125
|
+
};
|
|
126
|
+
inode.with_ops(Arc::new(ops))
|
|
127
|
+
};
|
|
128
|
+
match found {
|
|
129
|
+
Lookup::Found(inode) => Lookup::Found(wrapped(inode)),
|
|
130
|
+
Lookup::Spelled { name, inode } => Lookup::Spelled {
|
|
131
|
+
name,
|
|
132
|
+
inode: wrapped(inode),
|
|
133
|
+
},
|
|
134
|
+
Lookup::Absent => Lookup::Absent,
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/// `ops`, handed the directory a `WrapInode<H>` wraps.
|
|
140
|
+
struct WrapDentry<H> {
|
|
141
|
+
ops: Arc<dyn DentryOperations>,
|
|
142
|
+
hook: Arc<H>,
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
impl<H: Hook> DentryOperations for WrapDentry<H> {
|
|
146
|
+
fn revalidate(&self, dir: &dyn InodeOperations, dentry: &Dentry) -> Result<bool, Errno> {
|
|
147
|
+
let dir = (dir as &dyn Any)
|
|
148
|
+
.downcast_ref::<WrapInode<H>>()
|
|
149
|
+
.map_or(dir, |wrap| wrap.inner.as_ref());
|
|
150
|
+
self.hook.revalidate(self.ops.as_ref(), dir, dentry)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
impl<H: Hook> InodeOperations for WrapInode<H> {
|
|
155
|
+
fn permission(&self, dentry: &Dentry, mask: Mask) -> Result<(), Errno> {
|
|
156
|
+
self.hook.permission(self.inner.as_ref(), dentry, mask)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
fn getattr(&self, dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
160
|
+
self.hook.getattr(self.inner.as_ref(), dentry)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
fn lookup(&self, dentry: &Dentry) -> Result<Lookup, Errno> {
|
|
164
|
+
Ok(self.wrap(self.hook.lookup(self.inner.as_ref(), dentry)?))
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
fn setattr(&self, dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
|
|
168
|
+
self.inner.setattr(dentry, attr)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
fn get_link(&self, dentry: &Dentry) -> Result<String, Errno> {
|
|
172
|
+
self.inner.get_link(dentry)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fn open(&self, dentry: &Dentry, how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
|
|
176
|
+
self.hook.open(self.inner.as_ref(), dentry, how)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
fn create(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
180
|
+
self.inner.create(dentry)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
fn mkdir(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
184
|
+
self.hook.mkdir(self.inner.as_ref(), dentry)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
fn rmdir(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
188
|
+
self.hook.rmdir(self.inner.as_ref(), dentry)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
fn unlink(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
192
|
+
self.hook.unlink(self.inner.as_ref(), dentry)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn rename(
|
|
196
|
+
&self,
|
|
197
|
+
old: &Dentry,
|
|
198
|
+
new_dir: &dyn InodeOperations,
|
|
199
|
+
new: &Dentry,
|
|
200
|
+
flags: Option<RenameFlag>,
|
|
201
|
+
) -> Result<(), Errno> {
|
|
202
|
+
let target = (new_dir as &dyn Any)
|
|
203
|
+
.downcast_ref::<Self>()
|
|
204
|
+
.ok_or(Errno::CrossesDevices)?;
|
|
205
|
+
self.hook
|
|
206
|
+
.rename(self.inner.as_ref(), old, target.inner.as_ref(), new, flags)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
@@ -1,392 +1,29 @@
|
|
|
1
|
-
//! The Filesystem
|
|
2
|
-
//! guest makes beneath
|
|
1
|
+
//! The Filesystem kinds kobako ships, each built on the VFS as a Linux
|
|
2
|
+
//! filesystem is: what answers every call a guest makes beneath a Mount.
|
|
3
3
|
//!
|
|
4
|
-
//! A
|
|
5
|
-
//!
|
|
6
|
-
//! themselves, so a third party brings one without implementing any of
|
|
7
|
-
//! that. Every path a runtime hands over is relative to the Filesystem's
|
|
8
|
-
//! own root, its components joined by `/`, with no `.` or `..` left and
|
|
9
|
-
//! no leading `/`; the empty path is the root, which a runtime never asks
|
|
10
|
-
//! to remove or move.
|
|
4
|
+
//! A third party implements the same tables to bring its own, so they are
|
|
5
|
+
//! named here too; the VFS, which calls them, owns them.
|
|
11
6
|
|
|
12
|
-
mod
|
|
13
|
-
mod
|
|
7
|
+
mod anon_inodes;
|
|
8
|
+
mod bind;
|
|
14
9
|
mod overlay;
|
|
15
|
-
mod
|
|
16
|
-
mod
|
|
17
|
-
|
|
18
|
-
use std::sync::atomic::{AtomicU64, Ordering};
|
|
19
|
-
use std::sync::Arc;
|
|
20
|
-
|
|
21
|
-
pub use directory::Directory;
|
|
22
|
-
pub use memory::{Memory, SeedError};
|
|
23
|
-
pub use overlay::{Blocking, Overlay};
|
|
24
|
-
pub use temporary::Temporary;
|
|
25
|
-
|
|
26
|
-
/// What the guest may do beneath a Mount, or an Overlay in one of its
|
|
27
|
-
/// Layers.
|
|
28
|
-
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
29
|
-
pub enum Access {
|
|
30
|
-
Read,
|
|
31
|
-
ReadWrite,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/// The files and directories behind a Mount. One may wrap
|
|
35
|
-
/// another and answer by delegating, so it sees every call on the way
|
|
36
|
-
/// through.
|
|
37
|
-
///
|
|
38
|
-
/// Six methods keep a guarantee the runtime gives the guest, so each
|
|
39
|
-
/// Filesystem answers them itself and a wrapper forwards them:
|
|
40
|
-
/// `symlink_metadata` keeps a link from being followed where a Mount
|
|
41
|
-
/// refuses links, `stored_path` keeps a Policy judging the spelling the
|
|
42
|
-
/// host stores, `canonicalize_beneath` keeps a link within the directory
|
|
43
|
-
/// a descriptor opened, `hold_directory` keeps an open directory's
|
|
44
|
-
/// identity its own, `for_invocation` keeps one Invocation's changes
|
|
45
|
-
/// from the next, and `for_policy` keeps a call to the path a Policy
|
|
46
|
-
/// judged.
|
|
47
|
-
pub trait Filesystem: Send + Sync {
|
|
48
|
-
/// Open the file at `path` as `options` asks, creating or truncating it
|
|
49
|
-
/// where they say to.
|
|
50
|
-
fn open(&self, path: &str, options: &OpenOptions) -> Result<Box<dyn File>, FilesystemError>;
|
|
51
|
-
|
|
52
|
-
fn metadata(&self, path: &str) -> Result<Metadata, FilesystemError>;
|
|
53
|
-
|
|
54
|
-
/// What `path` names without following a link standing there, as
|
|
55
|
-
/// `lstat` answers. A link is reported as one and nothing of where it
|
|
56
|
-
/// points: no size, and no way to read it. A Filesystem holding no
|
|
57
|
-
/// links answers `metadata`.
|
|
58
|
-
fn symlink_metadata(&self, path: &str) -> Result<Metadata, FilesystemError>;
|
|
59
|
-
|
|
60
|
-
/// `path` with each name this Filesystem holds spelled as it stores
|
|
61
|
-
/// it, so a name a host reaches by more than one spelling is judged by
|
|
62
|
-
/// one; names past the last it holds stay as given. A Filesystem
|
|
63
|
-
/// matching names exactly answers `path`.
|
|
64
|
-
fn stored_path(&self, path: &str) -> Result<String, FilesystemError>;
|
|
65
|
-
|
|
66
|
-
/// `path`, relative to the directory at `base`, with every link on it
|
|
67
|
-
/// followed, as cap-std's `Dir::canonicalize` answers: still relative
|
|
68
|
-
/// to `base`, `NotPermitted` where a link leads out of `base`, and
|
|
69
|
-
/// `NotFound` where nothing stands. A descriptor opened on `base`
|
|
70
|
-
/// reaches nothing above it, as a capability never widens. A
|
|
71
|
-
/// Filesystem holding no links answers `path`.
|
|
72
|
-
fn canonicalize_beneath(&self, base: &str, path: &str) -> Result<String, FilesystemError>;
|
|
73
|
-
|
|
74
|
-
/// Keep the directory at `path` from handing its identity to another
|
|
75
|
-
/// while the Hold lives, as an open descriptor keeps a host's inode
|
|
76
|
-
/// from being reused. A Filesystem whose identities never repeat
|
|
77
|
-
/// holds nothing.
|
|
78
|
-
fn hold_directory(&self, path: &str) -> Result<Option<Hold>, FilesystemError>;
|
|
79
|
-
|
|
80
|
-
/// The entries of the directory at `path`, without `.` or `..`.
|
|
81
|
-
fn read_dir(&self, path: &str) -> Result<Vec<DirEntry>, FilesystemError>;
|
|
82
|
-
|
|
83
|
-
fn create_dir(&self, path: &str) -> Result<(), FilesystemError>;
|
|
84
|
-
|
|
85
|
-
/// Remove the empty directory at `path`.
|
|
86
|
-
fn remove_dir(&self, path: &str) -> Result<(), FilesystemError>;
|
|
87
|
-
|
|
88
|
-
fn remove_file(&self, path: &str) -> Result<(), FilesystemError>;
|
|
89
|
-
|
|
90
|
-
/// Move the entry at `from` to `to`, refusing one `rename` does not
|
|
91
|
-
/// allow; a move onto its own path changes nothing and is allowed.
|
|
92
|
-
/// The Filesystem checks what stands at `from` as it moves it, under
|
|
93
|
-
/// the same lock, so nothing replaces it in between.
|
|
94
|
-
fn rename(&self, from: &str, to: &str, rename: Rename) -> Result<(), FilesystemError>;
|
|
95
|
-
|
|
96
|
-
/// The Filesystem a new Invocation starts from in this one's place, or
|
|
97
|
-
/// `None` when every Invocation shares this one.
|
|
98
|
-
fn for_invocation(&self) -> Option<Arc<dyn Filesystem>>;
|
|
99
|
-
|
|
100
|
-
/// The Filesystem a Mount with a Policy hands its calls in this one's
|
|
101
|
-
/// place, following no link anywhere on a path, each name reached
|
|
102
|
-
/// from the directory already held, so a link another writer swaps in
|
|
103
|
-
/// after the Policy judged the path is a link loop rather than
|
|
104
|
-
/// followed. A Filesystem holding no links answers `None`.
|
|
105
|
-
fn for_policy(&self) -> Option<Arc<dyn Filesystem>>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/// One open file. The runtime keeps its position, so every read and write
|
|
109
|
-
/// names the offset it starts at.
|
|
110
|
-
pub trait File: Send {
|
|
111
|
-
fn read_at(&mut self, buf: &mut [u8], offset: u64) -> Result<usize, FilesystemError>;
|
|
112
|
-
|
|
113
|
-
fn write_at(&mut self, buf: &[u8], offset: u64) -> Result<usize, FilesystemError>;
|
|
114
|
-
|
|
115
|
-
/// Write `buf` at the file's end as it stands when the write lands,
|
|
116
|
-
/// answering the offset it landed at and how much was written. It
|
|
117
|
-
/// keeps another writer's append from landing over this one, as Linux
|
|
118
|
-
/// takes an append under the file's lock, so a file that cannot read
|
|
119
|
-
/// its end and write there in one step answers `Unsupported`.
|
|
120
|
-
fn append(&mut self, buf: &[u8]) -> Result<(u64, usize), FilesystemError>;
|
|
121
|
-
|
|
122
|
-
fn metadata(&self) -> Result<Metadata, FilesystemError>;
|
|
123
|
-
|
|
124
|
-
/// Truncate or extend the file to `len` bytes, extending with zeros.
|
|
125
|
-
fn set_len(&mut self, len: u64) -> Result<(), FilesystemError>;
|
|
126
|
-
|
|
127
|
-
/// Make what was written durable. The default has nothing to flush,
|
|
128
|
-
/// which is the truthful answer of a file with no durability of its
|
|
129
|
-
/// own.
|
|
130
|
-
fn sync(&mut self) -> Result<(), FilesystemError> {
|
|
131
|
-
Ok(())
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/// Release the file once the guest closes it, answering whether what
|
|
135
|
-
/// it held was kept. The default has nothing to release; a file the
|
|
136
|
-
/// guest never closes is dropped instead.
|
|
137
|
-
fn close(self: Box<Self>) -> Result<(), FilesystemError> {
|
|
138
|
-
Ok(())
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/// How `Filesystem::open` opens a file.
|
|
143
|
-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
|
144
|
-
#[non_exhaustive]
|
|
145
|
-
pub struct OpenOptions {
|
|
146
|
-
pub read: bool,
|
|
147
|
-
pub write: bool,
|
|
148
|
-
/// Create the file when it does not exist.
|
|
149
|
-
pub create: bool,
|
|
150
|
-
/// Create the file, refusing one that already exists.
|
|
151
|
-
pub create_new: bool,
|
|
152
|
-
/// Empty the file once it is open.
|
|
153
|
-
pub truncate: bool,
|
|
154
|
-
/// Refuse a symbolic link standing at the path, as `O_NOFOLLOW` does;
|
|
155
|
-
/// a Filesystem holding no links has none to refuse.
|
|
156
|
-
pub nofollow: bool,
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/// What `Filesystem::rename` may move, as `renameat2` flags ask more of
|
|
160
|
-
/// a rename than its two paths.
|
|
161
|
-
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
|
162
|
-
#[non_exhaustive]
|
|
163
|
-
pub enum Rename {
|
|
164
|
-
/// Whatever stands at the source.
|
|
165
|
-
#[default]
|
|
166
|
-
Any,
|
|
167
|
-
/// Only a file. A directory is refused as `CrossesDevices`, so a
|
|
168
|
-
/// caller copies what is beneath it one entry at a time instead.
|
|
169
|
-
File,
|
|
170
|
-
/// Only a directory, as a trailing `/` asks. A file is refused as
|
|
171
|
-
/// `NotADirectory`.
|
|
172
|
-
Directory,
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
impl Rename {
|
|
176
|
-
/// Refuse moving an entry of `file_type` this rename may not move.
|
|
177
|
-
pub fn check(self, file_type: FileType) -> Result<(), FilesystemError> {
|
|
178
|
-
match (self, file_type) {
|
|
179
|
-
(Self::File, FileType::Directory) => Err(FilesystemError::CrossesDevices),
|
|
180
|
-
(Self::Directory, file_type) if file_type != FileType::Directory => {
|
|
181
|
-
Err(FilesystemError::NotADirectory)
|
|
182
|
-
}
|
|
183
|
-
_ => Ok(()),
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/// What a path names.
|
|
189
|
-
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
190
|
-
#[non_exhaustive]
|
|
191
|
-
pub enum FileType {
|
|
192
|
-
File,
|
|
193
|
-
Directory,
|
|
194
|
-
/// A link, as only `symlink_metadata` and a listing report one.
|
|
195
|
-
Symlink,
|
|
196
|
-
/// Anything else a host holds, such as a FIFO, a socket, or a device,
|
|
197
|
-
/// which no Filesystem opens.
|
|
198
|
-
Unknown,
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
202
|
-
#[non_exhaustive]
|
|
203
|
-
pub struct Metadata {
|
|
204
|
-
pub file_type: FileType,
|
|
205
|
-
/// The length in bytes; zero for a directory or a link.
|
|
206
|
-
pub len: u64,
|
|
207
|
-
/// The device and inode numbers naming what the path holds, as
|
|
208
|
-
/// `st_dev` and `st_ino` do. An `ino` of zero reports none, so a
|
|
209
|
-
/// descriptor of such a directory follows its path alone.
|
|
210
|
-
pub dev: u64,
|
|
211
|
-
pub ino: u64,
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
impl Metadata {
|
|
215
|
-
/// Metadata reporting no identity.
|
|
216
|
-
pub fn new(file_type: FileType, len: u64) -> Self {
|
|
217
|
-
Self {
|
|
218
|
-
file_type,
|
|
219
|
-
len,
|
|
220
|
-
dev: 0,
|
|
221
|
-
ino: 0,
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/// This metadata naming `dev` and `ino` as what the path holds.
|
|
226
|
-
pub fn with_identity(self, dev: u64, ino: u64) -> Self {
|
|
227
|
-
Self { dev, ino, ..self }
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/// A device number for a Filesystem with none of its own, as each
|
|
231
|
-
/// tmpfs mount takes one: no earlier call returned it, and its top bit,
|
|
232
|
-
/// which no host's `st_dev` sets, keeps it apart from a host's.
|
|
233
|
-
pub fn unique_device() -> u64 {
|
|
234
|
-
static NEXT: AtomicU64 = AtomicU64::new(1);
|
|
235
|
-
(1 << 63) | NEXT.fetch_add(1, Ordering::Relaxed)
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/// What keeps a directory's identity its own while a descriptor has the
|
|
240
|
-
/// directory open, released when it drops.
|
|
241
|
-
pub struct Hold {
|
|
242
|
-
_kept: Box<dyn Send + Sync>,
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
impl Hold {
|
|
246
|
-
/// A Hold keeping `kept`, such as a host directory's descriptor, until
|
|
247
|
-
/// it drops.
|
|
248
|
-
pub fn new(kept: impl Send + Sync + 'static) -> Self {
|
|
249
|
-
Self {
|
|
250
|
-
_kept: Box::new(kept),
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
256
|
-
#[non_exhaustive]
|
|
257
|
-
pub struct DirEntry {
|
|
258
|
-
pub name: String,
|
|
259
|
-
pub file_type: FileType,
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
impl DirEntry {
|
|
263
|
-
/// The entry `name` in its directory, naming a `file_type`.
|
|
264
|
-
pub fn new(name: impl Into<String>, file_type: FileType) -> Self {
|
|
265
|
-
Self {
|
|
266
|
-
name: name.into(),
|
|
267
|
-
file_type,
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
/// Why a Filesystem call failed. The runtime hands the guest the matching
|
|
273
|
-
/// error code.
|
|
274
|
-
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
275
|
-
#[non_exhaustive]
|
|
276
|
-
pub enum FilesystemError {
|
|
277
|
-
NotFound,
|
|
278
|
-
AlreadyExists,
|
|
279
|
-
NotADirectory,
|
|
280
|
-
IsADirectory,
|
|
281
|
-
DirectoryNotEmpty,
|
|
282
|
-
PermissionDenied,
|
|
283
|
-
ReadOnlyFilesystem,
|
|
284
|
-
InvalidInput,
|
|
285
|
-
Unsupported,
|
|
286
|
-
/// A change past what the Filesystem can hold.
|
|
287
|
-
StorageFull,
|
|
288
|
-
/// A file grown past the largest the Filesystem keeps.
|
|
289
|
-
FileTooLarge,
|
|
290
|
-
/// A move that cannot happen in one step, as between two devices.
|
|
291
|
-
CrossesDevices,
|
|
292
|
-
/// A call that would wait on a lock its own thread holds.
|
|
293
|
-
Deadlock,
|
|
294
|
-
/// A symbolic link where the call asked to follow none.
|
|
295
|
-
FilesystemLoop,
|
|
296
|
-
/// A call only a privileged caller may make, as apart from one the
|
|
297
|
-
/// file's permissions deny.
|
|
298
|
-
NotPermitted,
|
|
299
|
-
BadDescriptor,
|
|
300
|
-
ResourceBusy,
|
|
301
|
-
/// Bytes that are no valid character where the call needs one.
|
|
302
|
-
IllegalSequence,
|
|
303
|
-
Interrupted,
|
|
304
|
-
TooManyOpenFiles,
|
|
305
|
-
/// A name too long for the Filesystem.
|
|
306
|
-
InvalidFilename,
|
|
307
|
-
OutOfMemory,
|
|
308
|
-
NotASocket,
|
|
309
|
-
/// A value too large for the type the call answers in.
|
|
310
|
-
ValueTooLarge,
|
|
311
|
-
NotSeekable,
|
|
312
|
-
/// Any other failure, with what the Filesystem knows of it.
|
|
313
|
-
Other(String),
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/// Each failure under the POSIX error name it stands for. `ENOTSUP` comes
|
|
317
|
-
/// before `EOPNOTSUPP`, a name some hosts give the same error, so
|
|
318
|
-
/// `Unsupported` answers to the first.
|
|
319
|
-
const POSIX_NAMES: [(&str, FilesystemError); 26] = [
|
|
320
|
-
("ENOENT", FilesystemError::NotFound),
|
|
321
|
-
("EEXIST", FilesystemError::AlreadyExists),
|
|
322
|
-
("ENOTDIR", FilesystemError::NotADirectory),
|
|
323
|
-
("EISDIR", FilesystemError::IsADirectory),
|
|
324
|
-
("ENOTEMPTY", FilesystemError::DirectoryNotEmpty),
|
|
325
|
-
("EACCES", FilesystemError::PermissionDenied),
|
|
326
|
-
("EROFS", FilesystemError::ReadOnlyFilesystem),
|
|
327
|
-
("EINVAL", FilesystemError::InvalidInput),
|
|
328
|
-
("ENOTSUP", FilesystemError::Unsupported),
|
|
329
|
-
("EOPNOTSUPP", FilesystemError::Unsupported),
|
|
330
|
-
("ENOSPC", FilesystemError::StorageFull),
|
|
331
|
-
("EFBIG", FilesystemError::FileTooLarge),
|
|
332
|
-
("EXDEV", FilesystemError::CrossesDevices),
|
|
333
|
-
("EDEADLK", FilesystemError::Deadlock),
|
|
334
|
-
("ELOOP", FilesystemError::FilesystemLoop),
|
|
335
|
-
("EPERM", FilesystemError::NotPermitted),
|
|
336
|
-
("EBADF", FilesystemError::BadDescriptor),
|
|
337
|
-
("EBUSY", FilesystemError::ResourceBusy),
|
|
338
|
-
("EILSEQ", FilesystemError::IllegalSequence),
|
|
339
|
-
("EINTR", FilesystemError::Interrupted),
|
|
340
|
-
("EMFILE", FilesystemError::TooManyOpenFiles),
|
|
341
|
-
("ENAMETOOLONG", FilesystemError::InvalidFilename),
|
|
342
|
-
("ENOMEM", FilesystemError::OutOfMemory),
|
|
343
|
-
("ENOTSOCK", FilesystemError::NotASocket),
|
|
344
|
-
("EOVERFLOW", FilesystemError::ValueTooLarge),
|
|
345
|
-
("ESPIPE", FilesystemError::NotSeekable),
|
|
346
|
-
];
|
|
347
|
-
|
|
348
|
-
impl FilesystemError {
|
|
349
|
-
/// The POSIX error name this failure stands for, as `ENOENT`. `Other`
|
|
350
|
-
/// has none.
|
|
351
|
-
pub fn posix_name(&self) -> Option<&'static str> {
|
|
352
|
-
POSIX_NAMES
|
|
353
|
-
.iter()
|
|
354
|
-
.find(|(_, error)| error == self)
|
|
355
|
-
.map(|(name, _)| *name)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/// The failure a POSIX error name stands for, if it is one of these.
|
|
359
|
-
pub fn from_posix_name(name: &str) -> Option<Self> {
|
|
360
|
-
POSIX_NAMES
|
|
361
|
-
.iter()
|
|
362
|
-
.find(|(known, _)| *known == name)
|
|
363
|
-
.map(|(_, error)| error.clone())
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
10
|
+
mod pipe;
|
|
11
|
+
mod rdir;
|
|
12
|
+
mod tmpfs;
|
|
367
13
|
#[cfg(test)]
|
|
368
|
-
mod
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
(
|
|
385
|
-
FilesystemError::Unsupported.posix_name(),
|
|
386
|
-
FilesystemError::Other("x".into()).posix_name()
|
|
387
|
-
),
|
|
388
|
-
(Some("ENOTSUP"), None),
|
|
389
|
-
"Unsupported through FilesystemError::posix_name must answer ENOTSUP, and Other none"
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
14
|
+
pub(crate) mod wrap;
|
|
15
|
+
|
|
16
|
+
pub(crate) use anon_inodes::anon_inode_getfile;
|
|
17
|
+
pub use bind::Bind;
|
|
18
|
+
pub use overlay::Overlay;
|
|
19
|
+
pub use pipe::{create_pipe_files, PipeInodeInfo};
|
|
20
|
+
pub use rdir::Rdir;
|
|
21
|
+
pub use tmpfs::{SeedError, Tmpfs};
|
|
22
|
+
|
|
23
|
+
pub use crate::vfs::{
|
|
24
|
+
get_anon_bdev, Dentry, DentryOperations, DirContext, DirEntry, FMode, FileOperations,
|
|
25
|
+
FileSystemType, FileType, Finish, Iattr, Inode, InodeOperations, Kiocb, Kstat, Lookup, Mask,
|
|
26
|
+
OpenHow, PollMask, RenameFlag, SetTime, SuperBlock as Filesystem, Whence,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
use crate::Errno;
|