diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs index f8d3c0f9654..16de054a3c2 100644 --- a/src/uucore/src/lib/features/fs.rs +++ b/src/uucore/src/lib/features/fs.rs @@ -123,6 +123,7 @@ impl FileInformation { not(target_os = "openbsd"), not(target_os = "illumos"), not(target_os = "solaris"), + not(target_os = "cygwin"), not(target_arch = "aarch64"), not(target_arch = "riscv64"), not(target_arch = "loongarch64"), @@ -140,6 +141,7 @@ impl FileInformation { target_os = "openbsd", target_os = "illumos", target_os = "solaris", + target_os = "cygwin", target_arch = "aarch64", target_arch = "riscv64", target_arch = "loongarch64", diff --git a/src/uucore/src/lib/features/fsext.rs b/src/uucore/src/lib/features/fsext.rs index 4be4d66cf8f..78dfcceb23d 100644 --- a/src/uucore/src/lib/features/fsext.rs +++ b/src/uucore/src/lib/features/fsext.rs @@ -7,9 +7,9 @@ // spell-checker:ignore DATETIME getmntinfo subsecond (fs) cifs smbfs -#[cfg(any(target_os = "linux", target_os = "android"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] const LINUX_MTAB: &str = "/etc/mtab"; -#[cfg(any(target_os = "linux", target_os = "android"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] const LINUX_MOUNTINFO: &str = "/proc/self/mountinfo"; #[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))] static MOUNT_OPT_BIND: &str = "bind"; @@ -94,7 +94,8 @@ pub use libc::statfs as StatFs; target_os = "dragonfly", target_os = "illumos", target_os = "solaris", - target_os = "redox" + target_os = "redox", + target_os = "cygwin", ))] pub use libc::statvfs as StatFs; @@ -112,7 +113,8 @@ pub use libc::statfs as statfs_fn; target_os = "illumos", target_os = "solaris", target_os = "dragonfly", - target_os = "redox" + target_os = "redox", + target_os = "cygwin", ))] pub use libc::statvfs as statfs_fn; @@ -189,7 +191,7 @@ pub struct MountInfo { pub dummy: bool, } -#[cfg(any(target_os = "linux", target_os = "android"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] fn replace_special_chars(s: &[u8]) -> Vec { use bstr::ByteSlice; @@ -205,7 +207,7 @@ fn replace_special_chars(s: &[u8]) -> Vec { } impl MountInfo { - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] fn new(file_name: &str, raw: &[&[u8]]) -> Option { use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; @@ -459,9 +461,9 @@ use crate::error::UResult; target_os = "windows" ))] use crate::error::USimpleError; -#[cfg(any(target_os = "linux", target_os = "android"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] use std::fs::File; -#[cfg(any(target_os = "linux", target_os = "android"))] +#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] use std::io::{BufRead, BufReader}; #[cfg(any( target_vendor = "apple", @@ -481,7 +483,7 @@ use std::slice; /// Read file system list. pub fn read_fs_list() -> UResult> { - #[cfg(any(target_os = "linux", target_os = "android"))] + #[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] { let (file_name, f) = File::open(LINUX_MOUNTINFO) .map(|f| (LINUX_MOUNTINFO, f)) @@ -722,6 +724,7 @@ impl FsMeta for StatFs { not(target_os = "solaris"), not(target_os = "redox"), not(target_arch = "s390x"), + not(target_os = "cygwin"), target_pointer_width = "64" ))] return self.f_bsize; @@ -730,6 +733,7 @@ impl FsMeta for StatFs { not(target_os = "freebsd"), not(target_os = "netbsd"), not(target_os = "redox"), + not(target_os = "cygwin"), any( target_arch = "s390x", target_vendor = "apple", @@ -747,6 +751,7 @@ impl FsMeta for StatFs { target_os = "illumos", target_os = "solaris", target_os = "redox", + target_os = "cygwin", all(target_os = "android", target_pointer_width = "64"), ))] return self.f_bsize.try_into().unwrap(); diff --git a/src/uucore/src/lib/features/signals.rs b/src/uucore/src/lib/features/signals.rs index 4e7fe81c9af..0bccb2173f6 100644 --- a/src/uucore/src/lib/features/signals.rs +++ b/src/uucore/src/lib/features/signals.rs @@ -3,8 +3,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (vars/api) fcntl setrlimit setitimer rubout pollable sysconf -// spell-checker:ignore (vars/signals) ABRT ALRM CHLD SEGV SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGDANGER SIGEMT SIGFPE SIGHUP SIGILL SIGINFO SIGINT SIGIO SIGIOT SIGKILL SIGMIGRATE SIGMSG SIGPIPE SIGPRE SIGPROF SIGPWR SIGQUIT SIGSEGV SIGSTOP SIGSYS SIGTALRM SIGTERM SIGTRAP SIGTSTP SIGTHR SIGTTIN SIGTTOU SIGURG SIGUSR SIGVIRT SIGVTALRM SIGWINCH SIGXCPU SIGXFSZ STKFLT PWR THR TSTP TTIN TTOU VIRT VTALRM XCPU XFSZ SIGCLD SIGPOLL SIGWAITING SIGAIOCANCEL SIGLWP SIGFREEZE SIGTHAW SIGCANCEL SIGLOST SIGXRES SIGJVM SIGRTMIN SIGRT SIGRTMAX TALRM AIOCANCEL XRES RTMIN RTMAX +// spell-checker:ignore (vars/api) fcntl setrlimit setitimer rubout pollable sysconf pgrp +// spell-checker:ignore (vars/signals) ABRT ALRM CHLD SEGV SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGDANGER SIGEMT SIGFPE SIGHUP SIGILL SIGINFO SIGINT SIGIO SIGIOT SIGKILL SIGMIGRATE SIGMSG SIGPIPE SIGPRE SIGPROF SIGPWR SIGQUIT SIGSEGV SIGSTOP SIGSYS SIGTALRM SIGTERM SIGTRAP SIGTSTP SIGTHR SIGTTIN SIGTTOU SIGURG SIGUSR SIGVIRT SIGVTALRM SIGWINCH SIGXCPU SIGXFSZ STKFLT PWR THR TSTP TTIN TTOU VIRT VTALRM XCPU XFSZ SIGCLD SIGPOLL SIGWAITING SIGAIOCANCEL SIGLWP SIGFREEZE SIGTHAW SIGCANCEL SIGLOST SIGXRES SIGJVM SIGRTMIN SIGRT SIGRTMAX TALRM AIOCANCEL XRES RTMIN RTMAX LTOSTOP //! This module provides a way to handle signals in a platform-independent way. //! It provides a way to convert signal names to their corresponding values and vice versa. @@ -346,6 +346,49 @@ pub static ALL_SIGNALS: [&str; 37] = [ "VIRT", "TALRM", ]; +/* + The following signals are defined in Cygwin + https://cygwin.com/cgit/newlib-cygwin/tree/winsup/cygwin/include/cygwin/signal.h + + SIGHUP 1 hangup + SIGINT 2 interrupt + SIGQUIT 3 quit + SIGILL 4 illegal instruction (not reset when caught) + SIGTRAP 5 trace trap (not reset when caught) + SIGABRT 6 used by abort + SIGEMT 7 EMT instruction + SIGFPE 8 floating point exception + SIGKILL 9 kill (cannot be caught or ignored) + SIGBUS 10 bus error + SIGSEGV 11 segmentation violation + SIGSYS 12 bad argument to system call + SIGPIPE 13 write on a pipe with no one to read it + SIGALRM 14 alarm clock + SIGTERM 15 software termination signal from kill + SIGURG 16 urgent condition on IO channel + SIGSTOP 17 sendable stop signal not from tty + SIGTSTP 18 stop signal from tty + SIGCONT 19 continue a stopped process + SIGCHLD 20 to parent on child stop or exit + SIGTTIN 21 to readers pgrp upon background tty read + SIGTTOU 22 like TTIN for output if (tp->t_local<OSTOP) + SIGIO 23 input/output possible signal + SIGXCPU 24 exceeded CPU time limit + SIGXFSZ 25 exceeded file size limit + SIGVTALRM 26 virtual time alarm + SIGPROF 27 profiling time alarm + SIGWINCH 28 window changed + SIGLOST 29 resource lost (eg, record-lock lost) + SIGUSR1 30 user defined signal 1 + SIGUSR2 31 user defined signal 2 +*/ +#[cfg(target_os = "cygwin")] +pub static ALL_SIGNALS: [&str; 32] = [ + "EXIT", "HUP", "INT", "QUIT", "ILL", "TRAP", "ABRT", "EMT", "FPE", "KILL", "BUS", "SEGV", + "SYS", "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP", "CONT", "CHLD", "TTIN", "TTOU", "IO", + "XCPU", "XFSZ", "VTALRM", "PROF", "WINCH", "PWR", "USR1", "USR2", +]; + /// Returns the signal number for a given signal name or value. pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option { let signal_name_upcase = signal_name_or_value.to_uppercase();