-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathaccess.rs
More file actions
28 lines (25 loc) · 840 Bytes
/
access.rs
File metadata and controls
28 lines (25 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use fspy_shared::ipc::AccessMode;
use libc::{c_char, c_int};
use crate::{
client::{convert::PathAt, handle_open},
macros::intercept,
};
intercept!(access(64): unsafe extern "C" fn(pathname: *const c_char, mode: c_int) -> c_int);
unsafe extern "C" fn access(pathname: *const c_char, mode: c_int) -> c_int {
unsafe {
handle_open(pathname, AccessMode::Read);
}
unsafe { access::original()(pathname, mode) }
}
intercept!(faccessat(64): unsafe extern "C" fn(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int);
unsafe extern "C" fn faccessat(
dirfd: c_int,
pathname: *const c_char,
mode: c_int,
flags: c_int,
) -> c_int {
unsafe {
handle_open(PathAt(dirfd, pathname), AccessMode::Read);
}
unsafe { faccessat::original()(dirfd, pathname, mode, flags) }
}