From b0d658f1c5986fc88766d454cd5bc8c50af50a91 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:51:55 +0700 Subject: [PATCH 1/7] GNUMakefile: add support for cygwin --- GNUmakefile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 6f5eda35f30..4055618dc43 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,15 +62,15 @@ TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER) #------------------------------------------------------------------------ # Detect the host system. -# On Windows the environment already sets OS = Windows_NT. +# On Windows uname -s might return MINGW_NT-* or CYGWIN_NT-*. # Otherwise let it default to the kernel name returned by uname -s # (Linux, Darwin, FreeBSD, …). #------------------------------------------------------------------------ -OS ?= $(shell uname -s) +OS := $(shell uname -s) # Windows does not allow symlink by default. # Allow to override LN for AppArmor. -ifeq ($(OS),Windows_NT) +ifeq (,$(findstring _NT,$(OS))) LN ?= ln -f endif LN ?= ln -sf @@ -195,7 +195,7 @@ HASHSUM_PROGS := \ $(info Detected OS = $(OS)) -ifneq ($(OS),Windows_NT) +ifeq (,$(findstring MINGW,$(OS))) PROGS += $(UNIX_PROGS) endif ifeq ($(SELINUX_ENABLED),1) @@ -450,8 +450,12 @@ install: build install-manpages install-completions install-locales mkdir -p $(INSTALLDIR_BIN) ifneq (,$(and $(findstring stdbuf,$(UTILS)),$(findstring feat_external_libstdbuf,$(CARGOFLAGS)))) mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR) +ifneq (,$(findstring CYGWIN,$(OS))) + $(INSTALL) -m 755 $(BUILDDIR)/deps/stdbuf.dll $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.dll +else $(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf.* $(DESTDIR)$(LIBSTDBUF_DIR)/ endif +endif ifeq (${MULTICALL}, y) $(INSTALL) -m 755 $(BUILDDIR)/coreutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)coreutils $(foreach prog, $(filter-out coreutils, $(INSTALLEES)), \ @@ -472,7 +476,7 @@ else endif uninstall: -ifneq ($(OS),Windows_NT) +ifeq (,$(findstring MINGW,$(OS))) rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.* -rm -d $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true endif From 46f7f21e5bb030ccad4a188d579aab982d3023ab Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Tue, 16 Dec 2025 22:53:24 +0700 Subject: [PATCH 2/7] uucore: add more cygwin support --- src/uucore/src/lib/features/utmpx.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 8832caff3ba..3ac181f8186 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -56,7 +56,7 @@ pub use libc::getutxent; #[cfg_attr(target_env = "musl", allow(deprecated))] pub use libc::setutxent; use libc::utmpx; -#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "netbsd"))] +#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "netbsd", target_os = "cygwin"))] #[cfg_attr(target_env = "musl", allow(deprecated))] pub use libc::utmpxname; @@ -179,6 +179,26 @@ mod ut { pub use libc::USER_PROCESS; } +#[cfg(target_os = "cygwin")] +mod ut { + pub static DEFAULT_FILE: &str = ""; + + pub use libc::UT_LINESIZE as UT_LINESIZE; + pub use libc::UT_NAMESIZE as UT_NAMESIZE; + pub use libc::UT_HOSTSIZE as UT_HOSTSIZE; + pub use libc::UT_IDLEN as UT_IDLEN; + + pub use libc::RUN_LVL; + pub use libc::BOOT_TIME; + pub use libc::NEW_TIME; + pub use libc::OLD_TIME; + pub use libc::INIT_PROCESS; + pub use libc::LOGIN_PROCESS; + pub use libc::USER_PROCESS; + pub use libc::DEAD_PROCESS; + +} + /// A login record pub struct Utmpx { inner: utmpx, From 3a98b0bad9f0b2bbe970c63b17e2e4ecedd2b538 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:50:24 +0700 Subject: [PATCH 3/7] chroot, id, nohup, stdbuf, stty: add support for cygwin --- src/uu/chroot/src/chroot.rs | 2 +- src/uu/id/src/id.rs | 6 +- src/uu/nohup/src/nohup.rs | 3 +- src/uu/stdbuf/build.rs | 8 +++ src/uu/stdbuf/src/libstdbuf/build.rs | 4 +- src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs | 75 +++++++++++++++++++- src/uu/stdbuf/src/stdbuf.rs | 3 + src/uu/stty/src/flags.rs | 3 + 8 files changed, 94 insertions(+), 10 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 6f615885054..04eb09485eb 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -319,7 +319,7 @@ fn supplemental_gids(uid: libc::uid_t) -> Vec { /// Set the supplemental group IDs for this process. fn set_supplemental_gids(gids: &[libc::gid_t]) -> std::io::Result<()> { - #[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "openbsd"))] + #[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin"))] let n = gids.len() as libc::c_int; #[cfg(any(target_os = "linux", target_os = "android"))] let n = gids.len() as libc::size_t; diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 298619fd5e3..96ce617570b 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -535,7 +535,7 @@ fn pline(possible_uid: Option) { ); } -#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "cygwin"))] fn pline(possible_uid: Option) { let uid = possible_uid.unwrap_or_else(getuid); let pw = Passwd::locate(uid).unwrap(); @@ -552,10 +552,10 @@ fn pline(possible_uid: Option) { ); } -#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "cygwin"))] fn auditid() {} -#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "openbsd")))] +#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "cygwin")))] fn auditid() { use std::mem::MaybeUninit; diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 38b5e5ceb30..6280d44e1e3 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -185,7 +185,8 @@ unsafe extern "C" { target_os = "linux", target_os = "android", target_os = "freebsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "cygwin" ))] /// # Safety /// This function is unsafe because it dereferences a raw pointer. diff --git a/src/uu/stdbuf/build.rs b/src/uu/stdbuf/build.rs index aa2692cb512..d844f37907a 100644 --- a/src/uu/stdbuf/build.rs +++ b/src/uu/stdbuf/build.rs @@ -26,6 +26,11 @@ mod platform { pub const DYLIB_EXT: &str = ".dylib"; } +#[cfg(target_os = "cygwin")] +mod platform { + pub const DYLIB_EXT: &str = ".dll"; +} + fn main() { println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=src/libstdbuf/src/libstdbuf.rs"); @@ -103,6 +108,9 @@ fn main() { assert!(status.success(), "Failed to build libstdbuf"); // Copy the built library to OUT_DIR for include_bytes! to find + #[cfg(target_os = "cygwin")] + let lib_name = format!("stdbuf{}", platform::DYLIB_EXT); + #[cfg(not(target_os = "cygwin"))] let lib_name = format!("libstdbuf{}", platform::DYLIB_EXT); let dest_path = Path::new(&out_dir).join(format!("libstdbuf{}", platform::DYLIB_EXT)); diff --git a/src/uu/stdbuf/src/libstdbuf/build.rs b/src/uu/stdbuf/src/libstdbuf/build.rs index 505cdf68aec..7584bf31f8e 100644 --- a/src/uu/stdbuf/src/libstdbuf/build.rs +++ b/src/uu/stdbuf/src/libstdbuf/build.rs @@ -11,8 +11,8 @@ fn main() { println!("cargo:rustc-link-arg=-fPIC"); let target = env::var("TARGET").unwrap_or_else(|_| "unknown".to_string()); - // Ensure the library doesn't have any undefined symbols (-z flag not supported on macOS) - if !target.contains("apple-darwin") { + // Ensure the library doesn't have any undefined symbols (-z flag not supported on macOS and Cygwin) + if !target.contains("apple-darwin") && !target.contains("cygwin") { println!("cargo:rustc-link-arg=-z"); println!("cargo:rustc-link-arg=defs"); } diff --git a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs index 3ef7473bf79..e3aeff0817d 100644 --- a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs +++ b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs @@ -35,7 +35,30 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE { unsafe { __stdin } } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))] + #[cfg(target_os = "cygwin")] + { + // _getreent()->_std{in,out,err} + // see: + // echo '#include \nstd{in,out,err}' | gcc -E -xc - -std=c23 | tail -n1 + // echo '#include ' | grep -E -xc - -std=c23 | grep 'struct _reent' -A91 | grep 580 -A91 | tail -n+2 + + #[repr(C)] + struct _reent { + _errno: c_int, + _stdin: *mut FILE, + _stdout: *mut FILE, + _stderr: *mut FILE, + // other stuff + } + + unsafe extern "C" { + fn __getreent() -> *mut _reent; + } + + unsafe { (*__getreent())._stdin } + } + + #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin")))] { unsafe extern "C" { static mut stdin: *mut FILE; @@ -64,7 +87,30 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE { unsafe { __stdout } } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))] + #[cfg(target_os = "cygwin")] + { + // _getreent()->_std{in,out,err} + // see: + // echo '#include \nstd{in,out,err}' | gcc -E -xc - -std=c23 | tail -n1 + // echo '#include ' | grep -E -xc - -std=c23 | grep 'struct _reent' -A91 | grep 580 -A91 | tail -n+2 + + #[repr(C)] + struct _reent { + _errno: c_int, + _stdin: *mut FILE, + _stdout: *mut FILE, + _stderr: *mut FILE, + // other stuff + } + + unsafe extern "C" { + fn __getreent() -> *mut _reent; + } + + unsafe { (*__getreent())._stdout } + } + + #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin")))] { unsafe extern "C" { static mut stdout: *mut FILE; @@ -93,7 +139,30 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE { unsafe { __stderr } } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd")))] + #[cfg(target_os = "cygwin")] + { + // _getreent()->_std{in,out,err} + // see: + // echo '#include \nstd{in,out,err}' | gcc -E -xc - -std=c23 | tail -n1 + // echo '#include ' | grep -E -xc - -std=c23 | grep 'struct _reent' -A91 | grep 580 -A91 | tail -n+2 + + #[repr(C)] + struct _reent { + _errno: c_int, + _stdin: *mut FILE, + _stdout: *mut FILE, + _stderr: *mut FILE, + // other stuff + } + + unsafe extern "C" { + fn __getreent() -> *mut _reent; + } + + unsafe { (*__getreent())._stdin } + } + + #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin")))] { unsafe extern "C" { static mut stderr: *mut FILE; diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 9af3d80cab1..f45dd2b97b3 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -43,6 +43,9 @@ const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf #[cfg(all(not(feature = "feat_external_libstdbuf"), target_vendor = "apple"))] const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.dylib")); +#[cfg(all(not(feature = "feat_external_libstdbuf"), target_os = "cygwin"))] +const STDBUF_INJECT: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/libstdbuf.dll")); + enum BufferType { Default, Line, diff --git a/src/uu/stty/src/flags.rs b/src/uu/stty/src/flags.rs index c10e7c04b39..d3f4ca848be 100644 --- a/src/uu/stty/src/flags.rs +++ b/src/uu/stty/src/flags.rs @@ -256,13 +256,16 @@ pub const LOCAL_FLAGS: &[Flag] = &[ // Not supported by nix // Flag::new("xcase", L::XCASE), Flag::new("tostop", L::TOSTOP), + #[cfg(not(target_os = "cygwin"))] Flag::new("echoprt", L::ECHOPRT), + #[cfg(not(target_os = "cygwin"))] Flag::new("prterase", L::ECHOPRT).hidden(), Flag::new("echoctl", L::ECHOCTL).sane(), Flag::new("ctlecho", L::ECHOCTL).sane().hidden(), Flag::new("echoke", L::ECHOKE).sane(), Flag::new("crtkill", L::ECHOKE).sane().hidden(), Flag::new("flusho", L::FLUSHO), + #[cfg(not(target_os = "cygwin"))] Flag::new("extproc", L::EXTPROC), ]; From b78a29f5ce2478fea8018fae041d90ab7d2aea8a Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Wed, 17 Dec 2025 14:52:51 +0700 Subject: [PATCH 4/7] uucore, chroot, id, nohup, stdbuf: format --- src/uu/chroot/src/chroot.rs | 13 ++++--- src/uu/id/src/id.rs | 23 +++++++++--- src/uu/nohup/src/nohup.rs | 4 +-- src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs | 23 +++++++++--- src/uu/stdbuf/src/stdbuf.rs | 2 +- src/uucore/src/lib/features/utmpx.rs | 38 +++++++++++--------- 6 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index 04eb09485eb..af0e7a13842 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -13,9 +13,9 @@ use std::io::Error; use std::os::unix::prelude::OsStrExt; use std::path::{Path, PathBuf}; use std::process; -use uucore::entries::{Locate, Passwd, grp2gid, usr2uid}; -use uucore::error::{UResult, UUsageError, set_exit_code}; -use uucore::fs::{MissingHandling, ResolveMode, canonicalize}; +use uucore::entries::{grp2gid, usr2uid, Locate, Passwd}; +use uucore::error::{set_exit_code, UResult, UUsageError}; +use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; use uucore::libc::{self, chroot, setgid, setgroups, setuid}; use uucore::{format_usage, show}; @@ -319,7 +319,12 @@ fn supplemental_gids(uid: libc::uid_t) -> Vec { /// Set the supplemental group IDs for this process. fn set_supplemental_gids(gids: &[libc::gid_t]) -> std::io::Result<()> { - #[cfg(any(target_vendor = "apple", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin"))] + #[cfg(any( + target_vendor = "apple", + target_os = "freebsd", + target_os = "openbsd", + target_os = "cygwin" + ))] let n = gids.len() as libc::c_int; #[cfg(any(target_os = "linux", target_os = "android"))] let n = gids.len() as libc::size_t; diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index 96ce617570b..afd8c68d670 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -38,7 +38,7 @@ use std::ffi::CStr; use uucore::display::Quotable; use uucore::entries::{self, Group, Locate, Passwd}; use uucore::error::UResult; -use uucore::error::{USimpleError, set_exit_code}; +use uucore::error::{set_exit_code, USimpleError}; pub use uucore::libc; use uucore::libc::{getlogin, uid_t}; use uucore::line_ending::LineEnding; @@ -535,7 +535,12 @@ fn pline(possible_uid: Option) { ); } -#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "cygwin"))] +#[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "openbsd", + target_os = "cygwin" +))] fn pline(possible_uid: Option) { let uid = possible_uid.unwrap_or_else(getuid); let pw = Passwd::locate(uid).unwrap(); @@ -552,10 +557,20 @@ fn pline(possible_uid: Option) { ); } -#[cfg(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "cygwin"))] +#[cfg(any( + target_os = "linux", + target_os = "android", + target_os = "openbsd", + target_os = "cygwin" +))] fn auditid() {} -#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "openbsd", target_os = "cygwin")))] +#[cfg(not(any( + target_os = "linux", + target_os = "android", + target_os = "openbsd", + target_os = "cygwin" +)))] fn auditid() { use std::mem::MaybeUninit; diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 6280d44e1e3..5a6aa78d87f 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -6,7 +6,7 @@ // spell-checker:ignore (ToDO) SIGHUP cproc vprocmgr homeout use clap::{Arg, ArgAction, Command}; -use libc::{SIG_IGN, SIGHUP, dup2, signal}; +use libc::{dup2, signal, SIGHUP, SIG_IGN}; use std::env; use std::fs::{File, OpenOptions}; use std::io::{Error, ErrorKind, IsTerminal}; @@ -16,7 +16,7 @@ use std::path::{Path, PathBuf}; use std::process; use thiserror::Error; use uucore::display::Quotable; -use uucore::error::{UError, UResult, set_exit_code}; +use uucore::error::{set_exit_code, UError, UResult}; use uucore::translate; use uucore::{format_usage, show_error}; diff --git a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs index e3aeff0817d..a6643f16273 100644 --- a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs +++ b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs @@ -5,7 +5,7 @@ // spell-checker:ignore (ToDO) IOFBF IOLBF IONBF setvbuf stderrp stdinp stdoutp use ctor::ctor; -use libc::{_IOFBF, _IOLBF, _IONBF, FILE, c_char, c_int, fileno, size_t}; +use libc::{c_char, c_int, fileno, size_t, FILE, _IOFBF, _IOLBF, _IONBF}; use std::env; use std::ptr; @@ -58,7 +58,12 @@ pub unsafe extern "C" fn __stdbuf_get_stdin() -> *mut FILE { unsafe { (*__getreent())._stdin } } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin")))] + #[cfg(not(any( + target_os = "macos", + target_os = "freebsd", + target_os = "openbsd", + target_os = "cygwin" + )))] { unsafe extern "C" { static mut stdin: *mut FILE; @@ -110,7 +115,12 @@ pub unsafe extern "C" fn __stdbuf_get_stdout() -> *mut FILE { unsafe { (*__getreent())._stdout } } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin")))] + #[cfg(not(any( + target_os = "macos", + target_os = "freebsd", + target_os = "openbsd", + target_os = "cygwin" + )))] { unsafe extern "C" { static mut stdout: *mut FILE; @@ -162,7 +172,12 @@ pub unsafe extern "C" fn __stdbuf_get_stderr() -> *mut FILE { unsafe { (*__getreent())._stdin } } - #[cfg(not(any(target_os = "macos", target_os = "freebsd", target_os = "openbsd", target_os = "cygwin")))] + #[cfg(not(any( + target_os = "macos", + target_os = "freebsd", + target_os = "openbsd", + target_os = "cygwin" + )))] { unsafe extern "C" { static mut stderr: *mut FILE; diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index f45dd2b97b3..199813c82d1 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -9,8 +9,8 @@ use clap::{Arg, ArgAction, ArgMatches, Command}; use std::ffi::OsString; use std::path::PathBuf; use std::process; -use tempfile::TempDir; use tempfile::tempdir; +use tempfile::TempDir; use thiserror::Error; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::format_usage; diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 3ac181f8186..735482cf3eb 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -56,7 +56,12 @@ pub use libc::getutxent; #[cfg_attr(target_env = "musl", allow(deprecated))] pub use libc::setutxent; use libc::utmpx; -#[cfg(any(target_vendor = "apple", target_os = "linux", target_os = "netbsd", target_os = "cygwin"))] +#[cfg(any( + target_vendor = "apple", + target_os = "linux", + target_os = "netbsd", + target_os = "cygwin" +))] #[cfg_attr(target_env = "musl", allow(deprecated))] pub use libc::utmpxname; @@ -83,20 +88,20 @@ macro_rules! chars2string { mod ut { pub static DEFAULT_FILE: &str = "/var/run/utmp"; - #[cfg(not(target_env = "musl"))] - pub use libc::__UT_HOSTSIZE as UT_HOSTSIZE; #[cfg(target_env = "musl")] pub use libc::UT_HOSTSIZE; - #[cfg(not(target_env = "musl"))] - pub use libc::__UT_LINESIZE as UT_LINESIZE; + pub use libc::__UT_HOSTSIZE as UT_HOSTSIZE; + #[cfg(target_env = "musl")] pub use libc::UT_LINESIZE; - #[cfg(not(target_env = "musl"))] - pub use libc::__UT_NAMESIZE as UT_NAMESIZE; + pub use libc::__UT_LINESIZE as UT_LINESIZE; + #[cfg(target_env = "musl")] pub use libc::UT_NAMESIZE; + #[cfg(not(target_env = "musl"))] + pub use libc::__UT_NAMESIZE as UT_NAMESIZE; pub const UT_IDSIZE: usize = 4; @@ -183,20 +188,19 @@ mod ut { mod ut { pub static DEFAULT_FILE: &str = ""; - pub use libc::UT_LINESIZE as UT_LINESIZE; - pub use libc::UT_NAMESIZE as UT_NAMESIZE; - pub use libc::UT_HOSTSIZE as UT_HOSTSIZE; - pub use libc::UT_IDLEN as UT_IDLEN; + pub use libc::UT_HOSTSIZE; + pub use libc::UT_IDLEN; + pub use libc::UT_LINESIZE; + pub use libc::UT_NAMESIZE; - pub use libc::RUN_LVL; pub use libc::BOOT_TIME; - pub use libc::NEW_TIME; - pub use libc::OLD_TIME; + pub use libc::DEAD_PROCESS; pub use libc::INIT_PROCESS; pub use libc::LOGIN_PROCESS; + pub use libc::NEW_TIME; + pub use libc::OLD_TIME; + pub use libc::RUN_LVL; pub use libc::USER_PROCESS; - pub use libc::DEAD_PROCESS; - } /// A login record @@ -271,7 +275,7 @@ impl Utmpx { let (hostname, display) = host.split_once(':').unwrap_or((&host, "")); if !hostname.is_empty() { - use dns_lookup::{AddrInfoHints, getaddrinfo}; + use dns_lookup::{getaddrinfo, AddrInfoHints}; const AI_CANONNAME: i32 = 0x2; let hints = AddrInfoHints { From 9b51c51a78d77e9b15287e9fcfdcc89c08f6ee4e Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Thu, 18 Dec 2025 00:09:48 +0700 Subject: [PATCH 5/7] chore: format --- src/uu/chroot/src/chroot.rs | 6 +++--- src/uu/id/src/id.rs | 2 +- src/uu/nohup/src/nohup.rs | 4 ++-- src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs | 2 +- src/uu/stdbuf/src/stdbuf.rs | 2 +- src/uucore/src/lib/features/utmpx.rs | 14 +++++++------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/uu/chroot/src/chroot.rs b/src/uu/chroot/src/chroot.rs index af0e7a13842..289511d81c5 100644 --- a/src/uu/chroot/src/chroot.rs +++ b/src/uu/chroot/src/chroot.rs @@ -13,9 +13,9 @@ use std::io::Error; use std::os::unix::prelude::OsStrExt; use std::path::{Path, PathBuf}; use std::process; -use uucore::entries::{grp2gid, usr2uid, Locate, Passwd}; -use uucore::error::{set_exit_code, UResult, UUsageError}; -use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; +use uucore::entries::{Locate, Passwd, grp2gid, usr2uid}; +use uucore::error::{UResult, UUsageError, set_exit_code}; +use uucore::fs::{MissingHandling, ResolveMode, canonicalize}; use uucore::libc::{self, chroot, setgid, setgroups, setuid}; use uucore::{format_usage, show}; diff --git a/src/uu/id/src/id.rs b/src/uu/id/src/id.rs index afd8c68d670..59f06809af5 100644 --- a/src/uu/id/src/id.rs +++ b/src/uu/id/src/id.rs @@ -38,7 +38,7 @@ use std::ffi::CStr; use uucore::display::Quotable; use uucore::entries::{self, Group, Locate, Passwd}; use uucore::error::UResult; -use uucore::error::{set_exit_code, USimpleError}; +use uucore::error::{USimpleError, set_exit_code}; pub use uucore::libc; use uucore::libc::{getlogin, uid_t}; use uucore::line_ending::LineEnding; diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index 5a6aa78d87f..6280d44e1e3 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -6,7 +6,7 @@ // spell-checker:ignore (ToDO) SIGHUP cproc vprocmgr homeout use clap::{Arg, ArgAction, Command}; -use libc::{dup2, signal, SIGHUP, SIG_IGN}; +use libc::{SIG_IGN, SIGHUP, dup2, signal}; use std::env; use std::fs::{File, OpenOptions}; use std::io::{Error, ErrorKind, IsTerminal}; @@ -16,7 +16,7 @@ use std::path::{Path, PathBuf}; use std::process; use thiserror::Error; use uucore::display::Quotable; -use uucore::error::{set_exit_code, UError, UResult}; +use uucore::error::{UError, UResult, set_exit_code}; use uucore::translate; use uucore::{format_usage, show_error}; diff --git a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs index a6643f16273..5bfbe799ae5 100644 --- a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs +++ b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs @@ -5,7 +5,7 @@ // spell-checker:ignore (ToDO) IOFBF IOLBF IONBF setvbuf stderrp stdinp stdoutp use ctor::ctor; -use libc::{c_char, c_int, fileno, size_t, FILE, _IOFBF, _IOLBF, _IONBF}; +use libc::{_IOFBF, _IOLBF, _IONBF, FILE, c_char, c_int, fileno, size_t}; use std::env; use std::ptr; diff --git a/src/uu/stdbuf/src/stdbuf.rs b/src/uu/stdbuf/src/stdbuf.rs index 199813c82d1..f45dd2b97b3 100644 --- a/src/uu/stdbuf/src/stdbuf.rs +++ b/src/uu/stdbuf/src/stdbuf.rs @@ -9,8 +9,8 @@ use clap::{Arg, ArgAction, ArgMatches, Command}; use std::ffi::OsString; use std::path::PathBuf; use std::process; -use tempfile::tempdir; use tempfile::TempDir; +use tempfile::tempdir; use thiserror::Error; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::format_usage; diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index 735482cf3eb..f7f6783eca2 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -88,20 +88,20 @@ macro_rules! chars2string { mod ut { pub static DEFAULT_FILE: &str = "/var/run/utmp"; - #[cfg(target_env = "musl")] - pub use libc::UT_HOSTSIZE; #[cfg(not(target_env = "musl"))] pub use libc::__UT_HOSTSIZE as UT_HOSTSIZE; - #[cfg(target_env = "musl")] - pub use libc::UT_LINESIZE; + pub use libc::UT_HOSTSIZE; + #[cfg(not(target_env = "musl"))] pub use libc::__UT_LINESIZE as UT_LINESIZE; - #[cfg(target_env = "musl")] - pub use libc::UT_NAMESIZE; + pub use libc::UT_LINESIZE; + #[cfg(not(target_env = "musl"))] pub use libc::__UT_NAMESIZE as UT_NAMESIZE; + #[cfg(target_env = "musl")] + pub use libc::UT_NAMESIZE; pub const UT_IDSIZE: usize = 4; @@ -275,7 +275,7 @@ impl Utmpx { let (hostname, display) = host.split_once(':').unwrap_or((&host, "")); if !hostname.is_empty() { - use dns_lookup::{getaddrinfo, AddrInfoHints}; + use dns_lookup::{AddrInfoHints, getaddrinfo}; const AI_CANONNAME: i32 = 0x2; let hints = AddrInfoHints { From cbaf85b80a6a3269808130a0c719103a33b00318 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Thu, 18 Dec 2025 09:52:45 +0700 Subject: [PATCH 6/7] chore: fix spelling --- src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs | 2 +- src/uucore/src/lib/features/utmpx.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs index 5bfbe799ae5..da0e43fef0c 100644 --- a/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs +++ b/src/uu/stdbuf/src/libstdbuf/src/libstdbuf.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) IOFBF IOLBF IONBF setvbuf stderrp stdinp stdoutp +// spell-checker:ignore (ToDO) getreent reent IOFBF IOLBF IONBF setvbuf stderrp stdinp stdoutp use ctor::ctor; use libc::{_IOFBF, _IOLBF, _IONBF, FILE, c_char, c_int, fileno, size_t}; diff --git a/src/uucore/src/lib/features/utmpx.rs b/src/uucore/src/lib/features/utmpx.rs index f7f6783eca2..3c3664389df 100644 --- a/src/uucore/src/lib/features/utmpx.rs +++ b/src/uucore/src/lib/features/utmpx.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // -// spell-checker:ignore logind +// spell-checker:ignore IDLEN logind //! Aims to provide platform-independent methods to obtain login records //! From ba221216c38048777f9e2b811eba67246943bb37 Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Thu, 18 Dec 2025 15:14:44 +0700 Subject: [PATCH 7/7] GNUMakefile: fix inverted check --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 4055618dc43..d3430e7e2e5 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -70,7 +70,7 @@ OS := $(shell uname -s) # Windows does not allow symlink by default. # Allow to override LN for AppArmor. -ifeq (,$(findstring _NT,$(OS))) +ifneq (,$(findstring _NT,$(OS))) LN ?= ln -f endif LN ?= ln -sf