Skip to content

fix: always set directory open flag in open_ambient_dir#276

Merged
sunfishcode merged 1 commit intobytecodealliance:mainfrom
rvolosatovs:fix/open_ambient_dir
Sep 29, 2022
Merged

fix: always set directory open flag in open_ambient_dir#276
sunfishcode merged 1 commit intobytecodealliance:mainfrom
rvolosatovs:fix/open_ambient_dir

Conversation

@rvolosatovs
Copy link
Member

Note, that this is the only way to actually acquire a directory from AmbientAuthority when running in Wasmtime.
Fix for that is in-progress at bytecodealliance/wasmtime#4947

All this should do is fail if the FD is not a directory. Currently Wasmtime Snapshot 1 implementation incorrectly uses this bit value to determine whether to open the FD in "file mode" or "directory mode". Setting this bit is a workaround for that issue, but it's also just generally a good thing to do.

@rvolosatovs
Copy link
Member Author

CI failures seem unrelated:

 [cap-primitives 1.0.0-rc1] For more information about this error, try `rustc --explain E0554`.
error[E0308]: arguments to this function are incorrect
    --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rustix-0.36.0-rc1/src/backend/libc/fs/makedev.rs:15:14
     |
15   |     unsafe { c::makedev(maj as i32, min as i32) }
     |              ^^^^^^^^^^ ----------  ---------- expected `u32`, found `i32`
     |                         |
     |                         expected `u32`, found `i32`
     |
note: function defined here
    --> /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.133/src/unix/linux_like/android/mod.rs:2794:20
     |
2794 |     pub {const} fn makedev(ma: ::c_uint, mi: ::c_uint) -> ::dev_t {
     |                    ^^^^^^^
help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
     |
15   |     unsafe { c::makedev((maj as i32).try_into().unwrap(), min as i32) }
     |                         +          +++++++++++++++++++++
help: you can convert an `i32` to a `u32` and panic if the converted value doesn't fit
     |
15   |     unsafe { c::makedev(maj as i32, (min as i32).try_into().unwrap()) }
     |                                     +          +++++++++++++++++++++

@sunfishcode
Copy link
Member

The makedev error in CI is indeed unrelated, and it's now fixed on main. Would you mind rebasing this?

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
@rvolosatovs
Copy link
Member Author

@sunfishcode updated, PTAL

@sunfishcode sunfishcode merged commit 1ee6daf into bytecodealliance:main Sep 29, 2022
@sunfishcode
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants