Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/fspy/src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{io, path::Path};

#[cfg(target_os = "linux")]
use fspy_seccomp_unotify::supervisor::supervise;
use fspy_shared::ipc::{NativeString, PathAccess, channel::channel};
use fspy_shared::ipc::{NativeStr, PathAccess, channel::channel};
#[cfg(target_os = "macos")]
use fspy_shared_unix::payload::Artifacts;
use fspy_shared_unix::{
Expand All @@ -28,12 +28,12 @@ use crate::{
ipc::{OwnedReceiverLockGuard, SHM_CAPACITY},
};

#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct SpyImpl {
#[cfg(target_os = "macos")]
artifacts: Artifacts,

preload_path: NativeString,
preload_path: Box<NativeStr>,
}

const PRELOAD_CDYLIB_BINARY: &[u8] = include_bytes!(env!("CARGO_CDYLIB_FILE_FSPY_PRELOAD_UNIX"));
Expand Down
8 changes: 5 additions & 3 deletions crates/fspy_preload_unix/src/client/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
pub mod convert;
pub mod raw_exec;

use std::{fmt::Debug, num::NonZeroUsize, sync::OnceLock};
use std::{
ffi::OsStr, fmt::Debug, num::NonZeroUsize, os::unix::ffi::OsStrExt as _, sync::OnceLock,
};

use bincode::{enc::write::SizeWriter, encode_into_slice, encode_into_writer};
use convert::{ToAbsolutePath, ToAccessMode};
Expand Down Expand Up @@ -55,7 +57,7 @@ impl Client {
// ipc channel not available, skip sending
return Ok(());
};
let path = path_access.path.as_bstr();
let path = path_access.path.as_os_str().as_bytes();
if path.starts_with(b"/dev/")
|| (cfg!(target_os = "linux")
&& (path.starts_with(b"/proc/") || path.starts_with(b"/sys/")))
Expand Down Expand Up @@ -101,7 +103,7 @@ impl Client {
let Some(abs_path) = abs_path else {
return Ok(Ok(()));
};
Ok(self.send(PathAccess { mode, path: abs_path.into() }))
Ok(self.send(PathAccess { mode, path: OsStr::from_bytes(abs_path).into() }))
})
}??;

Expand Down
2 changes: 1 addition & 1 deletion crates/fspy_shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ allocator-api2 = { workspace = true }
bincode = { workspace = true }
bitflags = { workspace = true }
bstr = { workspace = true }
bytemuck = { workspace = true, features = ["must_cast"] }
bytemuck = { workspace = true, features = ["must_cast", "derive"] }
shared_memory = { workspace = true, features = ["logging"] }
thiserror = { workspace = true }
tracing = { workspace = true }
Expand Down
6 changes: 3 additions & 3 deletions crates/fspy_shared/src/ipc/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use shm_io::{ShmReader, ShmWriter};
use tracing::debug;
use uuid::Uuid;

use super::NativeString;
use super::NativeStr;

/// Serializable configuration to create channel senders.
#[derive(Encode, Decode, Clone, Debug)]
pub struct ChannelConf {
lock_file_path: NativeString,
lock_file_path: Box<NativeStr>,
shm_id: Arc<str>,
shm_size: usize,
}
Expand Down Expand Up @@ -69,7 +69,7 @@ impl ChannelConf {

pub struct Sender {
writer: ShmWriter<Shmem>,
lock_file_path: NativeString,
lock_file_path: Box<NativeStr>,
lock_file: File,
}

Expand Down
8 changes: 4 additions & 4 deletions crates/fspy_shared/src/ipc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::fmt::Debug;

use bincode::{BorrowDecode, Encode, config::Configuration};
use bitflags::bitflags;
pub use native_str::{NativeStr, NativeString};
pub use native_str::NativeStr;

pub const BINCODE_CONFIG: Configuration = bincode::config::standard();

Expand Down Expand Up @@ -35,16 +35,16 @@ impl Debug for AccessMode {
#[derive(Encode, BorrowDecode, Debug, Clone, Copy)]
pub struct PathAccess<'a> {
pub mode: AccessMode,
pub path: NativeStr<'a>,
pub path: &'a NativeStr,
// TODO: add follow_symlinks (O_NOFOLLOW)
}

impl<'a> PathAccess<'a> {
pub fn read(path: impl Into<NativeStr<'a>>) -> Self {
pub fn read(path: impl Into<&'a NativeStr>) -> Self {
Self { mode: AccessMode::READ, path: path.into() }
}

pub fn read_dir(path: impl Into<NativeStr<'a>>) -> Self {
pub fn read_dir(path: impl Into<&'a NativeStr>) -> Self {
Self { mode: AccessMode::READ_DIR, path: path.into() }
}
}
Loading