Skip to content

Commit 717a5db

Browse files
committed
yanix: Provide faccessat.
1 parent 144e935 commit 717a5db

File tree

1 file changed

+25
-0
lines changed
  • crates/wasi-common/yanix/src

1 file changed

+25
-0
lines changed

crates/wasi-common/yanix/src/file.rs

+25
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ bitflags! {
3131
}
3232
}
3333

34+
bitflags! {
35+
pub struct Access: libc::c_int {
36+
const R_OK = libc::R_OK;
37+
const W_OK = libc::W_OK;
38+
const X_OK = libc::X_OK;
39+
const F_OK = libc::F_OK;
40+
}
41+
}
42+
3443
bitflags! {
3544
pub struct AtFlags: libc::c_int {
3645
const REMOVEDIR = libc::AT_REMOVEDIR;
@@ -315,6 +324,22 @@ pub unsafe fn fstat(fd: RawFd) -> Result<stat> {
315324
Ok(filestat.assume_init())
316325
}
317326

327+
pub unsafe fn faccessat<P: AsRef<Path>>(
328+
dirfd: RawFd,
329+
path: P,
330+
access: Access,
331+
flags: AtFlags,
332+
) -> Result<()> {
333+
let path = cstr(path)?;
334+
from_result(libc::faccessat(
335+
dirfd as libc::c_int,
336+
path.as_ptr(),
337+
access.bits(),
338+
flags.bits(),
339+
))?;
340+
Ok(())
341+
}
342+
318343
/// `fionread()` function, equivalent to `ioctl(fd, FIONREAD, *bytes)`.
319344
pub unsafe fn fionread(fd: RawFd) -> Result<u32> {
320345
let mut nread: libc::c_int = 0;

0 commit comments

Comments
 (0)