refactor: resolved cross-platform build warnings and add windows-sys features
- Add conditional attributes to silence dead-code warnings on platform-specific code and fields. - Update target dependencies in pi-walker/Cargo.toml with explicit windows-sys feature sets. - Simplify time cast expressions in linux_reflink and rcopy modules.
This commit is contained in:
@@ -248,14 +248,8 @@ mod imp {
|
|||||||
|
|
||||||
fn set_times_nofollow(path: &Path, meta: &fs::Metadata) -> std::io::Result<()> {
|
fn set_times_nofollow(path: &Path, meta: &fs::Metadata) -> std::io::Result<()> {
|
||||||
let times = [
|
let times = [
|
||||||
libc::timespec {
|
libc::timespec { tv_sec: meta.atime() as _, tv_nsec: meta.atime_nsec() as libc::c_long },
|
||||||
tv_sec: meta.atime() as libc::time_t,
|
libc::timespec { tv_sec: meta.mtime() as _, tv_nsec: meta.mtime_nsec() as libc::c_long },
|
||||||
tv_nsec: meta.atime_nsec() as libc::c_long,
|
|
||||||
},
|
|
||||||
libc::timespec {
|
|
||||||
tv_sec: meta.mtime() as libc::time_t,
|
|
||||||
tv_nsec: meta.mtime_nsec() as libc::c_long,
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
let c_path = CString::new(path.as_os_str().as_bytes())?;
|
let c_path = CString::new(path.as_os_str().as_bytes())?;
|
||||||
// SAFETY: `c_path` and `times` live until the syscall returns; the
|
// SAFETY: `c_path` and `times` live until the syscall returns; the
|
||||||
|
|||||||
@@ -413,11 +413,10 @@ fn filetime_set(path: &Path, mtime: std::time::SystemTime) -> std::io::Result<()
|
|||||||
let dur = mtime
|
let dur = mtime
|
||||||
.duration_since(std::time::UNIX_EPOCH)
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
.map_err(std::io::Error::other)?;
|
.map_err(std::io::Error::other)?;
|
||||||
let times =
|
let times = [libc::timespec { tv_sec: dur.as_secs() as _, tv_nsec: 0 }, libc::timespec {
|
||||||
[libc::timespec { tv_sec: dur.as_secs() as libc::time_t, tv_nsec: 0 }, libc::timespec {
|
tv_sec: dur.as_secs() as _,
|
||||||
tv_sec: dur.as_secs() as libc::time_t,
|
tv_nsec: dur.subsec_nanos() as libc::c_long,
|
||||||
tv_nsec: dur.subsec_nanos() as libc::c_long,
|
}];
|
||||||
}];
|
|
||||||
let c_path = std::ffi::CString::new(path.as_os_str().as_bytes())?;
|
let c_path = std::ffi::CString::new(path.as_os_str().as_bytes())?;
|
||||||
// SAFETY: `c_path` and `times` outlive the syscall; the kernel does
|
// SAFETY: `c_path` and `times` outlive the syscall; the kernel does
|
||||||
// not retain the pointers.
|
// not retain the pointers.
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
//! thread-local context isolated across concurrent pipeline stages and avoids
|
//! thread-local context isolated across concurrent pipeline stages and avoids
|
||||||
//! blocking the async runtime on synchronous utility I/O.
|
//! blocking the async runtime on synchronous utility I/O.
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
use std::ffi::OsStr;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
ffi::{OsStr, OsString},
|
ffi::OsString,
|
||||||
io::{self, Read, Write},
|
io::{self, Read, Write},
|
||||||
panic::catch_unwind,
|
panic::catch_unwind,
|
||||||
sync::{
|
sync::{
|
||||||
@@ -106,6 +108,7 @@ async fn run_uutil<SE: ShellExtensions>(
|
|||||||
|
|
||||||
// brush passes the command name as the first `CommandArg`, which is exactly
|
// brush passes the command name as the first `CommandArg`, which is exactly
|
||||||
// the argv[0] uutils' argument parsing expects.
|
// the argv[0] uutils' argument parsing expects.
|
||||||
|
#[cfg_attr(not(unix), allow(unused_mut))]
|
||||||
let mut argv: Vec<OsString> = args
|
let mut argv: Vec<OsString> = args
|
||||||
.iter()
|
.iter()
|
||||||
.map(|arg| OsString::from(arg.to_string()))
|
.map(|arg| OsString::from(arg.to_string()))
|
||||||
|
|||||||
@@ -511,12 +511,14 @@ struct SizeFilter {
|
|||||||
bytes: u64,
|
bytes: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
enum OwnerSide {
|
enum OwnerSide {
|
||||||
Include(u32),
|
Include(u32),
|
||||||
Exclude(u32),
|
Exclude(u32),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
struct OwnerMatcher {
|
struct OwnerMatcher {
|
||||||
user: Option<OwnerSide>,
|
user: Option<OwnerSide>,
|
||||||
@@ -1183,6 +1185,7 @@ fn matches_owner_filters(filters: &[OwnerMatcher], _metadata: Option<&Metadata>)
|
|||||||
filters.is_empty()
|
filters.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
const fn owner_side_matches(side: OwnerSide, actual: u32) -> bool {
|
const fn owner_side_matches(side: OwnerSide, actual: u32) -> bool {
|
||||||
match side {
|
match side {
|
||||||
OwnerSide::Include(expected) => actual == expected,
|
OwnerSide::Include(expected) => actual == expected,
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ struct Ctx {
|
|||||||
stdin: Box<dyn Read + Send>,
|
stdin: Box<dyn Read + Send>,
|
||||||
/// Raw fd backing `stdin` when it is a real OS file/pipe, used for
|
/// Raw fd backing `stdin` when it is a real OS file/pipe, used for
|
||||||
/// cancellable readiness polling on unix. `None` for non-fd readers.
|
/// cancellable readiness polling on unix. `None` for non-fd readers.
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
stdin_fd: Option<i32>,
|
stdin_fd: Option<i32>,
|
||||||
/// Whether stdin is a shell pipe/stream that should be searched implicitly.
|
/// Whether stdin is a shell pipe/stream that should be searched implicitly.
|
||||||
stdin_is_search_input: bool,
|
stdin_is_search_input: bool,
|
||||||
|
|||||||
@@ -20,4 +20,10 @@ rayon.workspace = true
|
|||||||
libc.workspace = true
|
libc.workspace = true
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
windows-sys = { workspace = true, features = ["Wdk_Storage_FileSystem"] }
|
windows-sys = { workspace = true, features = [
|
||||||
|
"Wdk_Storage_FileSystem",
|
||||||
|
"Win32_Foundation",
|
||||||
|
"Win32_Security",
|
||||||
|
"Win32_Storage_FileSystem",
|
||||||
|
"Win32_System_IO",
|
||||||
|
] }
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use nix::unistd::Group;
|
|||||||
use super::{ComparableValue, Matcher, MatcherIO, WalkEntry};
|
use super::{ComparableValue, Matcher, MatcherIO, WalkEntry};
|
||||||
|
|
||||||
pub struct GroupMatcher {
|
pub struct GroupMatcher {
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
gid: ComparableValue,
|
gid: ComparableValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ use nix::unistd::User;
|
|||||||
use super::{ComparableValue, Matcher, MatcherIO, WalkEntry};
|
use super::{ComparableValue, Matcher, MatcherIO, WalkEntry};
|
||||||
|
|
||||||
pub struct UserMatcher {
|
pub struct UserMatcher {
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
uid: ComparableValue,
|
uid: ComparableValue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+6
@@ -146,8 +146,10 @@ for details about the options it supports.";
|
|||||||
#[error("{directive}: invalid directive")]
|
#[error("{directive}: invalid directive")]
|
||||||
InvalidDirective { directive: String },
|
InvalidDirective { directive: String },
|
||||||
#[error("cannot read table of mounted file systems: {error}")]
|
#[error("cannot read table of mounted file systems: {error}")]
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
CannotReadFilesystem { error: String },
|
CannotReadFilesystem { error: String },
|
||||||
#[error("using '-' to denote standard input does not work in file system mode")]
|
#[error("using '-' to denote standard input does not work in file system mode")]
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
StdinFilesystemMode,
|
StdinFilesystemMode,
|
||||||
#[error("cannot read file system information for {file}: {error}")]
|
#[error("cannot read file system information for {file}: {error}")]
|
||||||
CannotReadFilesystemInfo { file: String, error: String },
|
CannotReadFilesystemInfo { file: String, error: String },
|
||||||
@@ -275,6 +277,7 @@ for details about the options it supports.";
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum OutputType<'a> {
|
pub enum OutputType<'a> {
|
||||||
Str(String),
|
Str(String),
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
OsStr(&'a OsString),
|
OsStr(&'a OsString),
|
||||||
Integer(i64),
|
Integer(i64),
|
||||||
Unsigned(u64),
|
Unsigned(u64),
|
||||||
@@ -413,9 +416,12 @@ for details about the options it supports.";
|
|||||||
show_fs: bool,
|
show_fs: bool,
|
||||||
from_user: bool,
|
from_user: bool,
|
||||||
files: Vec<OsString>,
|
files: Vec<OsString>,
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
mount_list: OnceCell<Option<Vec<OsString>>>,
|
mount_list: OnceCell<Option<Vec<OsString>>>,
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
mount_list_needed: bool,
|
mount_list_needed: bool,
|
||||||
default_tokens: Vec<Token>,
|
default_tokens: Vec<Token>,
|
||||||
|
#[cfg_attr(not(unix), allow(dead_code))]
|
||||||
default_dev_tokens: Vec<Token>,
|
default_dev_tokens: Vec<Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1044,7 +1044,6 @@ export interface RegisteredCommand {
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
/** Handler function type for events */
|
/** Handler function type for events */
|
||||||
// biome-ignore lint/suspicious/noConfusingVoidType: void allows bare return statements
|
|
||||||
export type ExtensionHandler<E, R = undefined> = (event: E, ctx: ExtensionContext) => Promise<R | void> | R | void;
|
export type ExtensionHandler<E, R = undefined> = (event: E, ctx: ExtensionContext) => Promise<R | void> | R | void;
|
||||||
|
|
||||||
/** Service tiers accepted by each provider family. */
|
/** Service tiers accepted by each provider family. */
|
||||||
|
|||||||
@@ -444,7 +444,6 @@ export type {
|
|||||||
* Handler function type for each event.
|
* Handler function type for each event.
|
||||||
* Handlers can return R, undefined, or void (bare return statements).
|
* Handlers can return R, undefined, or void (bare return statements).
|
||||||
*/
|
*/
|
||||||
// biome-ignore lint/suspicious/noConfusingVoidType: void allows bare return statements in handlers
|
|
||||||
export type HookHandler<E, R = undefined> = (event: E, ctx: HookContext) => Promise<R | void> | R | void;
|
export type HookHandler<E, R = undefined> = (event: E, ctx: HookContext) => Promise<R | void> | R | void;
|
||||||
|
|
||||||
export interface HookMessageRenderOptions {
|
export interface HookMessageRenderOptions {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- napi binding build failures now surface the exit code and the tail of stdout/stderr instead of a bare "napi build failed" message ([#6799](https://github.com/can1357/oh-my-pi/pull/6799)).
|
- napi binding build failures now surface the exit code and the tail of stdout/stderr instead of a bare "napi build failed" message ([#6799](https://github.com/can1357/oh-my-pi/pull/6799)).
|
||||||
|
- Silenced cross-platform Rust build warnings: dead-code on unix-only fields/helpers in `pi-uutils-ctx`, `pi-shell` (fd owner filters, coreutils argv), and vendored `uu-find`/`uu-stat` when compiling for Windows, and deprecated `libc::time_t` casts in `pi-iso` on musl. `pi-walker` now declares the `windows-sys` features it uses (`Win32_Foundation`, `Win32_Security`, `Win32_Storage_FileSystem`, `Win32_System_IO`) instead of relying on workspace-wide feature unification.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const VENDORED_FORK_EXCLUDES = [
|
|||||||
const TASK_COMMANDS = {
|
const TASK_COMMANDS = {
|
||||||
"check:rs": [
|
"check:rs": [
|
||||||
["cargo", "fmt", "--all", "--", "--check"],
|
["cargo", "fmt", "--all", "--", "--check"],
|
||||||
["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--", "-D", "warnings"],
|
["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--no-deps", "--", "-D", "warnings"],
|
||||||
],
|
],
|
||||||
"fix:rs": [
|
"fix:rs": [
|
||||||
["cargo", "fmt", "--all"],
|
["cargo", "fmt", "--all"],
|
||||||
@@ -43,7 +43,7 @@ const TASK_COMMANDS = {
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"fmt:rs": [["cargo", "fmt", "--all"]],
|
"fmt:rs": [["cargo", "fmt", "--all"]],
|
||||||
"lint:rs": [["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--", "-D", "warnings"]],
|
"lint:rs": [["cargo", "clippy", "--workspace", ...VENDORED_FORK_EXCLUDES, "--no-deps", "--", "-D", "warnings"]],
|
||||||
"test:rs": [
|
"test:rs": [
|
||||||
[
|
[
|
||||||
"cargo",
|
"cargo",
|
||||||
|
|||||||
Reference in New Issue
Block a user