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
|
@@ -5,20 +5,21 @@
|
|
|
5
5
|
use std::sync::Arc;
|
|
6
6
|
|
|
7
7
|
use super::attr::notify_change;
|
|
8
|
-
use super::cred::{on_path, Cred};
|
|
9
8
|
use super::namei::{filename_lookup, retry_estale};
|
|
10
9
|
use super::path::{Path, Start};
|
|
11
|
-
use super::{
|
|
10
|
+
use super::{Errno, Iattr};
|
|
11
|
+
use crate::cred::Cred;
|
|
12
|
+
use crate::security::on_path;
|
|
12
13
|
|
|
13
14
|
/// Set `times` on what the descriptor at `path` names, as Linux's `do_utimes_fd`.
|
|
14
|
-
pub fn do_utimes_fd(cred: &Arc<Cred>, path: &Path, times: &Iattr) -> Result<(),
|
|
15
|
+
pub fn do_utimes_fd(cred: &Arc<Cred>, path: &Path, times: &Iattr) -> Result<(), Errno> {
|
|
15
16
|
vfs_utimes(cred, path, times)
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
/// Set `times` on what `path` names, as Linux's `vfs_utimes` asks the mount,
|
|
19
20
|
/// then the security hook, then `setattr` under the entry's lock. An entry
|
|
20
21
|
/// without `setattr` keeps no time to set, as this VFS holds none on an inode.
|
|
21
|
-
fn vfs_utimes(cred: &Arc<Cred>, path: &Path, times: &Iattr) -> Result<(),
|
|
22
|
+
fn vfs_utimes(cred: &Arc<Cred>, path: &Path, times: &Iattr) -> Result<(), Errno> {
|
|
22
23
|
path.mnt().mnt_want_write()?;
|
|
23
24
|
let dentry = path.dentry();
|
|
24
25
|
on_path(path.mnt(), dentry, |at| cred.security_path_utimes(at))?;
|
|
@@ -34,7 +35,7 @@ pub fn do_utimes_path(
|
|
|
34
35
|
path: &str,
|
|
35
36
|
follow: bool,
|
|
36
37
|
times: &Iattr,
|
|
37
|
-
) -> Result<(),
|
|
38
|
+
) -> Result<(), Errno> {
|
|
38
39
|
retry_estale(
|
|
39
40
|
|| filename_lookup(cred, start, path, follow),
|
|
40
41
|
|nd| vfs_utimes(cred, &nd.path_to(nd.path()?), times),
|
|
@@ -50,12 +51,13 @@ mod tests {
|
|
|
50
51
|
use crate::filesystem::{
|
|
51
52
|
FileSystemType, FileType, Filesystem, InodeOperations, Kstat, SetTime, Tmpfs,
|
|
52
53
|
};
|
|
53
|
-
use crate::mount::{Access as MountAccess, Mount,
|
|
54
|
-
use crate::
|
|
54
|
+
use crate::mount::{Access as MountAccess, Mount, MountRequest};
|
|
55
|
+
use crate::policy::Policy;
|
|
56
|
+
use crate::security::{prepare_creds, restrict_self};
|
|
55
57
|
use crate::vfs::Dentry;
|
|
56
58
|
|
|
57
59
|
fn times() -> Iattr<'static> {
|
|
58
|
-
Iattr::
|
|
60
|
+
Iattr::for_times(Some(SetTime::Now), Some(SetTime::At(UNIX_EPOCH)))
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
fn mount_of(filesystem: Arc<dyn FileSystemType>, access: MountAccess) -> Mount {
|
|
@@ -77,7 +79,7 @@ mod tests {
|
|
|
77
79
|
let _held = root.dentry().inode_lock().expect("the lock must be free");
|
|
78
80
|
assert_eq!(
|
|
79
81
|
vfs_utimes(&Arc::default(), &root, ×()),
|
|
80
|
-
Err(
|
|
82
|
+
Err(Errno::Deadlock),
|
|
81
83
|
"vfs::vfs_utimes on an entry whose lock its own thread holds must answer EDEADLK"
|
|
82
84
|
);
|
|
83
85
|
}
|
|
@@ -101,7 +103,7 @@ mod tests {
|
|
|
101
103
|
let _held = dentry.inode_lock().expect("the lock must be free");
|
|
102
104
|
assert_eq!(
|
|
103
105
|
file.truncate(0),
|
|
104
|
-
Err(
|
|
106
|
+
Err(Errno::Deadlock),
|
|
105
107
|
"vfs::File::truncate on a file whose lock its own thread holds must answer EDEADLK, \
|
|
106
108
|
as do_ftruncate holds the inode's lock around notify_change"
|
|
107
109
|
);
|
|
@@ -127,8 +129,8 @@ mod tests {
|
|
|
127
129
|
set(MountAccess::ReadWrite, "file.txt"),
|
|
128
130
|
),
|
|
129
131
|
(
|
|
130
|
-
Err(
|
|
131
|
-
Err(
|
|
132
|
+
Err(Errno::NotFound),
|
|
133
|
+
Err(Errno::ReadOnlyFilesystem),
|
|
132
134
|
Ok(()),
|
|
133
135
|
),
|
|
134
136
|
"vfs::do_utimes_path must answer what is not there ENOENT, a read-only Mount EROFS, and \
|
|
@@ -140,7 +142,7 @@ mod tests {
|
|
|
140
142
|
struct NoSetattr;
|
|
141
143
|
|
|
142
144
|
impl FileSystemType for NoSetattr {
|
|
143
|
-
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(),
|
|
145
|
+
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
|
|
144
146
|
sb.d_make_root(crate::vfs::Inode::new(
|
|
145
147
|
&crate::vfs::Kstat::new(crate::vfs::FileType::Dir, 0),
|
|
146
148
|
self,
|
|
@@ -150,7 +152,7 @@ mod tests {
|
|
|
150
152
|
}
|
|
151
153
|
|
|
152
154
|
impl InodeOperations for NoSetattr {
|
|
153
|
-
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat,
|
|
155
|
+
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
154
156
|
Ok(Kstat::new(FileType::Dir, 0))
|
|
155
157
|
}
|
|
156
158
|
}
|
|
@@ -161,7 +163,7 @@ mod tests {
|
|
|
161
163
|
let mount = mount_of(Arc::new(NoSetattr), MountAccess::ReadWrite);
|
|
162
164
|
assert_eq!(
|
|
163
165
|
vfs_utimes(&Arc::default(), &Path::root(mount.mnt()), ×()),
|
|
164
|
-
Err(
|
|
166
|
+
Err(Errno::Unsupported),
|
|
165
167
|
"vfs::vfs_utimes on an entry without setattr must answer ENOTSUP"
|
|
166
168
|
);
|
|
167
169
|
}
|
|
@@ -171,7 +173,7 @@ mod tests {
|
|
|
171
173
|
struct KeepsTimes(Mutex<Option<Iattr<'static>>>);
|
|
172
174
|
|
|
173
175
|
impl FileSystemType for KeepsTimes {
|
|
174
|
-
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(),
|
|
176
|
+
fn fill_super(self: Arc<Self>, sb: &mut Filesystem) -> Result<(), Errno> {
|
|
175
177
|
sb.d_make_root(crate::vfs::Inode::new(
|
|
176
178
|
&crate::vfs::Kstat::new(crate::vfs::FileType::Dir, 0),
|
|
177
179
|
self,
|
|
@@ -181,11 +183,11 @@ mod tests {
|
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
impl InodeOperations for KeepsTimes {
|
|
184
|
-
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat,
|
|
186
|
+
fn getattr(&self, _dentry: &Dentry) -> Result<Kstat, Errno> {
|
|
185
187
|
Ok(Kstat::new(FileType::Dir, 0))
|
|
186
188
|
}
|
|
187
189
|
|
|
188
|
-
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(),
|
|
190
|
+
fn setattr(&self, _dentry: &Dentry, attr: &Iattr) -> Result<(), Errno> {
|
|
189
191
|
*self.0.lock().unwrap() = Some(Iattr {
|
|
190
192
|
size: attr.size,
|
|
191
193
|
atime: attr.atime,
|
|
@@ -221,9 +223,9 @@ mod tests {
|
|
|
221
223
|
#[derive(Default)]
|
|
222
224
|
struct RecordsPaths(Mutex<Vec<String>>);
|
|
223
225
|
|
|
224
|
-
impl Policy for RecordsPaths {
|
|
225
|
-
fn allows(&self,
|
|
226
|
-
self.0.lock().unwrap().push(path.to_string());
|
|
226
|
+
impl Policy<MountRequest<'_>> for RecordsPaths {
|
|
227
|
+
fn allows(&self, request: &MountRequest<'_>) -> bool {
|
|
228
|
+
self.0.lock().unwrap().push(request.path.to_string());
|
|
227
229
|
true
|
|
228
230
|
}
|
|
229
231
|
}
|
|
@@ -235,7 +237,11 @@ mod tests {
|
|
|
235
237
|
fn a_time_set_through_a_descriptor_is_judged_where_it_stands() {
|
|
236
238
|
let policy = Arc::new(RecordsPaths::default());
|
|
237
239
|
let mount = mount_of(tmpfs(), MountAccess::ReadWrite).with_policy(policy.clone());
|
|
238
|
-
let cred = restrict_self(
|
|
240
|
+
let cred = restrict_self(
|
|
241
|
+
&prepare_creds(&[], None),
|
|
242
|
+
[&crate::grant::Grant::Mount(mount.clone())],
|
|
243
|
+
)
|
|
244
|
+
.expect("every Mount stands");
|
|
239
245
|
let root = Path::root(mount.mnt());
|
|
240
246
|
let how = crate::vfs::OpenHow {
|
|
241
247
|
read: true,
|
|
@@ -250,7 +256,7 @@ mod tests {
|
|
|
250
256
|
crate::security::WalkGuard::new([&mount]).check(file.path()),
|
|
251
257
|
policy.0.lock().unwrap().clone()
|
|
252
258
|
),
|
|
253
|
-
(Err(
|
|
259
|
+
(Err(Errno::NotFound), Vec::new()),
|
|
254
260
|
"WalkGuard::check of a descriptor of a file whose name is gone, beneath a Policy, \
|
|
255
261
|
must answer ENOENT without asking the Policy about the path it stood at"
|
|
256
262
|
);
|
|
@@ -258,8 +264,8 @@ mod tests {
|
|
|
258
264
|
|
|
259
265
|
struct RefusesAll;
|
|
260
266
|
|
|
261
|
-
impl Policy for RefusesAll {
|
|
262
|
-
fn allows(&self,
|
|
267
|
+
impl Policy<MountRequest<'_>> for RefusesAll {
|
|
268
|
+
fn allows(&self, _request: &MountRequest<'_>) -> bool {
|
|
263
269
|
false
|
|
264
270
|
}
|
|
265
271
|
}
|
|
@@ -275,13 +281,17 @@ mod tests {
|
|
|
275
281
|
assert_eq!(
|
|
276
282
|
(
|
|
277
283
|
vfs_utimes(
|
|
278
|
-
&restrict_self(
|
|
284
|
+
&restrict_self(
|
|
285
|
+
&prepare_creds(&[], None),
|
|
286
|
+
[&crate::grant::Grant::Mount(mount.clone())],
|
|
287
|
+
)
|
|
288
|
+
.expect("every Mount stands"),
|
|
279
289
|
&Path::root(mount.mnt()),
|
|
280
290
|
×()
|
|
281
291
|
),
|
|
282
292
|
*filesystem.0.lock().unwrap(),
|
|
283
293
|
),
|
|
284
|
-
(Err(
|
|
294
|
+
(Err(Errno::PermissionDenied), None),
|
|
285
295
|
"vfs::vfs_utimes beneath a Policy refusing the path must answer EACCES and leave the \
|
|
286
296
|
Filesystem unasked"
|
|
287
297
|
);
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
//! Filesystem of a third party's checks neither.
|
|
9
9
|
|
|
10
10
|
mod attr;
|
|
11
|
-
mod cred;
|
|
12
11
|
mod dentry;
|
|
13
|
-
mod errno;
|
|
14
12
|
mod file;
|
|
15
13
|
mod inode;
|
|
16
14
|
#[cfg(test)]
|
|
17
15
|
pub(crate) mod kern_path;
|
|
18
16
|
mod mount;
|
|
19
17
|
mod namei;
|
|
18
|
+
mod namespace;
|
|
19
|
+
mod open_files;
|
|
20
20
|
mod openat2;
|
|
21
21
|
mod path;
|
|
22
22
|
mod readdir;
|
|
@@ -31,13 +31,11 @@ pub(crate) use namei::{
|
|
|
31
31
|
|
|
32
32
|
pub(crate) use attr::notify_change;
|
|
33
33
|
pub use attr::{Iattr, SetTime};
|
|
34
|
-
pub(crate) use cred::VmCommitted;
|
|
35
|
-
pub use cred::{Cred, FileSecurity, SecurityOperations, SecurityPath};
|
|
36
34
|
pub use dentry::{Dentry, DentryOperations};
|
|
37
|
-
pub use errno::FilesystemError;
|
|
38
35
|
pub(crate) use file::alloc_file_pseudo;
|
|
39
36
|
pub use file::{
|
|
40
37
|
generic_file_llseek, generic_write_sync, FMode, File, FileOperations, Kiocb, PollMask, Whence,
|
|
38
|
+
OFFSET_MAX,
|
|
41
39
|
};
|
|
42
40
|
pub use inode::{Finish, Identity, Inode, InodeOperations, Lookup, Mask, RenameFlag};
|
|
43
41
|
pub use mount::VfsMount;
|
|
@@ -45,15 +43,20 @@ pub use namei::{
|
|
|
45
43
|
do_file_open, filename_linkat, filename_mkdirat, filename_renameat2, filename_rmdir,
|
|
46
44
|
filename_symlinkat, filename_unlinkat,
|
|
47
45
|
};
|
|
46
|
+
pub(crate) use namespace::MntNamespace;
|
|
47
|
+
pub use open_files::OpenFiles;
|
|
48
48
|
pub use openat2::{build_open_flags, OpenFlags, OpenHow};
|
|
49
49
|
pub use path::{Path, Start};
|
|
50
50
|
pub use readdir::{
|
|
51
51
|
dir_emit_dots, generic_read_dir, verify_dirent_name, DirContext, DirEmit, DirEntry,
|
|
52
52
|
};
|
|
53
|
-
pub use stat::{do_readlinkat, vfs_fstatat, FileType, Kstat};
|
|
53
|
+
pub use stat::{cp_new_stat, do_readlinkat, get_anon_bdev, ino_of, vfs_fstatat, FileType, Kstat};
|
|
54
|
+
pub(crate) use super_block::MADE_ROOT;
|
|
54
55
|
pub use super_block::{FileSystemType, SuperBlock};
|
|
55
56
|
pub use utimes::{do_utimes_fd, do_utimes_path};
|
|
56
57
|
|
|
58
|
+
use crate::Errno;
|
|
59
|
+
|
|
57
60
|
/// Linux's limits on a path, its terminating NUL counted, and on one name
|
|
58
61
|
/// within it.
|
|
59
62
|
pub const PATH_MAX: usize = 4096;
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
//! Waiting for what another thread brings, as Linux's wait queues and
|
|
2
|
+
//! `do_poll` are: a producer wakes the queue its event stands on, and a
|
|
3
|
+
//! poller that registered on that queue looks again. A wait ends once its run
|
|
4
|
+
//! is to stop, as `do_poll`'s interruptible sleep ends on a pending signal; the
|
|
5
|
+
//! only signal a run receives is the one that stops it. It waits through the
|
|
6
|
+
//! registered Blocking, as a lock's slow path does.
|
|
7
|
+
|
|
8
|
+
use std::sync::{Arc, Condvar, Mutex, MutexGuard, PoisonError};
|
|
9
|
+
use std::task::Waker;
|
|
10
|
+
use std::time::Instant;
|
|
11
|
+
|
|
12
|
+
use crate::sched;
|
|
13
|
+
use crate::Errno;
|
|
14
|
+
|
|
15
|
+
/// Where the waiters for one event stand, as Linux's `wait_queue_head_t`.
|
|
16
|
+
#[derive(Default)]
|
|
17
|
+
pub struct WaitQueueHead {
|
|
18
|
+
waiters: Mutex<Vec<Arc<Waiter>>>,
|
|
19
|
+
/// The tasks waiting here, each woken once and then gone, as an entry
|
|
20
|
+
/// `init_waitqueue_func_entry` makes with `autoremove_wake_function`.
|
|
21
|
+
tasks: Mutex<Vec<Waker>>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
impl WaitQueueHead {
|
|
25
|
+
/// Wake every waiter standing here, as `wake_up` does once the event
|
|
26
|
+
/// arrived.
|
|
27
|
+
pub fn wake_up(&self) {
|
|
28
|
+
for waiter in self.waiters().iter() {
|
|
29
|
+
waiter.wake();
|
|
30
|
+
}
|
|
31
|
+
let tasks = std::mem::take(&mut *self.tasks.lock().unwrap_or_else(PoisonError::into_inner));
|
|
32
|
+
for task in tasks {
|
|
33
|
+
task.wake();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// Have the task `waker` stands for woken by the next wake here, once, as
|
|
38
|
+
/// `add_wait_queue` adds an entry whose wake function is the task's; a
|
|
39
|
+
/// task already waiting is not added twice.
|
|
40
|
+
pub(crate) fn add(&self, waker: &Waker) {
|
|
41
|
+
let mut tasks = self.tasks.lock().unwrap_or_else(PoisonError::into_inner);
|
|
42
|
+
if !tasks.iter().any(|task| task.will_wake(waker)) {
|
|
43
|
+
tasks.push(waker.clone());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fn waiters(&self) -> MutexGuard<'_, Vec<Arc<Waiter>>> {
|
|
48
|
+
self.waiters.lock().unwrap_or_else(PoisonError::into_inner)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/// One sleeping poller, as a `poll_wqueues` entry: a wake that arrives
|
|
53
|
+
/// before it sleeps is kept, so none is lost.
|
|
54
|
+
#[derive(Default)]
|
|
55
|
+
pub(crate) struct Waiter {
|
|
56
|
+
woken: Mutex<bool>,
|
|
57
|
+
wake: Condvar,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
impl Waiter {
|
|
61
|
+
pub(crate) fn wake(&self) {
|
|
62
|
+
*self.woken() = true;
|
|
63
|
+
self.wake.notify_all();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/// Sleep until woken or `until` passes.
|
|
67
|
+
fn sleep_until(&self, until: Option<Instant>) {
|
|
68
|
+
let mut woken = self.woken();
|
|
69
|
+
while !*woken {
|
|
70
|
+
woken = match until {
|
|
71
|
+
Some(at) => {
|
|
72
|
+
let left = at.saturating_duration_since(Instant::now());
|
|
73
|
+
if left.is_zero() {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
self.wake
|
|
77
|
+
.wait_timeout(woken, left)
|
|
78
|
+
.unwrap_or_else(PoisonError::into_inner)
|
|
79
|
+
.0
|
|
80
|
+
}
|
|
81
|
+
None => self
|
|
82
|
+
.wake
|
|
83
|
+
.wait(woken)
|
|
84
|
+
.unwrap_or_else(PoisonError::into_inner),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
*woken = false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
fn woken(&self) -> MutexGuard<'_, bool> {
|
|
91
|
+
self.woken.lock().unwrap_or_else(PoisonError::into_inner)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/// The queues one poll registered on, as Linux's `poll_table`; dropping it
|
|
96
|
+
/// leaves each, as `poll_freewait` does.
|
|
97
|
+
pub struct PollTable {
|
|
98
|
+
waiter: Arc<Waiter>,
|
|
99
|
+
queues: Vec<Arc<WaitQueueHead>>,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
impl Drop for PollTable {
|
|
103
|
+
fn drop(&mut self) {
|
|
104
|
+
for queue in &self.queues {
|
|
105
|
+
queue
|
|
106
|
+
.waiters()
|
|
107
|
+
.retain(|waiter| !Arc::ptr_eq(waiter, &self.waiter));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/// Have the poll `table` stands for woken by `queue`, as a file's `->poll`
|
|
113
|
+
/// calls `poll_wait`; a poll that will not sleep passes no table.
|
|
114
|
+
pub fn poll_wait(queue: &Arc<WaitQueueHead>, table: Option<&mut PollTable>) {
|
|
115
|
+
if let Some(table) = table {
|
|
116
|
+
queue.waiters().push(table.waiter.clone());
|
|
117
|
+
table.queues.push(queue.clone());
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/// Ask `poll` until it finds something ready, `end` passes, or the run is to
|
|
122
|
+
/// stop, as Linux's `do_poll` asks each file again whenever a queue it
|
|
123
|
+
/// registered on wakes. `end` is read afresh each turn, so a wait whose
|
|
124
|
+
/// soonest due moves earlier, as an exchange's next timeout starting once the
|
|
125
|
+
/// last ends, sleeps only to the new one. The first ask registers through the
|
|
126
|
+
/// table it is handed; nothing ready by `end` answers `None`, and a run that is
|
|
127
|
+
/// to stop answers EINTR.
|
|
128
|
+
pub fn do_poll<T>(
|
|
129
|
+
end: impl Fn() -> Option<Instant>,
|
|
130
|
+
mut poll: impl FnMut(Option<&mut PollTable>) -> Option<T>,
|
|
131
|
+
) -> Result<Option<T>, Errno> {
|
|
132
|
+
let mut table = PollTable {
|
|
133
|
+
waiter: Arc::default(),
|
|
134
|
+
queues: Vec::new(),
|
|
135
|
+
};
|
|
136
|
+
if let Some(ready) = poll(Some(&mut table)) {
|
|
137
|
+
return Ok(Some(ready));
|
|
138
|
+
}
|
|
139
|
+
let mut answer = Ok(None);
|
|
140
|
+
sched::sleep_on(&table.waiter, || {
|
|
141
|
+
sched::schedule(&mut || loop {
|
|
142
|
+
if sched::fatal_signal_pending() {
|
|
143
|
+
answer = Err(Errno::Interrupted);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let end = end();
|
|
147
|
+
if end.is_some_and(|end| Instant::now() >= end) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let until = match (end, sched::deadline()) {
|
|
151
|
+
(Some(end), Some(deadline)) => Some(end.min(deadline)),
|
|
152
|
+
(end, deadline) => end.or(deadline),
|
|
153
|
+
};
|
|
154
|
+
table.waiter.sleep_until(until);
|
|
155
|
+
if let Some(ready) = poll(None) {
|
|
156
|
+
answer = Ok(Some(ready));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
answer
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#[cfg(test)]
|
|
165
|
+
mod tests {
|
|
166
|
+
use std::sync::atomic::{AtomicBool, Ordering};
|
|
167
|
+
use std::thread;
|
|
168
|
+
use std::time::Duration;
|
|
169
|
+
|
|
170
|
+
use super::*;
|
|
171
|
+
use crate::sched::testing::{count_waits, join, within_max_wait};
|
|
172
|
+
use crate::sched::{run_task, Task};
|
|
173
|
+
|
|
174
|
+
/// An end `after` from now, the same each time it is read.
|
|
175
|
+
fn end_after(after: Duration) -> impl Fn() -> Option<Instant> {
|
|
176
|
+
let end = Instant::now() + after;
|
|
177
|
+
move || Some(end)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// @behavior RT-335
|
|
181
|
+
#[test]
|
|
182
|
+
fn a_poll_looks_again_once_the_queue_it_registered_on_wakes() {
|
|
183
|
+
let queue = Arc::new(WaitQueueHead::default());
|
|
184
|
+
let ready = Arc::new(AtomicBool::new(false));
|
|
185
|
+
let producer = {
|
|
186
|
+
let (queue, ready) = (queue.clone(), ready.clone());
|
|
187
|
+
thread::spawn(move || {
|
|
188
|
+
while queue.waiters().is_empty() {
|
|
189
|
+
thread::yield_now();
|
|
190
|
+
}
|
|
191
|
+
// The poller has asked once and gone to sleep by now, so only
|
|
192
|
+
// the wake makes it look again before its deadline.
|
|
193
|
+
thread::sleep(Duration::from_millis(50));
|
|
194
|
+
ready.store(true, Ordering::SeqCst);
|
|
195
|
+
queue.wake_up();
|
|
196
|
+
})
|
|
197
|
+
};
|
|
198
|
+
let started = Instant::now();
|
|
199
|
+
let answer = within_max_wait(|| {
|
|
200
|
+
do_poll(
|
|
201
|
+
|| None,
|
|
202
|
+
|table| {
|
|
203
|
+
poll_wait(&queue, table);
|
|
204
|
+
ready.load(Ordering::SeqCst).then_some("ready")
|
|
205
|
+
},
|
|
206
|
+
)
|
|
207
|
+
});
|
|
208
|
+
let spent = started.elapsed();
|
|
209
|
+
join("the producer", producer);
|
|
210
|
+
assert!(
|
|
211
|
+
answer == Ok(Some("ready"))
|
|
212
|
+
&& queue.waiters().is_empty()
|
|
213
|
+
&& spent < Duration::from_secs(5),
|
|
214
|
+
"do_poll with no timeout over a queue another thread wakes once its event arrives \
|
|
215
|
+
must answer what the poll then finds at once, and leave the queue, got {answer:?} \
|
|
216
|
+
after {spent:?}"
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/// A task's wake, counted.
|
|
221
|
+
#[derive(Default)]
|
|
222
|
+
struct CountsWakes(std::sync::atomic::AtomicUsize);
|
|
223
|
+
|
|
224
|
+
impl std::task::Wake for CountsWakes {
|
|
225
|
+
fn wake(self: Arc<Self>) {
|
|
226
|
+
self.0.fetch_add(1, Ordering::SeqCst);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
#[test]
|
|
231
|
+
fn a_task_waiting_on_a_queue_is_woken_once_by_its_next_wake() {
|
|
232
|
+
let queue = WaitQueueHead::default();
|
|
233
|
+
let wakes = Arc::new(CountsWakes::default());
|
|
234
|
+
let waker = Waker::from(wakes.clone());
|
|
235
|
+
queue.add(&waker);
|
|
236
|
+
queue.add(&waker);
|
|
237
|
+
queue.wake_up();
|
|
238
|
+
queue.wake_up();
|
|
239
|
+
assert_eq!(
|
|
240
|
+
wakes.0.load(Ordering::SeqCst),
|
|
241
|
+
1,
|
|
242
|
+
"a task added to a wait queue twice must be woken once by the next wake_up and not \
|
|
243
|
+
by a later one, as an autoremoving wait entry leaves once it wakes"
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// @behavior RT-335
|
|
248
|
+
#[test]
|
|
249
|
+
fn a_poll_finding_nothing_answers_none_once_its_timeout_passes() {
|
|
250
|
+
let started = Instant::now();
|
|
251
|
+
let answer = do_poll(end_after(Duration::from_millis(20)), |_| None::<()>);
|
|
252
|
+
assert!(
|
|
253
|
+
answer == Ok(None) && started.elapsed() >= Duration::from_millis(20),
|
|
254
|
+
"do_poll with a 20 ms timeout over nothing ready must answer None once it passes, \
|
|
255
|
+
got {answer:?} after {:?}",
|
|
256
|
+
started.elapsed()
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// @behavior RT-395
|
|
261
|
+
#[test]
|
|
262
|
+
fn a_poll_sleeps_only_to_its_end_once_a_wake_moves_it_earlier() {
|
|
263
|
+
let queue = Arc::new(WaitQueueHead::default());
|
|
264
|
+
let moved = Arc::new(Mutex::new(None::<Instant>));
|
|
265
|
+
let far = Instant::now() + Duration::from_secs(30);
|
|
266
|
+
let waker = {
|
|
267
|
+
let (queue, moved) = (queue.clone(), moved.clone());
|
|
268
|
+
thread::spawn(move || {
|
|
269
|
+
while queue.waiters().is_empty() {
|
|
270
|
+
thread::yield_now();
|
|
271
|
+
}
|
|
272
|
+
thread::sleep(Duration::from_millis(50));
|
|
273
|
+
*moved.lock().unwrap() = Some(Instant::now() + Duration::from_millis(20));
|
|
274
|
+
queue.wake_up();
|
|
275
|
+
})
|
|
276
|
+
};
|
|
277
|
+
let started = Instant::now();
|
|
278
|
+
let answer = within_max_wait(|| {
|
|
279
|
+
do_poll(
|
|
280
|
+
|| Some(moved.lock().unwrap().unwrap_or(far)),
|
|
281
|
+
|table| {
|
|
282
|
+
poll_wait(&queue, table);
|
|
283
|
+
None::<()>
|
|
284
|
+
},
|
|
285
|
+
)
|
|
286
|
+
});
|
|
287
|
+
let spent = started.elapsed();
|
|
288
|
+
join("the waker", waker);
|
|
289
|
+
assert!(
|
|
290
|
+
answer == Ok(None) && spent < Duration::from_secs(5),
|
|
291
|
+
"do_poll over nothing ready, its 30 s end moved to 20 ms after a wake, must answer \
|
|
292
|
+
None once the moved end passes, got {answer:?} after {spent:?}"
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// @behavior RT-267
|
|
297
|
+
#[test]
|
|
298
|
+
fn a_poll_ends_with_eintr_once_its_thread_is_interrupted() {
|
|
299
|
+
let (task, waiting) = (Arc::new(Mutex::new(None)), Arc::new(AtomicBool::new(false)));
|
|
300
|
+
let poller = {
|
|
301
|
+
let (task, waiting) = (task.clone(), waiting.clone());
|
|
302
|
+
thread::spawn(move || {
|
|
303
|
+
run_task(Some(Instant::now() + Duration::from_secs(10)), || {
|
|
304
|
+
*task.lock().unwrap() = Some(Task::current());
|
|
305
|
+
do_poll(
|
|
306
|
+
|| None,
|
|
307
|
+
|_| {
|
|
308
|
+
waiting.store(true, Ordering::SeqCst);
|
|
309
|
+
None::<()>
|
|
310
|
+
},
|
|
311
|
+
)
|
|
312
|
+
})
|
|
313
|
+
})
|
|
314
|
+
};
|
|
315
|
+
crate::sched::testing::wait_until("the poll", || waiting.load(Ordering::SeqCst));
|
|
316
|
+
// The poller has asked once and gone to sleep by now, so only a wake
|
|
317
|
+
// from the interrupt ends it before its deadline.
|
|
318
|
+
thread::sleep(Duration::from_millis(50));
|
|
319
|
+
task.lock().unwrap().as_ref().unwrap().interrupt();
|
|
320
|
+
let started = Instant::now();
|
|
321
|
+
let answer = join("the interrupted poll", poller);
|
|
322
|
+
assert!(
|
|
323
|
+
answer == Err(Errno::Interrupted) && started.elapsed() < Duration::from_secs(1),
|
|
324
|
+
"do_poll with no timeout, its thread interrupted, must answer EINTR without waiting \
|
|
325
|
+
for its deadline, got {answer:?} after {:?}",
|
|
326
|
+
started.elapsed()
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// @behavior RT-267
|
|
331
|
+
#[test]
|
|
332
|
+
fn a_poll_ends_with_eintr_once_its_deadline_passes() {
|
|
333
|
+
let answer = run_task(Some(Instant::now() + Duration::from_millis(20)), || {
|
|
334
|
+
do_poll(|| None, |_| None::<()>)
|
|
335
|
+
});
|
|
336
|
+
assert_eq!(
|
|
337
|
+
answer,
|
|
338
|
+
Err(Errno::Interrupted),
|
|
339
|
+
"do_poll with no timeout, past its run's deadline, must answer EINTR"
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// @behavior RT-336
|
|
344
|
+
#[test]
|
|
345
|
+
fn a_poll_that_sleeps_waits_through_the_registered_blocking() {
|
|
346
|
+
let waits = count_waits();
|
|
347
|
+
let _ = do_poll(end_after(Duration::from_millis(1)), |_| None::<()>);
|
|
348
|
+
let _ = do_poll(end_after(Duration::from_secs(1)), |_| Some(()));
|
|
349
|
+
assert_eq!(
|
|
350
|
+
waits.load(Ordering::SeqCst),
|
|
351
|
+
1,
|
|
352
|
+
"do_poll must sleep through the registered Blocking only when its first ask finds \
|
|
353
|
+
nothing ready"
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.21.0](https://github.com/elct9620/kobako/compare/kobako-transport-v0.20.0...kobako-transport-v0.21.0) (2026-11-18)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* **transport:** kobako_transport::envelope::Reply is CallReply.
|
|
9
|
+
* **transport:** call Driver::from_file in place of Driver::new;
|
|
10
|
+
* **transport:** a Guest Binary built against ABI 5 is refused at construction. Rebuild it against kobako-core, whose export_guest! emits the new names. kobako-transport drops ABI_VERSION as a u32, FRAME_LEN_SIZE, MAX_FRAME_LEN, pack_ptr_len, and unpack_ptr_len, and names the ABI through ABI_VERSION ("0.6.0"), GUEST_INTERFACE, HOST_INTERFACE, DOWNCALL, UPCALL, and PREAMBLE. kobako-core drops alloc; answer returns the return area's address.
|
|
11
|
+
* **transport:** kobako_transport::abi::MAX_DISPATCH_PAYLOAD is renamed to MAX_MESSAGE_LEN; its value is unchanged.
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **transport:** carry the Guest ABI in the Canonical ABI's core shape ([34b9560](https://github.com/elct9620/kobako/commit/34b956001a05e15fe29febd7098b2ceb054e1bab))
|
|
16
|
+
* **transport:** expose the Capability Handle id bound the Envelope holds ([8a48012](https://github.com/elct9620/kobako/commit/8a48012cbac62c6a4a67c0c47664ee03a8089605))
|
|
17
|
+
* **transport:** spell once the form of a name a guest interns ([95c10bc](https://github.com/elct9620/kobako/commit/95c10bcf7180fc0e5ef432a9935ce3f856c75c9f))
|
|
18
|
+
* **transport:** spell once the names a Panic carries that a Frontend reads ([d1fb291](https://github.com/elct9620/kobako/commit/d1fb291082abcc376fc17d2f53b2e7d69dbf5da2))
|
|
19
|
+
* **transport:** spell once the Service and entrypoint names a Panic carries ([fd09028](https://github.com/elct9620/kobako/commit/fd09028dee973397c66eb2029f7fd75bf6e7ee26))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **guest:** say a guest supports no block, as the glossary words an Unsupported ([3aa9a78](https://github.com/elct9620/kobako/commit/3aa9a7844780ba095fa2d197c3ab1a163a33dce6))
|
|
25
|
+
* **transport:** refuse a Call target past the wire's Handle id range ([8a9b169](https://github.com/elct9620/kobako/commit/8a9b1694f96dc0769fff3251a76c3e1cb52a4866))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Code Refactoring
|
|
29
|
+
|
|
30
|
+
* **transport:** load a Driver from its file, and read an origin as a lookup that may miss ([4ec8d79](https://github.com/elct9620/kobako/commit/4ec8d792ddf14bb21cfd36437b64b2389ee6df89))
|
|
31
|
+
* **transport:** name a Call's reply CallReply beside YieldReply and CompileReply ([f34063e](https://github.com/elct9620/kobako/commit/f34063ee94edb723800b4a0670cf912aa1a445e0))
|
|
32
|
+
* **transport:** name the message cap by what it bounds ([133e1c1](https://github.com/elct9620/kobako/commit/133e1c151506a1f41d5f2d17ac2678648c6ed262))
|
|
33
|
+
|
|
3
34
|
## [0.20.0](https://github.com/elct9620/kobako/compare/kobako-transport-v0.19.0...kobako-transport-v0.20.0) (2026-11-07)
|
|
4
35
|
|
|
5
36
|
|
|
@@ -15,9 +15,8 @@ same in every assembly. This crate is both of them, and nothing else.
|
|
|
15
15
|
The envelope covers the downcall's and the upcall's requests under one
|
|
16
16
|
tag registry. It also covers a dispatch round-trip, how an invocation
|
|
17
17
|
ended, and what an invocation is handed, and re-exports every message
|
|
18
|
-
type. The ABI values are the version, the
|
|
19
|
-
|
|
20
|
-
message size cap.
|
|
18
|
+
type. The ABI values are the version, the interface and function
|
|
19
|
+
names it carries, and the message size cap.
|
|
21
20
|
|
|
22
21
|
## Opaque Payload
|
|
23
22
|
|
|
@@ -52,7 +51,7 @@ reaches the same types through `kobako-core`.
|
|
|
52
51
|
|
|
53
52
|
```toml
|
|
54
53
|
[dependencies]
|
|
55
|
-
kobako-transport = "0.
|
|
54
|
+
kobako-transport = "0.21.0" # x-release-please-version
|
|
56
55
|
```
|
|
57
56
|
|
|
58
57
|
## License
|