Skip to content

add access FFI shim function for unix/posix #4256

Open
@programmerjake

Description

@programmerjake

I'm trying to use which, but it errors:

error: unsupported operation: can't call foreign function `access` on OS `linux`
   --> /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.38.31/src/backend/libc/fs/syscalls.rs:723:18
    |
723 |     unsafe { ret(c::access(c_str(path), access.bits())) }
    |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't call foreign function `access` on OS `linux`
    |
    = help: if this is a basic API commonly used on this target, please report an issue with Miri
    = help: however, note that Miri does not aim to support every FFI function out there; for instance, we will not support APIs for things such as GUIs, scripting languages, or databases
    = note: BACKTRACE on thread `util::ready_val`:
    = note: inside `rustix::backend::fs::syscalls::access` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.38.31/src/backend/libc/fs/syscalls.rs:723:18: 723:55
    = note: inside closure at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.38.31/src/fs/abs.rs:243:33: 243:76
    = note: inside `rustix::path::arg::with_c_str::<(), {closure@rustix::fs::abs::access<&std::path::Path>::{closure#0}}>` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.38.31/src/path/arg.rs:1046:18: 1046:22
    = note: inside `<&std::path::Path as rustix::path::arg::Arg>::into_with_c_str::<(), {closure@rustix::fs::abs::access<&std::path::Path>::{closure#0}}>` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.38.31/src/path/arg.rs:378:9: 378:51
    = note: inside `rustix::fs::abs::access::<&std::path::Path>` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-0.38.31/src/fs/abs.rs:243:5: 243:77
    = note: inside `<which::checker::ExecutableChecker as which::finder::Checker>::is_valid` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/which-6.0.1/src/checker.rs:17:9: 17:48
    = note: inside closure at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/which-6.0.1/src/checker.rs:78:44: 78:66
    = note: inside `<std::slice::Iter<'_, std::boxed::Box<dyn which::finder::Checker>> as std::iter::Iterator>::all::<{closure@<which::checker::CompositeChecker as which::finder::Checker>::is_valid::{closure#0}}>` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/iter/macros.rs:268:25: 268:29
    = note: inside `<which::checker::CompositeChecker as which::finder::Checker>::is_valid` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/which-6.0.1/src/checker.rs:78:9: 78:67
    = note: inside closure at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/which-6.0.1/src/finder.rs:98:30: 98:56
    = note: inside `std::ops::function::impls::<impl std::ops::FnMut<(&std::path::PathBuf,)> for &mut {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>::call_mut` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:294:13: 294:35
    = note: inside closure at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2829:20: 2829:33
    = note: inside closure at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:95:21: 95:35
    = note: inside `<std::vec::IntoIter<std::path::PathBuf> as std::iter::Iterator>::try_fold::<(), {closure@std::iter::adapters::map::map_try_fold<'_, std::path::PathBuf, std::path::PathBuf, (), std::ops::ControlFlow<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}, {closure@std::iter::Iterator::find::check<std::path::PathBuf, &mut {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>::{closure#0}}>::{closure#0}}, std::ops::ControlFlow<std::path::PathBuf>>` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/vec/into_iter.rs:346:25: 346:38
    = note: inside `<std::iter::Map<std::vec::IntoIter<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}> as std::iter::Iterator>::try_fold::<(), {closure@std::iter::Iterator::find::check<std::path::PathBuf, &mut {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>::{closure#0}}, std::ops::ControlFlow<std::path::PathBuf>>` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:121:9: 121:63
    = note: inside `<std::iter::Map<std::vec::IntoIter<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}> as std::iter::Iterator>::find::<&mut {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:2833:9: 2833:44
    = note: inside `either::iterator::<impl std::iter::Iterator for either::Either<std::iter::Once<std::path::PathBuf>, std::iter::Map<std::vec::IntoIter<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}>>>::find::<&mut {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/either-1.13.0/src/iterator.rs:117:43: 117:64
    = note: inside `<std::iter::Filter<either::Either<std::iter::Once<std::path::PathBuf>, std::iter::Map<std::vec::IntoIter<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}>>, {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}> as std::iter::Iterator>::next` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/filter.rs:98:9: 98:44
    = note: inside `<std::iter::Map<std::iter::Filter<either::Either<std::iter::Once<std::path::PathBuf>, std::iter::Map<std::vec::IntoIter<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}>>, {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>, fn(std::path::PathBuf) -> std::path::PathBuf {which::finder::correct_casing}> as std::iter::Iterator>::next` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:107:9: 107:25
    = note: inside closure at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/which-6.0.1/src/lib.rs:59:45: 59:53
    = note: inside `std::result::Result::<std::iter::Map<std::iter::Filter<either::Either<std::iter::Once<std::path::PathBuf>, std::iter::Map<std::vec::IntoIter<std::path::PathBuf>, {closure@which::finder::Finder::path_search_candidates<std::vec::Vec<std::path::PathBuf>>::{closure#0}}>>, {closure@which::finder::Finder::find<std::ffi::OsString, std::ffi::OsString, std::path::PathBuf>::{closure#0}}>, fn(std::path::PathBuf) -> std::path::PathBuf {which::finder::correct_casing}>, which::Error>::and_then::<std::path::PathBuf, {closure@which::which<std::ffi::OsString>::{closure#0}}>` at /home/jacob/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1353:22: 1353:27
    = note: inside `which::which::<std::ffi::OsString>` at /home/jacob/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/which-6.0.1/src/lib.rs:59:5: 59:89

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linuxArea: affects only Linux targetsA-shimsArea: This affects the external function shimsC-enhancementCategory: a PR with an enhancement or an issue tracking an accepted enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions