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.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +335 -0
- data/Cargo.lock +469 -11
- data/README.md +43 -3
- data/ROADMAP.md +1 -1
- data/crates/kobako-runtime/CHANGELOG.md +219 -0
- data/crates/kobako-runtime/Cargo.toml +51 -3
- data/crates/kobako-runtime/README.md +7 -4
- data/crates/kobako-runtime/src/cred.rs +124 -0
- data/crates/kobako-runtime/src/dispatch.rs +4 -5
- data/crates/kobako-runtime/src/endpoint/buffer.rs +153 -44
- data/crates/kobako-runtime/src/endpoint/dispatch.rs +80 -41
- data/crates/kobako-runtime/src/endpoint/invoke.rs +23 -36
- data/crates/kobako-runtime/src/endpoint.rs +137 -36
- 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/lookup.rs +52 -14
- data/crates/kobako-runtime/src/filesystem/bind/walk.rs +19 -20
- data/crates/kobako-runtime/src/filesystem/bind.rs +437 -245
- data/crates/kobako-runtime/src/filesystem/overlay/file.rs +6 -6
- data/crates/kobako-runtime/src/filesystem/overlay/path.rs +43 -65
- data/crates/kobako-runtime/src/filesystem/overlay/stack/copy_up.rs +9 -16
- data/crates/kobako-runtime/src/filesystem/overlay/stack/dir.rs +47 -72
- data/crates/kobako-runtime/src/filesystem/overlay/stack/namei.rs +12 -12
- data/crates/kobako-runtime/src/filesystem/overlay/stack/readdir.rs +4 -7
- data/crates/kobako-runtime/src/filesystem/overlay/stack.rs +121 -37
- data/crates/kobako-runtime/src/filesystem/overlay.rs +302 -343
- data/crates/kobako-runtime/src/filesystem/pipe.rs +12 -9
- data/crates/kobako-runtime/src/filesystem/rdir.rs +15 -32
- data/crates/kobako-runtime/src/filesystem/tmpfs/seed.rs +32 -0
- data/crates/kobako-runtime/src/filesystem/tmpfs/tmpfile.rs +3 -3
- data/crates/kobako-runtime/src/filesystem/tmpfs/whiteout.rs +57 -35
- data/crates/kobako-runtime/src/filesystem/tmpfs/xattr.rs +2 -2
- data/crates/kobako-runtime/src/filesystem/tmpfs.rs +172 -160
- data/crates/kobako-runtime/src/filesystem/wrap.rs +36 -52
- data/crates/kobako-runtime/src/filesystem.rs +6 -3
- 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 +4 -2
- data/crates/kobako-runtime/src/lib.rs +18 -7
- data/crates/kobako-runtime/src/limits.rs +195 -0
- data/crates/kobako-runtime/src/locking.rs +10 -0
- data/crates/kobako-runtime/src/memcg.rs +383 -0
- data/crates/kobako-runtime/src/mount.rs +67 -9
- 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 +29 -144
- data/crates/kobako-runtime/src/runtime.rs +3 -5
- data/crates/kobako-runtime/src/sched.rs +130 -29
- data/crates/kobako-runtime/src/security/entry_policy.rs +22 -0
- data/crates/kobako-runtime/src/{vfs/cred.rs → security/hooks.rs} +52 -144
- data/crates/kobako-runtime/src/security/mount_policy.rs +158 -0
- data/crates/kobako-runtime/src/security.rs +101 -196
- data/crates/kobako-runtime/src/snapshot.rs +121 -2
- data/crates/kobako-runtime/src/vfs/attr.rs +5 -5
- data/crates/kobako-runtime/src/vfs/dentry.rs +143 -89
- data/crates/kobako-runtime/src/vfs/file.rs +199 -203
- data/crates/kobako-runtime/src/vfs/inode.rs +41 -45
- data/crates/kobako-runtime/src/vfs/kern_path.rs +38 -42
- data/crates/kobako-runtime/src/vfs/mount.rs +10 -9
- data/crates/kobako-runtime/src/vfs/namei.rs +829 -700
- 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 +3 -3
- data/crates/kobako-runtime/src/vfs/path.rs +6 -6
- data/crates/kobako-runtime/src/vfs/readdir.rs +6 -6
- data/crates/kobako-runtime/src/vfs/stat.rs +159 -23
- data/crates/kobako-runtime/src/vfs/super_block.rs +18 -14
- data/crates/kobako-runtime/src/vfs/utimes.rs +37 -27
- data/crates/kobako-runtime/src/vfs.rs +9 -6
- data/crates/kobako-runtime/src/wait.rs +356 -0
- data/crates/kobako-transport/CHANGELOG.md +31 -0
- data/crates/kobako-transport/Cargo.toml +1 -1
- data/crates/kobako-transport/README.md +3 -4
- data/crates/kobako-transport/src/abi.rs +78 -72
- data/crates/kobako-transport/src/envelope/bytes.rs +17 -6
- data/crates/kobako-transport/src/envelope/call.rs +32 -4
- data/crates/kobako-transport/src/envelope/error_record.rs +21 -0
- data/crates/kobako-transport/src/envelope/name.rs +99 -0
- data/crates/kobako-transport/src/envelope/outcome.rs +9 -9
- data/crates/kobako-transport/src/envelope/preamble.rs +24 -21
- data/crates/kobako-transport/src/envelope/reply.rs +27 -27
- data/crates/kobako-transport/src/envelope/unsupported.rs +10 -10
- data/crates/kobako-transport/src/envelope.rs +13 -8
- data/crates/kobako-wasmtime/CHANGELOG.md +161 -0
- data/crates/kobako-wasmtime/Cargo.toml +26 -7
- data/crates/kobako-wasmtime/README.md +3 -2
- data/crates/kobako-wasmtime/build/preview2.rs +1339 -0
- data/crates/kobako-wasmtime/build.rs +16 -0
- data/crates/kobako-wasmtime/src/abi.rs +17 -37
- data/crates/kobako-wasmtime/src/ambient.rs +33 -18
- data/crates/kobako-wasmtime/src/cache.rs +23 -15
- data/crates/kobako-wasmtime/src/config.rs +52 -68
- data/crates/kobako-wasmtime/src/driver.rs +48 -63
- data/crates/kobako-wasmtime/src/exports.rs +143 -17
- data/crates/kobako-wasmtime/src/guest.rs +12 -6
- data/crates/kobako-wasmtime/src/guest_binary.rs +14 -0
- data/crates/kobako-wasmtime/src/imports.rs +42 -18
- data/crates/kobako-wasmtime/src/instance_pre.rs +4 -4
- data/crates/kobako-wasmtime/src/invocation.rs +74 -12
- data/crates/kobako-wasmtime/src/lib.rs +5 -3
- data/crates/kobako-wasmtime/src/limiter.rs +70 -5
- data/crates/kobako-wasmtime/src/preview1/descriptors.rs +309 -0
- data/crates/kobako-wasmtime/src/preview1/differential/mount.rs +5 -15
- data/crates/kobako-wasmtime/src/preview1/differential.rs +27 -31
- data/crates/kobako-wasmtime/src/preview1/errno.rs +55 -66
- data/crates/kobako-wasmtime/src/preview1/fd.rs +327 -296
- data/crates/kobako-wasmtime/src/preview1/memory.rs +21 -12
- data/crates/kobako-wasmtime/src/preview1/mount_view/wrap.rs +34 -53
- data/crates/kobako-wasmtime/src/preview1/mount_view.rs +231 -217
- data/crates/kobako-wasmtime/src/preview1/path.rs +56 -121
- data/crates/kobako-wasmtime/src/preview1/poll.rs +244 -120
- data/crates/kobako-wasmtime/src/preview1/sock.rs +10 -8
- data/crates/kobako-wasmtime/src/preview1/testsuite.rs +5 -15
- data/crates/kobako-wasmtime/src/preview1.rs +46 -42
- 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 +24 -9
- data/crates/kobako-wasmtime/src/wasi.rs +210 -81
- 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/data/kobako.wasm +0 -0
- data/ext/kobako/Cargo.toml +1 -1
- data/ext/kobako/src/{runtime/errors.rs → errors.rs} +34 -26
- data/ext/kobako/src/{runtime/escape.rs → escape.rs} +42 -11
- data/ext/kobako/src/{runtime/filesystem → filesystem}/grants.rs +30 -26
- data/ext/kobako/src/{runtime/filesystem → filesystem}/ruby.rs +149 -168
- data/ext/kobako/src/{runtime/filesystem.rs → filesystem.rs} +24 -15
- 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 +30 -29
- data/ext/kobako/src/runtime/snapshot.rs +4 -4
- data/ext/kobako/src/runtime.rs +221 -143
- data/ext/kobako/src/wire.rs +42 -0
- data/lib/kobako/catalog/extensions.rb +14 -2
- data/lib/kobako/catalog/flags.rb +3 -5
- data/lib/kobako/catalog/grants.rb +5 -4
- data/lib/kobako/catalog/handles.rb +5 -27
- data/lib/kobako/catalog/mount.rb +11 -3
- data/lib/kobako/catalog/network.rb +35 -0
- data/lib/kobako/catalog/replacements.rb +28 -0
- data/lib/kobako/catalog/services.rb +5 -19
- data/lib/kobako/catalog/snippets.rb +3 -18
- data/lib/kobako/catalog.rb +3 -0
- data/lib/kobako/codec/{utils.rb → boundary.rb} +4 -2
- data/lib/kobako/codec/decoder.rb +4 -4
- data/lib/kobako/codec/ext_types.rb +3 -3
- data/lib/kobako/codec/handle_walk.rb +3 -43
- data/lib/kobako/codec/value_budget.rb +132 -40
- data/lib/kobako/codec.rb +1 -1
- data/lib/kobako/context.rb +24 -11
- data/lib/kobako/errors.rb +15 -12
- data/lib/kobako/extension.rb +3 -2
- data/lib/kobako/filesystem.rb +9 -2
- 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/pool.rb +45 -23
- data/lib/kobako/runtime.rb +3 -2
- data/lib/kobako/sandbox.rb +92 -35
- data/lib/kobako/sandbox_options.rb +41 -106
- data/lib/kobako/transport/argument_wrap.rb +64 -0
- data/lib/kobako/transport/block_failure.rb +1 -1
- data/lib/kobako/transport/dispatcher.rb +6 -6
- data/lib/kobako/transport/exposure.rb +26 -15
- data/lib/kobako/transport/reflection.rb +21 -4
- data/lib/kobako/transport/run.rb +8 -23
- data/lib/kobako/transport/yielder.rb +2 -9
- data/lib/kobako/transport.rb +1 -0
- data/lib/kobako/version.rb +1 -1
- data/lib/kobako.rb +6 -2
- data/release-please-config.json +15 -0
- data/sig/core/thread.rbs +6 -0
- data/sig/kobako/catalog/extensions.rbs +2 -0
- data/sig/kobako/catalog/grants.rbs +7 -4
- data/sig/kobako/catalog/handles.rbs +0 -2
- data/sig/kobako/catalog/mount.rbs +3 -1
- data/sig/kobako/catalog/network.rbs +20 -0
- data/sig/kobako/catalog/replacements.rbs +14 -0
- data/sig/kobako/catalog/services.rbs +0 -4
- data/sig/kobako/catalog/snippets.rbs +0 -2
- data/sig/kobako/codec/{utils.rbs → boundary.rbs} +2 -2
- data/sig/kobako/codec/handle_walk.rbs +0 -6
- data/sig/kobako/codec/value_budget.rbs +47 -4
- data/sig/kobako/context.rbs +3 -1
- data/sig/kobako/errors.rbs +4 -4
- data/sig/kobako/filesystem.rbs +21 -3
- data/sig/kobako/network.rbs +115 -0
- data/sig/kobako/outcome.rbs +1 -1
- data/sig/kobako/pool.rbs +7 -3
- data/sig/kobako/runtime.rbs +32 -3
- data/sig/kobako/sandbox.rbs +19 -2
- data/sig/kobako/sandbox_options.rbs +29 -38
- data/sig/kobako/transport/argument_wrap.rbs +15 -0
- data/sig/kobako/transport/error.rbs +1 -1
- data/sig/kobako/transport/exposure.rbs +2 -4
- data/sig/kobako/transport/reflection.rbs +10 -0
- data/sig/kobako/transport/run.rbs +0 -2
- data/sig/kobako/transport/yielder.rbs +0 -3
- data/sig/kobako/transport.rbs +1 -1
- data/sig/kobako.rbs +13 -0
- metadata +84 -35
- data/crates/kobako-runtime/src/endpoint/capture.rs +0 -115
- data/crates/kobako-runtime/src/endpoint/memory_cap.rs +0 -238
- data/crates/kobako-runtime/src/filesystem/path.rs +0 -21
- data/crates/kobako-runtime/src/vfs/errno.rs +0 -153
- data/crates/kobako-runtime/tests/linux_baseline/calls.rs +0 -171
- data/crates/kobako-runtime/tests/linux_baseline/concurrent.rs +0 -276
- data/crates/kobako-runtime/tests/linux_baseline/kobako.rs +0 -323
- data/crates/kobako-runtime/tests/linux_baseline/linux-baseline-expected.txt +0 -16
- data/crates/kobako-runtime/tests/linux_baseline/linux.rs +0 -449
- data/crates/kobako-runtime/tests/linux_baseline/main.rs +0 -611
- data/crates/kobako-runtime/tests/linux_baseline/permissions.rs +0 -236
- data/crates/kobako-wasmtime/src/descriptors.rs +0 -200
- data/crates/kobako-wasmtime/tests/integration/compile_posture.rs +0 -43
- data/crates/kobako-wasmtime/tests/integration/guest_file.rs +0 -1085
- data/crates/kobako-wasmtime/tests/integration/main.rs +0 -29
- data/crates/kobako-wasmtime/tests/integration/preamble_flags.rs +0 -70
- data/crates/kobako-wasmtime/tests/integration/snippet_compile.rs +0 -95
- data/crates/kobako-wasmtime/tests/integration/support/mod.rs +0 -30
- data/crates/kobako-wasmtime/tests/integration/unanswered_call.rs +0 -86
- data/crates/kobako-wasmtime/tests/integration/unsupported_call.rs +0 -51
- data/ext/kobako/src/runtime/gvl.rs +0 -147
- data/lib/kobako/constant_name.rb +0 -8
- data/sig/kobako/constant_name.rbs +0 -3
- /data/ext/kobako/src/{runtime/pinned_value.rs → pinned_value.rs} +0 -0
|
@@ -7,19 +7,21 @@ use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
|
|
|
7
7
|
use std::sync::{Arc, Mutex, MutexGuard};
|
|
8
8
|
use std::time::SystemTime;
|
|
9
9
|
|
|
10
|
-
use super::path::{ancestors, name, normalize_seed};
|
|
11
10
|
use super::{
|
|
12
|
-
DentryOperations, DirEntry, FileOperations, FileSystemType, FileType, Filesystem,
|
|
13
|
-
|
|
11
|
+
DentryOperations, DirEntry, Errno, FileOperations, FileSystemType, FileType, Filesystem, Iattr,
|
|
12
|
+
InodeOperations, Kiocb, Kstat, Lookup, OpenHow, RenameFlag, SetTime,
|
|
14
13
|
};
|
|
15
14
|
use crate::vfs::{dir_emit_dots, generic_file_llseek, generic_read_dir, DirContext, Whence};
|
|
16
|
-
use crate::vfs::{Dentry, Identity, Inode, NAME_MAX};
|
|
15
|
+
use crate::vfs::{get_anon_bdev, Dentry, Identity, Inode, NAME_MAX};
|
|
17
16
|
use whiteout::Whiteout;
|
|
18
17
|
|
|
18
|
+
mod seed;
|
|
19
19
|
mod tmpfile;
|
|
20
20
|
mod whiteout;
|
|
21
21
|
mod xattr;
|
|
22
22
|
|
|
23
|
+
use seed::{ancestors, name};
|
|
24
|
+
|
|
23
25
|
/// Files and directories held in tmpfs. Every Invocation it is handed to
|
|
24
26
|
/// shares it, so what one writes the next reads. What its files hold
|
|
25
27
|
/// together, and how many entries it holds, are bounded as a tmpfs mount
|
|
@@ -52,9 +54,7 @@ enum Node {
|
|
|
52
54
|
File(Arc<Mutex<Content>>),
|
|
53
55
|
Directory(Arc<Dir>),
|
|
54
56
|
/// An Overlay's whiteout, as tmpfs holds a character device 0:0.
|
|
55
|
-
Whiteout
|
|
56
|
-
_inode: Arc<Whiteout>,
|
|
57
|
-
},
|
|
57
|
+
Whiteout(Arc<Whiteout>),
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
impl Node {
|
|
@@ -64,7 +64,7 @@ impl Node {
|
|
|
64
64
|
match self {
|
|
65
65
|
Self::File(data) => lock(data).names = 0,
|
|
66
66
|
Self::Directory(dir) => dir.state().removed = true,
|
|
67
|
-
Self::Whiteout
|
|
67
|
+
Self::Whiteout(_) => {}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -75,7 +75,18 @@ impl Node {
|
|
|
75
75
|
match self {
|
|
76
76
|
Self::File(data) => lock(data).times.ctime = now,
|
|
77
77
|
Self::Directory(dir) => dir.state().times.ctime = now,
|
|
78
|
-
Self::Whiteout
|
|
78
|
+
Self::Whiteout(whiteout) => whiteout.times().ctime = now,
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/// Refuse a directory holding anything, whiteouts among them, as
|
|
83
|
+
/// `simple_empty` answers before a removal or a replacement takes it.
|
|
84
|
+
fn ensure_empty(&self) -> Result<(), Errno> {
|
|
85
|
+
match self {
|
|
86
|
+
Self::Directory(dir) if !dir.state().entries.is_empty() => {
|
|
87
|
+
Err(Errno::DirectoryNotEmpty)
|
|
88
|
+
}
|
|
89
|
+
_ => Ok(()),
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
92
|
|
|
@@ -83,7 +94,7 @@ impl Node {
|
|
|
83
94
|
match self {
|
|
84
95
|
Self::File(_) => FileType::RegFile,
|
|
85
96
|
Self::Directory(_) => FileType::Dir,
|
|
86
|
-
Self::Whiteout
|
|
97
|
+
Self::Whiteout(_) => FileType::Chrdev,
|
|
87
98
|
}
|
|
88
99
|
}
|
|
89
100
|
|
|
@@ -96,7 +107,7 @@ impl Node {
|
|
|
96
107
|
entry.with_identity(content.dev, content.ino)
|
|
97
108
|
}
|
|
98
109
|
Self::Directory(dir) => entry.with_identity(dev, dir.ino),
|
|
99
|
-
Self::Whiteout
|
|
110
|
+
Self::Whiteout(whiteout) => entry.with_identity(dev, whiteout.ino()),
|
|
100
111
|
}
|
|
101
112
|
}
|
|
102
113
|
}
|
|
@@ -287,12 +298,12 @@ impl Dir {
|
|
|
287
298
|
}
|
|
288
299
|
|
|
289
300
|
/// What stands at `name` in this directory.
|
|
290
|
-
fn get(&self, name: &str) -> Result<Node,
|
|
301
|
+
fn get(&self, name: &str) -> Result<Node, Errno> {
|
|
291
302
|
self.state()
|
|
292
303
|
.entries
|
|
293
304
|
.get(name)
|
|
294
305
|
.cloned()
|
|
295
|
-
.ok_or(
|
|
306
|
+
.ok_or(Errno::NotFound)
|
|
296
307
|
}
|
|
297
308
|
|
|
298
309
|
/// Hand `nested` every directory this one holds, leaving it holding
|
|
@@ -329,17 +340,18 @@ impl Drop for Dir {
|
|
|
329
340
|
/// What a Tmpfs holds: the bytes of its files, and its entries, each
|
|
330
341
|
/// file and directory and the root counting one as an inode does.
|
|
331
342
|
struct Space {
|
|
332
|
-
bytes:
|
|
333
|
-
inodes:
|
|
343
|
+
bytes: Counter,
|
|
344
|
+
inodes: Counter,
|
|
334
345
|
}
|
|
335
346
|
|
|
336
|
-
/// How much of one thing is used,
|
|
337
|
-
|
|
347
|
+
/// How much of one thing is used, counted against the limit the Host App
|
|
348
|
+
/// set, as shmem counts `used_blocks` against `max_blocks`.
|
|
349
|
+
struct Counter {
|
|
338
350
|
limit: AtomicUsize,
|
|
339
351
|
used: AtomicUsize,
|
|
340
352
|
}
|
|
341
353
|
|
|
342
|
-
impl
|
|
354
|
+
impl Counter {
|
|
343
355
|
fn new(limit: Option<usize>) -> Self {
|
|
344
356
|
Self {
|
|
345
357
|
limit: AtomicUsize::new(limit.unwrap_or(usize::MAX)),
|
|
@@ -353,14 +365,14 @@ impl Budget {
|
|
|
353
365
|
}
|
|
354
366
|
|
|
355
367
|
/// Count `amount` more, refusing when it would pass the limit.
|
|
356
|
-
fn take(&self, amount: usize) -> Result<(),
|
|
368
|
+
fn take(&self, amount: usize) -> Result<(), Errno> {
|
|
357
369
|
let limit = self.limit.load(Ordering::Relaxed);
|
|
358
370
|
self.used
|
|
359
371
|
.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |used| {
|
|
360
372
|
used.checked_add(amount).filter(|&total| total <= limit)
|
|
361
373
|
})
|
|
362
374
|
.map(drop)
|
|
363
|
-
.map_err(|_|
|
|
375
|
+
.map_err(|_| Errno::StorageFull)
|
|
364
376
|
}
|
|
365
377
|
|
|
366
378
|
/// Count `amount` more without refusing, for what the Host App seeds.
|
|
@@ -395,7 +407,7 @@ impl Content {
|
|
|
395
407
|
}
|
|
396
408
|
|
|
397
409
|
/// An empty file the guest creates, refused once no inode is left.
|
|
398
|
-
fn create(tree: &Tree) -> Result<Arc<Mutex<Self>>,
|
|
410
|
+
fn create(tree: &Tree) -> Result<Arc<Mutex<Self>>, Errno> {
|
|
399
411
|
tree.space.inodes.take(1)?;
|
|
400
412
|
Ok(Self::new(Vec::new(), tree))
|
|
401
413
|
}
|
|
@@ -421,13 +433,13 @@ impl Content {
|
|
|
421
433
|
|
|
422
434
|
/// Resize to `len`, refusing a growth past the space left or past what
|
|
423
435
|
/// can be allocated, rather than aborting the host process.
|
|
424
|
-
fn resize(&mut self, len: usize) -> Result<(),
|
|
436
|
+
fn resize(&mut self, len: usize) -> Result<(), Errno> {
|
|
425
437
|
let growth = len.saturating_sub(self.bytes.len());
|
|
426
438
|
if growth > 0 {
|
|
427
439
|
self.space.bytes.take(growth)?;
|
|
428
440
|
if self.bytes.try_reserve_exact(growth).is_err() {
|
|
429
441
|
self.space.bytes.give(growth);
|
|
430
|
-
return Err(
|
|
442
|
+
return Err(Errno::StorageFull);
|
|
431
443
|
}
|
|
432
444
|
}
|
|
433
445
|
self.space.bytes.give(self.bytes.len().saturating_sub(len));
|
|
@@ -463,8 +475,8 @@ impl Tmpfs {
|
|
|
463
475
|
|
|
464
476
|
pub fn new() -> Self {
|
|
465
477
|
let space = Space {
|
|
466
|
-
bytes:
|
|
467
|
-
inodes:
|
|
478
|
+
bytes: Counter::new(Some(Self::DEFAULT_SIZE)),
|
|
479
|
+
inodes: Counter::new(inodes_for(Some(Self::DEFAULT_SIZE))),
|
|
468
480
|
};
|
|
469
481
|
space.inodes.add(1);
|
|
470
482
|
let space = Arc::new(space);
|
|
@@ -472,7 +484,7 @@ impl Tmpfs {
|
|
|
472
484
|
tree: Arc::new(Tree {
|
|
473
485
|
space: space.clone(),
|
|
474
486
|
inodes_follow_limit: AtomicBool::new(true),
|
|
475
|
-
dev:
|
|
487
|
+
dev: get_anon_bdev(),
|
|
476
488
|
next_ino: AtomicU64::new(2),
|
|
477
489
|
}),
|
|
478
490
|
dir: Dir::new(1, space),
|
|
@@ -567,13 +579,7 @@ impl Tmpfs {
|
|
|
567
579
|
{
|
|
568
580
|
let tmpfs = Self::new();
|
|
569
581
|
for (path, contents) in files {
|
|
570
|
-
let path =
|
|
571
|
-
if path.is_empty() {
|
|
572
|
-
return Err(SeedError::Root);
|
|
573
|
-
}
|
|
574
|
-
if path.split('/').any(|name| name == "..") {
|
|
575
|
-
return Err(SeedError::DotDot(path));
|
|
576
|
-
}
|
|
582
|
+
let path = seed::normalize(path.as_ref())?;
|
|
577
583
|
let mut dir = tmpfs.dir.clone();
|
|
578
584
|
for above in ancestors(&path) {
|
|
579
585
|
let standing = dir.state().entries.get(name(above)).cloned();
|
|
@@ -585,7 +591,7 @@ impl Tmpfs {
|
|
|
585
591
|
});
|
|
586
592
|
dir = match next {
|
|
587
593
|
Node::Directory(inner) => inner,
|
|
588
|
-
Node::File(_) | Node::Whiteout
|
|
594
|
+
Node::File(_) | Node::Whiteout(_) => {
|
|
589
595
|
return Err(SeedError::FileAndDirectory(above.to_string()))
|
|
590
596
|
}
|
|
591
597
|
};
|
|
@@ -593,7 +599,7 @@ impl Tmpfs {
|
|
|
593
599
|
let mut state = dir.state();
|
|
594
600
|
match state.entries.get(name(&path)) {
|
|
595
601
|
Some(Node::Directory(_)) => return Err(SeedError::FileAndDirectory(path)),
|
|
596
|
-
Some(Node::File(_) | Node::Whiteout
|
|
602
|
+
Some(Node::File(_) | Node::Whiteout(_)) => return Err(SeedError::Twice(path)),
|
|
597
603
|
None => {}
|
|
598
604
|
}
|
|
599
605
|
state.hold(
|
|
@@ -620,12 +626,12 @@ impl<P: AsRef<str>, C: Into<Vec<u8>>> FromIterator<(P, C)> for Tmpfs {
|
|
|
620
626
|
|
|
621
627
|
impl Tmpfs {
|
|
622
628
|
/// What `node`, an entry of this Tmpfs, reports of itself. A whiteout is
|
|
623
|
-
/// a character device 0:0, as tmpfs makes one.
|
|
629
|
+
/// a character device 0:0 with an inode of its own, as tmpfs makes one.
|
|
624
630
|
fn node_getattr(&self, node: &Node) -> Kstat {
|
|
625
631
|
match node {
|
|
626
632
|
Node::File(data) => lock(data).getattr(),
|
|
627
633
|
Node::Directory(dir) => dir.getattr(self.tree.dev),
|
|
628
|
-
Node::Whiteout
|
|
634
|
+
Node::Whiteout(whiteout) => whiteout.getattr(),
|
|
629
635
|
}
|
|
630
636
|
}
|
|
631
637
|
|
|
@@ -635,14 +641,14 @@ impl Tmpfs {
|
|
|
635
641
|
let ops: Arc<dyn InodeOperations> = match node {
|
|
636
642
|
Node::Directory(dir) => Arc::new(self.beneath(dir)),
|
|
637
643
|
Node::File(data) => Arc::new(TmpfsRegular { data }),
|
|
638
|
-
Node::Whiteout
|
|
644
|
+
Node::Whiteout(whiteout) => Arc::new(TmpfsWhiteout(whiteout)),
|
|
639
645
|
};
|
|
640
646
|
Inode::new(&stat, ops)
|
|
641
647
|
}
|
|
642
648
|
|
|
643
649
|
/// Put `node` at the name `dentry` carries and record it there, as
|
|
644
650
|
/// `shmem_mknod` calls `d_make_persistent`.
|
|
645
|
-
fn make(&self, dentry: &Dentry, node: Node) -> Result<(),
|
|
651
|
+
fn make(&self, dentry: &Dentry, node: Node) -> Result<(), Errno> {
|
|
646
652
|
self.dir.state().insert(&dentry.name(), node.clone());
|
|
647
653
|
dentry.add(Some(self.inode_of(node)));
|
|
648
654
|
Ok(())
|
|
@@ -650,7 +656,7 @@ impl Tmpfs {
|
|
|
650
656
|
}
|
|
651
657
|
|
|
652
658
|
impl FileSystemType for Tmpfs {
|
|
653
|
-
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(),
|
|
659
|
+
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
|
|
654
660
|
sb.set_default_d_op(Arc::new(TmpfsDentry));
|
|
655
661
|
sb.set_dontcache();
|
|
656
662
|
sb.d_make_root(Inode::new(&self.dir.getattr(self.tree.dev), self));
|
|
@@ -662,82 +668,76 @@ impl FileSystemType for Tmpfs {
|
|
|
662
668
|
/// through `TmpfsRegular`, and a whiteout, a character device 0:0 with no
|
|
663
669
|
/// driver to open it, through `TmpfsWhiteout`.
|
|
664
670
|
impl InodeOperations for Tmpfs {
|
|
665
|
-
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat,
|
|
671
|
+
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
666
672
|
Ok(self.dir.getattr(self.tree.dev))
|
|
667
673
|
}
|
|
668
674
|
|
|
669
|
-
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(),
|
|
675
|
+
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
|
|
670
676
|
self.dir.state().times.apply(attr);
|
|
671
677
|
Ok(())
|
|
672
678
|
}
|
|
673
679
|
|
|
674
680
|
/// A Tmpfs matches names byte for byte and holds no links, and refuses a
|
|
675
681
|
/// name past `NAME_MAX`, as `simple_lookup` does.
|
|
676
|
-
fn lookup(&self, dentry: &Dentry) -> Result<Lookup,
|
|
682
|
+
fn lookup(&self, dentry: &Dentry) -> Result<Lookup, Errno> {
|
|
677
683
|
let name = dentry.name();
|
|
678
684
|
if name.len() > NAME_MAX {
|
|
679
|
-
return Err(
|
|
685
|
+
return Err(Errno::InvalidFilename);
|
|
680
686
|
}
|
|
681
687
|
let node = match self.dir.get(&name) {
|
|
682
688
|
Ok(node) => node,
|
|
683
|
-
Err(
|
|
689
|
+
Err(Errno::NotFound) => return Ok(Lookup::Absent),
|
|
684
690
|
Err(err) => return Err(err),
|
|
685
691
|
};
|
|
686
692
|
Ok(Lookup::Found(self.inode_of(node)))
|
|
687
693
|
}
|
|
688
694
|
|
|
689
|
-
fn create(&self, dentry: &Dentry) -> Result<(),
|
|
695
|
+
fn create(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
690
696
|
let data = Content::create(&self.tree)?;
|
|
691
697
|
self.make(dentry, Node::File(data))
|
|
692
698
|
}
|
|
693
699
|
|
|
694
|
-
fn open(
|
|
695
|
-
&self,
|
|
696
|
-
_dentry: &Dentry,
|
|
697
|
-
_how: &OpenHow,
|
|
698
|
-
) -> Result<Box<dyn FileOperations>, FilesystemError> {
|
|
700
|
+
fn open(&self, _dentry: &Dentry, _how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
|
|
699
701
|
Ok(Box::new(TmpfsDir {
|
|
700
702
|
dir: self.dir.clone(),
|
|
701
703
|
dev: self.tree.dev,
|
|
702
704
|
}))
|
|
703
705
|
}
|
|
704
706
|
|
|
705
|
-
fn mkdir(&self, dentry: &Dentry) -> Result<(),
|
|
707
|
+
fn mkdir(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
706
708
|
self.tree.space.inodes.take(1)?;
|
|
707
709
|
self.make(dentry, Node::Directory(self.new_directory()))
|
|
708
710
|
}
|
|
709
711
|
|
|
710
712
|
/// The VFS found a directory at the name, as `shmem_rmdir` leaves it to,
|
|
711
713
|
/// so only whether it holds anything is left to answer.
|
|
712
|
-
fn rmdir(&self, dentry: &Dentry) -> Result<(),
|
|
714
|
+
fn rmdir(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
713
715
|
let name = dentry.name();
|
|
714
716
|
let mut state = self.dir.state();
|
|
715
|
-
if let Some(
|
|
716
|
-
|
|
717
|
-
return Err(FilesystemError::DirectoryNotEmpty);
|
|
718
|
-
}
|
|
717
|
+
if let Some(removed) = state.entries.get(&name) {
|
|
718
|
+
removed.ensure_empty()?;
|
|
719
719
|
}
|
|
720
720
|
state.remove(&name);
|
|
721
721
|
Ok(())
|
|
722
722
|
}
|
|
723
723
|
|
|
724
724
|
/// The VFS found no directory at the name, as `shmem_unlink` leaves it to.
|
|
725
|
-
fn unlink(&self, dentry: &Dentry) -> Result<(),
|
|
725
|
+
fn unlink(&self, dentry: &Dentry) -> Result<(), Errno> {
|
|
726
726
|
self.dir.state().remove(&dentry.name());
|
|
727
727
|
Ok(())
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
fn rename(
|
|
731
731
|
&self,
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
) -> Result<(),
|
|
737
|
-
let target = (
|
|
732
|
+
old: &Dentry,
|
|
733
|
+
new_dir: &dyn InodeOperations,
|
|
734
|
+
new: &Dentry,
|
|
735
|
+
flags: Option<RenameFlag>,
|
|
736
|
+
) -> Result<(), Errno> {
|
|
737
|
+
let target = (new_dir as &dyn Any)
|
|
738
738
|
.downcast_ref::<Self>()
|
|
739
|
-
.ok_or(
|
|
740
|
-
self.rename_at(&
|
|
739
|
+
.ok_or(Errno::CrossesDevices)?;
|
|
740
|
+
self.rename_at(&old.name(), target, &new.name(), flags)
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
743
|
|
|
@@ -754,21 +754,17 @@ impl FileOperations for TmpfsDir {
|
|
|
754
754
|
pos: u64,
|
|
755
755
|
offset: i64,
|
|
756
756
|
whence: Whence,
|
|
757
|
-
) -> Result<u64,
|
|
757
|
+
) -> Result<u64, Errno> {
|
|
758
758
|
generic_file_llseek(dentry, pos, offset, whence)
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
fn read_iter(&mut self, _iocb: &mut Kiocb, _buf: &mut [u8]) -> Result<usize,
|
|
761
|
+
fn read_iter(&mut self, _iocb: &mut Kiocb, _buf: &mut [u8]) -> Result<usize, Errno> {
|
|
762
762
|
generic_read_dir()
|
|
763
763
|
}
|
|
764
764
|
|
|
765
765
|
/// Reads on from each name's stable position, as `offset_readdir` does, so
|
|
766
766
|
/// nothing is held between two calls.
|
|
767
|
-
fn iterate_shared(
|
|
768
|
-
&mut self,
|
|
769
|
-
dentry: &Dentry,
|
|
770
|
-
ctx: &mut DirContext<'_>,
|
|
771
|
-
) -> Result<(), FilesystemError> {
|
|
767
|
+
fn iterate_shared(&mut self, dentry: &Dentry, ctx: &mut DirContext<'_>) -> Result<(), Errno> {
|
|
772
768
|
if !dir_emit_dots(dentry, ctx) {
|
|
773
769
|
return Ok(());
|
|
774
770
|
}
|
|
@@ -792,7 +788,7 @@ impl FileOperations for TmpfsDir {
|
|
|
792
788
|
|
|
793
789
|
/// A Tmpfs holds nothing to make durable, as tmpfs names `noop_fsync` for
|
|
794
790
|
/// its directories too.
|
|
795
|
-
fn fsync(&mut self, _datasync: bool) -> Result<(),
|
|
791
|
+
fn fsync(&mut self, _datasync: bool) -> Result<(), Errno> {
|
|
796
792
|
Ok(())
|
|
797
793
|
}
|
|
798
794
|
}
|
|
@@ -805,11 +801,7 @@ impl FileOperations for TmpfsDir {
|
|
|
805
801
|
pub(super) struct TmpfsDentry;
|
|
806
802
|
|
|
807
803
|
impl DentryOperations for TmpfsDentry {
|
|
808
|
-
fn revalidate(
|
|
809
|
-
&self,
|
|
810
|
-
dir: &dyn InodeOperations,
|
|
811
|
-
dentry: &Dentry,
|
|
812
|
-
) -> Result<bool, FilesystemError> {
|
|
804
|
+
fn revalidate(&self, dir: &dyn InodeOperations, dentry: &Dentry) -> Result<bool, Errno> {
|
|
813
805
|
let Some(dir) = (dir as &dyn Any).downcast_ref::<Tmpfs>() else {
|
|
814
806
|
return Ok(true);
|
|
815
807
|
};
|
|
@@ -830,25 +822,21 @@ struct TmpfsRegular {
|
|
|
830
822
|
}
|
|
831
823
|
|
|
832
824
|
impl InodeOperations for TmpfsRegular {
|
|
833
|
-
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat,
|
|
825
|
+
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
834
826
|
Ok(lock(&self.data).getattr())
|
|
835
827
|
}
|
|
836
828
|
|
|
837
|
-
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(),
|
|
829
|
+
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
|
|
838
830
|
let mut data = lock(&self.data);
|
|
839
831
|
if let Some(len) = attr.size {
|
|
840
|
-
let len = usize::try_from(len).map_err(|_|
|
|
832
|
+
let len = usize::try_from(len).map_err(|_| Errno::InvalidInput)?;
|
|
841
833
|
data.resize(len)?;
|
|
842
834
|
}
|
|
843
835
|
data.times.apply(attr);
|
|
844
836
|
Ok(())
|
|
845
837
|
}
|
|
846
838
|
|
|
847
|
-
fn open(
|
|
848
|
-
&self,
|
|
849
|
-
_dentry: &Dentry,
|
|
850
|
-
_how: &OpenHow,
|
|
851
|
-
) -> Result<Box<dyn FileOperations>, FilesystemError> {
|
|
839
|
+
fn open(&self, _dentry: &Dentry, _how: &OpenHow) -> Result<Box<dyn FileOperations>, Errno> {
|
|
852
840
|
Ok(Box::new(TmpfsFile {
|
|
853
841
|
data: self.data.clone(),
|
|
854
842
|
}))
|
|
@@ -856,11 +844,17 @@ impl InodeOperations for TmpfsRegular {
|
|
|
856
844
|
}
|
|
857
845
|
|
|
858
846
|
/// A whiteout a Tmpfs holds for an Overlay above it.
|
|
859
|
-
struct TmpfsWhiteout;
|
|
847
|
+
struct TmpfsWhiteout(Arc<Whiteout>);
|
|
860
848
|
|
|
861
849
|
impl InodeOperations for TmpfsWhiteout {
|
|
862
|
-
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat,
|
|
863
|
-
Ok(
|
|
850
|
+
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
851
|
+
Ok(self.0.getattr())
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/// Its times, as `shmem_setattr` sets a device's; it holds no size.
|
|
855
|
+
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
|
|
856
|
+
self.0.times().apply(attr);
|
|
857
|
+
Ok(())
|
|
864
858
|
}
|
|
865
859
|
}
|
|
866
860
|
|
|
@@ -868,13 +862,11 @@ fn lock(data: &Mutex<Content>) -> MutexGuard<'_, Content> {
|
|
|
868
862
|
data.lock().unwrap_or_else(|poisoned| poisoned.into_inner())
|
|
869
863
|
}
|
|
870
864
|
|
|
871
|
-
fn write(data: &mut Content, buf: &[u8], start: usize) -> Result<usize,
|
|
865
|
+
fn write(data: &mut Content, buf: &[u8], start: usize) -> Result<usize, Errno> {
|
|
872
866
|
if buf.is_empty() {
|
|
873
867
|
return Ok(0);
|
|
874
868
|
}
|
|
875
|
-
let end = start
|
|
876
|
-
.checked_add(buf.len())
|
|
877
|
-
.ok_or(FilesystemError::InvalidInput)?;
|
|
869
|
+
let end = start.checked_add(buf.len()).ok_or(Errno::InvalidInput)?;
|
|
878
870
|
if data.bytes.len() < end {
|
|
879
871
|
data.resize(end)?;
|
|
880
872
|
}
|
|
@@ -896,11 +888,11 @@ impl FileOperations for TmpfsFile {
|
|
|
896
888
|
pos: u64,
|
|
897
889
|
offset: i64,
|
|
898
890
|
whence: Whence,
|
|
899
|
-
) -> Result<u64,
|
|
891
|
+
) -> Result<u64, Errno> {
|
|
900
892
|
generic_file_llseek(dentry, pos, offset, whence)
|
|
901
893
|
}
|
|
902
894
|
|
|
903
|
-
fn read_iter(&mut self, iocb: &mut Kiocb, buf: &mut [u8]) -> Result<usize,
|
|
895
|
+
fn read_iter(&mut self, iocb: &mut Kiocb, buf: &mut [u8]) -> Result<usize, Errno> {
|
|
904
896
|
let data = &lock(&self.data).bytes;
|
|
905
897
|
let start = usize::try_from(iocb.pos)
|
|
906
898
|
.unwrap_or(usize::MAX)
|
|
@@ -913,11 +905,11 @@ impl FileOperations for TmpfsFile {
|
|
|
913
905
|
|
|
914
906
|
/// The end is read and written under one lock, so another handle's
|
|
915
907
|
/// append lands before or after this one, never over it.
|
|
916
|
-
fn write_iter(&mut self, iocb: &mut Kiocb, buf: &[u8]) -> Result<usize,
|
|
908
|
+
fn write_iter(&mut self, iocb: &mut Kiocb, buf: &[u8]) -> Result<usize, Errno> {
|
|
917
909
|
let mut data = lock(&self.data);
|
|
918
910
|
let start = match iocb.append {
|
|
919
911
|
true => data.bytes.len(),
|
|
920
|
-
false => usize::try_from(iocb.pos).map_err(|_|
|
|
912
|
+
false => usize::try_from(iocb.pos).map_err(|_| Errno::InvalidInput)?,
|
|
921
913
|
};
|
|
922
914
|
let written = write(&mut data, buf, start)?;
|
|
923
915
|
iocb.pos = (start + written) as u64;
|
|
@@ -927,15 +919,15 @@ impl FileOperations for TmpfsFile {
|
|
|
927
919
|
|
|
928
920
|
/// Nothing outlives the Tmpfs, so there is nothing to flush, as shmem's
|
|
929
921
|
/// `noop_fsync`.
|
|
930
|
-
fn fsync(&mut self, _datasync: bool) -> Result<(),
|
|
922
|
+
fn fsync(&mut self, _datasync: bool) -> Result<(), Errno> {
|
|
931
923
|
Ok(())
|
|
932
924
|
}
|
|
933
925
|
|
|
934
926
|
/// Grow the file to where the room ends, as `shmem_fallocate` moves `i_size`
|
|
935
927
|
/// past it. A Tmpfs holds every byte up to its end, so the room is taken from
|
|
936
928
|
/// its size or refused as out of space.
|
|
937
|
-
fn fallocate(&mut self, offset: u64, len: u64) -> Result<(),
|
|
938
|
-
let end = usize::try_from(offset + len).map_err(|_|
|
|
929
|
+
fn fallocate(&mut self, offset: u64, len: u64) -> Result<(), Errno> {
|
|
930
|
+
let end = usize::try_from(offset + len).map_err(|_| Errno::StorageFull)?;
|
|
939
931
|
let mut data = lock(&self.data);
|
|
940
932
|
if data.bytes.len() < end {
|
|
941
933
|
data.resize(end)?;
|
|
@@ -954,11 +946,7 @@ mod tests {
|
|
|
954
946
|
struct CountsLookups(std::sync::atomic::AtomicUsize);
|
|
955
947
|
|
|
956
948
|
impl crate::filesystem::wrap::Hook for CountsLookups {
|
|
957
|
-
fn lookup(
|
|
958
|
-
&self,
|
|
959
|
-
inner: &dyn InodeOperations,
|
|
960
|
-
dentry: &Dentry,
|
|
961
|
-
) -> Result<Lookup, FilesystemError> {
|
|
949
|
+
fn lookup(&self, inner: &dyn InodeOperations, dentry: &Dentry) -> Result<Lookup, Errno> {
|
|
962
950
|
self.0.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
|
|
963
951
|
inner.lookup(dentry)
|
|
964
952
|
}
|
|
@@ -971,7 +959,7 @@ mod tests {
|
|
|
971
959
|
let tmpfs: Tmpfs = [("a", ""), ("b", ""), ("c", "")].into_iter().collect();
|
|
972
960
|
let mount = crate::mount::Mount::new(
|
|
973
961
|
"/data",
|
|
974
|
-
Filesystem::new(
|
|
962
|
+
Filesystem::new(tmpfs).expect("the instance must stand"),
|
|
975
963
|
crate::mount::Access::ReadWrite,
|
|
976
964
|
)
|
|
977
965
|
.expect("/data is a guest path");
|
|
@@ -1024,7 +1012,7 @@ mod tests {
|
|
|
1024
1012
|
let wrapped = crate::filesystem::wrap::Wrap::new(Arc::new(tmpfs), counts.clone());
|
|
1025
1013
|
let mount = crate::mount::Mount::new(
|
|
1026
1014
|
"/data",
|
|
1027
|
-
Filesystem::new(
|
|
1015
|
+
Filesystem::new(wrapped).expect("the instance must stand"),
|
|
1028
1016
|
crate::mount::Access::ReadWrite,
|
|
1029
1017
|
)
|
|
1030
1018
|
.expect("/data is a guest path");
|
|
@@ -1046,14 +1034,14 @@ mod tests {
|
|
|
1046
1034
|
// @behavior FS-168
|
|
1047
1035
|
#[test]
|
|
1048
1036
|
fn an_exchange_leaves_both_files_named() {
|
|
1049
|
-
let filesystem = crate::filesystem::Filesystem::new(
|
|
1037
|
+
let filesystem = crate::filesystem::Filesystem::new(
|
|
1050
1038
|
[("a", "first"), ("b", "second")]
|
|
1051
1039
|
.into_iter()
|
|
1052
1040
|
.collect::<Tmpfs>(),
|
|
1053
|
-
)
|
|
1041
|
+
)
|
|
1054
1042
|
.expect("the instance must stand");
|
|
1055
1043
|
let dentries = filesystem.dentries();
|
|
1056
|
-
let root = filesystem.
|
|
1044
|
+
let root = filesystem.root().expect(crate::vfs::MADE_ROOT).clone();
|
|
1057
1045
|
let at = |name| {
|
|
1058
1046
|
dentries
|
|
1059
1047
|
.alloc_parallel(&root, name)
|
|
@@ -1091,7 +1079,7 @@ mod tests {
|
|
|
1091
1079
|
fs.create(&"x".repeat(NAME_MAX), &how).is_ok()
|
|
1092
1080
|
&& matches!(
|
|
1093
1081
|
fs.vfs_lstat(&"x".repeat(NAME_MAX + 1)),
|
|
1094
|
-
Err(
|
|
1082
|
+
Err(Errno::InvalidFilename)
|
|
1095
1083
|
),
|
|
1096
1084
|
"a name of NAME_MAX bytes must land in a Tmpfs, and one past it answer ENAMETOOLONG"
|
|
1097
1085
|
);
|
|
@@ -1157,6 +1145,37 @@ mod tests {
|
|
|
1157
1145
|
);
|
|
1158
1146
|
}
|
|
1159
1147
|
|
|
1148
|
+
// A whiteout made where the upper of an Overlay is mounted on its own
|
|
1149
|
+
// shows there, so it answers as the inode `shmem_mknod` makes for it.
|
|
1150
|
+
// @behavior FS-216
|
|
1151
|
+
#[test]
|
|
1152
|
+
fn a_whiteout_reports_an_inode_and_times_of_its_own() {
|
|
1153
|
+
let tmpfs = Tmpfs::new();
|
|
1154
|
+
tmpfs.whiteout("w").expect("the whiteout must be made");
|
|
1155
|
+
let fs = at(tmpfs);
|
|
1156
|
+
let set = SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(1_000);
|
|
1157
|
+
fs.setattr("w", &Iattr::for_times(None, Some(SetTime::At(set))))
|
|
1158
|
+
.expect("the whiteout's times must be set");
|
|
1159
|
+
let stat = fs.vfs_lstat("w").expect("the whiteout must stat");
|
|
1160
|
+
let listed = fs.iterate_dir().expect("the directory must list");
|
|
1161
|
+
let entry = listed
|
|
1162
|
+
.iter()
|
|
1163
|
+
.find(|entry| entry.name == "w")
|
|
1164
|
+
.expect("the whiteout is listed");
|
|
1165
|
+
assert_eq!(
|
|
1166
|
+
(
|
|
1167
|
+
stat.file_type,
|
|
1168
|
+
stat.ino != 0,
|
|
1169
|
+
entry.ino == stat.ino,
|
|
1170
|
+
stat.nlink,
|
|
1171
|
+
stat.mtime
|
|
1172
|
+
),
|
|
1173
|
+
(FileType::Chrdev, true, true, 1, Some(set)),
|
|
1174
|
+
"a whiteout in a Tmpfs through KernPath must stat as a character device with an \
|
|
1175
|
+
inode number its listing shares, one link, and the times set on it"
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1160
1179
|
fn at(tmpfs: Tmpfs) -> KernPath {
|
|
1161
1180
|
kern_path(Arc::new(tmpfs))
|
|
1162
1181
|
}
|
|
@@ -1173,7 +1192,7 @@ mod tests {
|
|
|
1173
1192
|
.expect("the file must open");
|
|
1174
1193
|
let mut buf = vec![0; 64];
|
|
1175
1194
|
let read = file
|
|
1176
|
-
.read_iter(&mut Kiocb::
|
|
1195
|
+
.read_iter(&mut Kiocb::new(0), &mut buf)
|
|
1177
1196
|
.expect("the file must read");
|
|
1178
1197
|
buf.truncate(read);
|
|
1179
1198
|
buf
|
|
@@ -1265,7 +1284,7 @@ mod tests {
|
|
|
1265
1284
|
},
|
|
1266
1285
|
)
|
|
1267
1286
|
.expect("a new file must be created");
|
|
1268
|
-
file.write_iter(&mut Kiocb::
|
|
1287
|
+
file.write_iter(&mut Kiocb::new(0), b"kept")
|
|
1269
1288
|
.expect("the write must land");
|
|
1270
1289
|
drop(file);
|
|
1271
1290
|
assert_eq!(
|
|
@@ -1278,13 +1297,10 @@ mod tests {
|
|
|
1278
1297
|
#[test]
|
|
1279
1298
|
fn a_directory_with_entries_is_not_removed() {
|
|
1280
1299
|
let tmpfs = at([("dir/file", "x")].into_iter().collect());
|
|
1281
|
-
assert_eq!(
|
|
1282
|
-
tmpfs.vfs_rmdir("dir"),
|
|
1283
|
-
Err(FilesystemError::DirectoryNotEmpty)
|
|
1284
|
-
);
|
|
1300
|
+
assert_eq!(tmpfs.vfs_rmdir("dir"), Err(Errno::DirectoryNotEmpty));
|
|
1285
1301
|
assert_eq!(tmpfs.vfs_unlink("dir/file"), Ok(()));
|
|
1286
1302
|
assert_eq!(tmpfs.vfs_rmdir("dir"), Ok(()));
|
|
1287
|
-
assert_eq!(tmpfs.vfs_lstat("dir"), Err(
|
|
1303
|
+
assert_eq!(tmpfs.vfs_lstat("dir"), Err(Errno::NotFound));
|
|
1288
1304
|
}
|
|
1289
1305
|
|
|
1290
1306
|
#[test]
|
|
@@ -1294,7 +1310,7 @@ mod tests {
|
|
|
1294
1310
|
.rename("old", &tmpfs, "new")
|
|
1295
1311
|
.expect("the rename must succeed");
|
|
1296
1312
|
assert_eq!(read_all(&tmpfs, "new/inner/file"), b"x");
|
|
1297
|
-
assert_eq!(tmpfs.vfs_lstat("old"), Err(
|
|
1313
|
+
assert_eq!(tmpfs.vfs_lstat("old"), Err(Errno::NotFound));
|
|
1298
1314
|
}
|
|
1299
1315
|
|
|
1300
1316
|
fn writable(fs: &KernPath, path: &str) -> Box<dyn FileOperations> {
|
|
@@ -1315,10 +1331,10 @@ mod tests {
|
|
|
1315
1331
|
let tmpfs = at(tmpfs.with_size(Some(4)));
|
|
1316
1332
|
assert_eq!(
|
|
1317
1333
|
(
|
|
1318
|
-
writable(&tmpfs, "file").write_iter(&mut Kiocb::
|
|
1334
|
+
writable(&tmpfs, "file").write_iter(&mut Kiocb::new(1), b"four"),
|
|
1319
1335
|
read_all(&tmpfs, "file")
|
|
1320
1336
|
),
|
|
1321
|
-
(Err(
|
|
1337
|
+
(Err(Errno::StorageFull), b"x".to_vec()),
|
|
1322
1338
|
"a write growing a Tmpfs's files past its limit through TmpfsFile::write_iter must \
|
|
1323
1339
|
answer StorageFull and leave the file as it was"
|
|
1324
1340
|
);
|
|
@@ -1330,7 +1346,7 @@ mod tests {
|
|
|
1330
1346
|
let tmpfs = at([("file", "")].into_iter().collect());
|
|
1331
1347
|
assert_eq!(
|
|
1332
1348
|
(
|
|
1333
|
-
writable(&tmpfs, "file").write_iter(&mut Kiocb::
|
|
1349
|
+
writable(&tmpfs, "file").write_iter(&mut Kiocb::new(1000), b""),
|
|
1334
1350
|
read_all(&tmpfs, "file")
|
|
1335
1351
|
),
|
|
1336
1352
|
(Ok(0), Vec::new()),
|
|
@@ -1350,7 +1366,7 @@ mod tests {
|
|
|
1350
1366
|
tmpfs.truncate("file", mib_64),
|
|
1351
1367
|
tmpfs.truncate("file", mib_64 + 1)
|
|
1352
1368
|
),
|
|
1353
|
-
(Ok(()), Err(
|
|
1369
|
+
(Ok(()), Err(Errno::StorageFull)),
|
|
1354
1370
|
"a Tmpfs given no limit through Tmpfs::new must hold 64 MiB and refuse a byte more"
|
|
1355
1371
|
);
|
|
1356
1372
|
}
|
|
@@ -1372,11 +1388,11 @@ mod tests {
|
|
|
1372
1388
|
fn a_removed_file_returns_its_space() {
|
|
1373
1389
|
let tmpfs = at(Tmpfs::new().with_size(Some(4)));
|
|
1374
1390
|
writable(&tmpfs, "first")
|
|
1375
|
-
.write_iter(&mut Kiocb::
|
|
1391
|
+
.write_iter(&mut Kiocb::new(0), b"four")
|
|
1376
1392
|
.expect("the first file must fit");
|
|
1377
1393
|
tmpfs.vfs_unlink("first").expect("the file must remove");
|
|
1378
1394
|
assert_eq!(
|
|
1379
|
-
writable(&tmpfs, "second").write_iter(&mut Kiocb::
|
|
1395
|
+
writable(&tmpfs, "second").write_iter(&mut Kiocb::new(0), b"four"),
|
|
1380
1396
|
Ok(4),
|
|
1381
1397
|
"the space a file removed through vfs_unlink held must be free for the next"
|
|
1382
1398
|
);
|
|
@@ -1394,12 +1410,12 @@ mod tests {
|
|
|
1394
1410
|
assert_eq!(
|
|
1395
1411
|
(
|
|
1396
1412
|
tmpfs.truncate("file", unallocatable),
|
|
1397
|
-
file.write_iter(&mut Kiocb::
|
|
1413
|
+
file.write_iter(&mut Kiocb::new(unallocatable), b"x"),
|
|
1398
1414
|
read_all(&tmpfs, "file")
|
|
1399
1415
|
),
|
|
1400
1416
|
(
|
|
1401
|
-
Err(
|
|
1402
|
-
Err(
|
|
1417
|
+
Err(Errno::StorageFull),
|
|
1418
|
+
Err(Errno::StorageFull),
|
|
1403
1419
|
b"x".to_vec()
|
|
1404
1420
|
),
|
|
1405
1421
|
"a length no allocator can hand out through TmpfsRegular::setattr and TmpfsFile::write_iter must \
|
|
@@ -1410,13 +1426,10 @@ mod tests {
|
|
|
1410
1426
|
#[test]
|
|
1411
1427
|
fn a_path_beneath_a_file_is_not_a_directory() {
|
|
1412
1428
|
let tmpfs = at([("file", "x")].into_iter().collect());
|
|
1413
|
-
assert_eq!(
|
|
1414
|
-
tmpfs.vfs_lstat("file/inner"),
|
|
1415
|
-
Err(FilesystemError::NotADirectory)
|
|
1416
|
-
);
|
|
1429
|
+
assert_eq!(tmpfs.vfs_lstat("file/inner"), Err(Errno::NotADirectory));
|
|
1417
1430
|
}
|
|
1418
1431
|
|
|
1419
|
-
fn create(fs: &KernPath, path: &str) -> Result<(),
|
|
1432
|
+
fn create(fs: &KernPath, path: &str) -> Result<(), Errno> {
|
|
1420
1433
|
fs.open_or_create(
|
|
1421
1434
|
path,
|
|
1422
1435
|
&OpenHow {
|
|
@@ -1443,8 +1456,8 @@ mod tests {
|
|
|
1443
1456
|
(
|
|
1444
1457
|
Ok(()),
|
|
1445
1458
|
Ok(()),
|
|
1446
|
-
Err(
|
|
1447
|
-
Err(
|
|
1459
|
+
Err(Errno::StorageFull),
|
|
1460
|
+
Err(Errno::StorageFull)
|
|
1448
1461
|
),
|
|
1449
1462
|
"a Tmpfs given inodes through Tmpfs::with_nr_inodes must refuse a file or directory \
|
|
1450
1463
|
past them, the root counted, as out of space"
|
|
@@ -1461,7 +1474,7 @@ mod tests {
|
|
|
1461
1474
|
create(&tmpfs, "b"),
|
|
1462
1475
|
create(&tmpfs, "c")
|
|
1463
1476
|
),
|
|
1464
|
-
(Ok(()), Ok(()), Err(
|
|
1477
|
+
(Ok(()), Ok(()), Err(Errno::StorageFull)),
|
|
1465
1478
|
"a Tmpfs given only a limit through Tmpfs::with_size must hold one entry for each \
|
|
1466
1479
|
4 KiB of it and the root"
|
|
1467
1480
|
);
|
|
@@ -1476,7 +1489,7 @@ mod tests {
|
|
|
1476
1489
|
let mut first = writable(&tmpfs, "log");
|
|
1477
1490
|
let mut second = writable(&tmpfs, "log");
|
|
1478
1491
|
let (mut from_first, mut from_second) =
|
|
1479
|
-
(Kiocb::
|
|
1492
|
+
(Kiocb::new(0).with_append(), Kiocb::new(0).with_append());
|
|
1480
1493
|
assert_eq!(
|
|
1481
1494
|
(
|
|
1482
1495
|
first.write_iter(&mut from_first, b"bb"),
|
|
@@ -1520,10 +1533,10 @@ mod tests {
|
|
|
1520
1533
|
(moves, standing),
|
|
1521
1534
|
(
|
|
1522
1535
|
[
|
|
1523
|
-
Some(
|
|
1524
|
-
Some(
|
|
1525
|
-
Some(
|
|
1526
|
-
Some(
|
|
1536
|
+
Some(Errno::IsADirectory),
|
|
1537
|
+
Some(Errno::IsADirectory),
|
|
1538
|
+
Some(Errno::NotADirectory),
|
|
1539
|
+
Some(Errno::DirectoryNotEmpty),
|
|
1527
1540
|
],
|
|
1528
1541
|
vec!["empty".to_string(), "file".to_string(), "full".to_string()]
|
|
1529
1542
|
),
|
|
@@ -1565,7 +1578,7 @@ mod tests {
|
|
|
1565
1578
|
drop(handle);
|
|
1566
1579
|
assert_eq!(
|
|
1567
1580
|
(while_open, create(&tmpfs, "second")),
|
|
1568
|
-
(Err(
|
|
1581
|
+
(Err(Errno::StorageFull), Ok(())),
|
|
1569
1582
|
"the inode of a file removed through vfs_unlink must stay taken while a \
|
|
1570
1583
|
handle holds it, and be free once it closes"
|
|
1571
1584
|
);
|
|
@@ -1576,7 +1589,7 @@ mod tests {
|
|
|
1576
1589
|
// @behavior FS-085
|
|
1577
1590
|
#[test]
|
|
1578
1591
|
fn a_device_of_its_own_stands_apart_from_every_other_device() {
|
|
1579
|
-
let (first, second) = (
|
|
1592
|
+
let (first, second) = (get_anon_bdev(), get_anon_bdev());
|
|
1580
1593
|
let tmpfs = at(Tmpfs::new())
|
|
1581
1594
|
.vfs_getattr()
|
|
1582
1595
|
.expect("the root must stand")
|
|
@@ -1586,7 +1599,7 @@ mod tests {
|
|
|
1586
1599
|
&& first != second
|
|
1587
1600
|
&& tmpfs != first
|
|
1588
1601
|
&& tmpfs != second,
|
|
1589
|
-
"devices from
|
|
1602
|
+
"devices from get_anon_bdev and a Tmpfs's root must each set the top bit \
|
|
1590
1603
|
and differ from one another"
|
|
1591
1604
|
);
|
|
1592
1605
|
}
|
|
@@ -1598,7 +1611,7 @@ mod tests {
|
|
|
1598
1611
|
.flat_map(|(name, node)| {
|
|
1599
1612
|
let beneath = match node {
|
|
1600
1613
|
Node::Directory(inner) => names(inner),
|
|
1601
|
-
Node::File(_) | Node::Whiteout
|
|
1614
|
+
Node::File(_) | Node::Whiteout(_) => Vec::new(),
|
|
1602
1615
|
};
|
|
1603
1616
|
std::iter::once(name.clone()).chain(beneath)
|
|
1604
1617
|
})
|
|
@@ -1652,7 +1665,7 @@ mod tests {
|
|
|
1652
1665
|
tmpfs.vfs_lstat("moved/made").map(|m| m.file_type),
|
|
1653
1666
|
tmpfs.vfs_lstat("dir/made").map(|m| m.file_type)
|
|
1654
1667
|
),
|
|
1655
|
-
(Ok(FileType::RegFile), Err(
|
|
1668
|
+
(Ok(FileType::RegFile), Err(Errno::NotFound)),
|
|
1656
1669
|
"a file made through a directory Tmpfs::open_dir opened before Tmpfs::rename moved \
|
|
1657
1670
|
it must stand beneath the directory's new path"
|
|
1658
1671
|
);
|
|
@@ -1673,8 +1686,8 @@ mod tests {
|
|
|
1673
1686
|
dir.vfs_lstat("").map(|m| m.file_type)
|
|
1674
1687
|
),
|
|
1675
1688
|
(
|
|
1676
|
-
Err(
|
|
1677
|
-
Err(
|
|
1689
|
+
Err(Errno::NotFound),
|
|
1690
|
+
Err(Errno::NotFound),
|
|
1678
1691
|
Ok(0),
|
|
1679
1692
|
Ok(FileType::Dir)
|
|
1680
1693
|
),
|
|
@@ -1697,7 +1710,7 @@ mod tests {
|
|
|
1697
1710
|
tmpfs.rename("a", &inner, "a"),
|
|
1698
1711
|
tmpfs.vfs_lstat("a/b").map(|m| m.file_type)
|
|
1699
1712
|
),
|
|
1700
|
-
(Err(
|
|
1713
|
+
(Err(Errno::InvalidInput), Ok(FileType::Dir)),
|
|
1701
1714
|
"Tmpfs::rename of a directory into one opened beneath it must answer InvalidInput \
|
|
1702
1715
|
and move nothing"
|
|
1703
1716
|
);
|
|
@@ -1736,7 +1749,7 @@ mod tests {
|
|
|
1736
1749
|
"file",
|
|
1737
1750
|
&Iattr {
|
|
1738
1751
|
ctime: Some(landed),
|
|
1739
|
-
..Iattr::
|
|
1752
|
+
..Iattr::for_times(now, now)
|
|
1740
1753
|
},
|
|
1741
1754
|
)
|
|
1742
1755
|
.expect("the times must be set");
|
|
@@ -1756,8 +1769,7 @@ mod tests {
|
|
|
1756
1769
|
fn a_removed_directory_something_holds_keeps_its_inode() {
|
|
1757
1770
|
let mount = crate::mount::Mount::new(
|
|
1758
1771
|
"/data",
|
|
1759
|
-
Filesystem::new(
|
|
1760
|
-
.expect("the instance must stand"),
|
|
1772
|
+
Filesystem::new(Tmpfs::new().with_nr_inodes(Some(2))).expect("the instance must stand"),
|
|
1761
1773
|
crate::mount::Access::ReadWrite,
|
|
1762
1774
|
)
|
|
1763
1775
|
.expect("/data is a guest path");
|
|
@@ -1779,7 +1791,7 @@ mod tests {
|
|
|
1779
1791
|
while_open,
|
|
1780
1792
|
crate::vfs::filename_mkdirat(&cred, &root, "next")
|
|
1781
1793
|
),
|
|
1782
|
-
(Err(
|
|
1794
|
+
(Err(Errno::StorageFull), Ok(())),
|
|
1783
1795
|
"vfs::filename_mkdirat in a Tmpfs out of inodes must answer ENOSPC while a removed \
|
|
1784
1796
|
directory stays open, and succeed once it closes"
|
|
1785
1797
|
);
|
|
@@ -1791,7 +1803,7 @@ mod tests {
|
|
|
1791
1803
|
let mount = |tmpfs: Tmpfs| {
|
|
1792
1804
|
crate::mount::Mount::new(
|
|
1793
1805
|
"/data",
|
|
1794
|
-
Filesystem::new(
|
|
1806
|
+
Filesystem::new(tmpfs).expect("the instance must stand"),
|
|
1795
1807
|
crate::mount::Access::ReadWrite,
|
|
1796
1808
|
)
|
|
1797
1809
|
.expect("/data is a guest path")
|
|
@@ -1807,7 +1819,7 @@ mod tests {
|
|
|
1807
1819
|
crate::vfs::filename_renameat2(&cred, &root(&from), "file", &root(&to), "file"),
|
|
1808
1820
|
crate::vfs::vfs_fstatat(&cred, &root(&from), "file", false).map(|found| found.size),
|
|
1809
1821
|
),
|
|
1810
|
-
(Err(
|
|
1822
|
+
(Err(Errno::CrossesDevices), Ok(1)),
|
|
1811
1823
|
"vfs::filename_renameat2 into a directory of another Tmpfs must answer EXDEV and \
|
|
1812
1824
|
leave the file"
|
|
1813
1825
|
);
|
|
@@ -1827,13 +1839,13 @@ mod tests {
|
|
|
1827
1839
|
let mut file = tmpfs
|
|
1828
1840
|
.open_or_create("file", &how)
|
|
1829
1841
|
.expect("the file must be made");
|
|
1830
|
-
file.write_iter(&mut Kiocb::
|
|
1842
|
+
file.write_iter(&mut Kiocb::new(0), b"ab")
|
|
1831
1843
|
.expect("the file must take a write");
|
|
1832
1844
|
let made = tmpfs.vfs_lstat("file").expect("the file must report");
|
|
1833
|
-
file.read_iter(&mut Kiocb::
|
|
1845
|
+
file.read_iter(&mut Kiocb::new(0), &mut [0; 1])
|
|
1834
1846
|
.expect("the file must read");
|
|
1835
1847
|
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
1836
|
-
file.write_iter(&mut Kiocb::
|
|
1848
|
+
file.write_iter(&mut Kiocb::new(0), b"c")
|
|
1837
1849
|
.expect("the file must take a write within its length");
|
|
1838
1850
|
let written = tmpfs.vfs_lstat("file").expect("the file must stand");
|
|
1839
1851
|
assert_eq!(
|
|
@@ -1947,7 +1959,7 @@ mod tests {
|
|
|
1947
1959
|
fn a_moved_file_keeps_its_names_through_the_move() {
|
|
1948
1960
|
let mount = crate::mount::Mount::new(
|
|
1949
1961
|
"/data",
|
|
1950
|
-
Filesystem::new(
|
|
1962
|
+
Filesystem::new([("a", "x")].into_iter().collect::<Tmpfs>())
|
|
1951
1963
|
.expect("the instance must stand"),
|
|
1952
1964
|
crate::mount::Access::ReadWrite,
|
|
1953
1965
|
)
|