Skip to content

Commit 60fbc3e

Browse files
committed
uucore: support cygwin
requires [libc patch](rust-lang/libc@a3bb40e), mio v1.1.0 and [nix patch](nix-rust/nix#\2708). behavour is mostly matched with Linux
1 parent ee39b35 commit 60fbc3e

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/uucore/src/lib/features/fs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl FileInformation {
123123
not(target_os = "openbsd"),
124124
not(target_os = "illumos"),
125125
not(target_os = "solaris"),
126+
not(target_os = "cygwin"),
126127
not(target_arch = "aarch64"),
127128
not(target_arch = "riscv64"),
128129
not(target_arch = "loongarch64"),
@@ -140,6 +141,7 @@ impl FileInformation {
140141
target_os = "openbsd",
141142
target_os = "illumos",
142143
target_os = "solaris",
144+
target_os = "cygwin",
143145
target_arch = "aarch64",
144146
target_arch = "riscv64",
145147
target_arch = "loongarch64",

src/uucore/src/lib/features/fsext.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
88
// spell-checker:ignore DATETIME getmntinfo subsecond (fs) cifs smbfs
99

10-
#[cfg(any(target_os = "linux", target_os = "android"))]
10+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
1111
const LINUX_MTAB: &str = "/etc/mtab";
12-
#[cfg(any(target_os = "linux", target_os = "android"))]
12+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
1313
const LINUX_MOUNTINFO: &str = "/proc/self/mountinfo";
1414
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
1515
static MOUNT_OPT_BIND: &str = "bind";
@@ -94,7 +94,8 @@ pub use libc::statfs as StatFs;
9494
target_os = "dragonfly",
9595
target_os = "illumos",
9696
target_os = "solaris",
97-
target_os = "redox"
97+
target_os = "redox",
98+
target_os = "cygwin",
9899
))]
99100
pub use libc::statvfs as StatFs;
100101

@@ -112,7 +113,8 @@ pub use libc::statfs as statfs_fn;
112113
target_os = "illumos",
113114
target_os = "solaris",
114115
target_os = "dragonfly",
115-
target_os = "redox"
116+
target_os = "redox",
117+
target_os = "cygwin",
116118
))]
117119
pub use libc::statvfs as statfs_fn;
118120

@@ -189,7 +191,7 @@ pub struct MountInfo {
189191
pub dummy: bool,
190192
}
191193

192-
#[cfg(any(target_os = "linux", target_os = "android"))]
194+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
193195
fn replace_special_chars(s: &[u8]) -> Vec<u8> {
194196
use bstr::ByteSlice;
195197

@@ -205,7 +207,7 @@ fn replace_special_chars(s: &[u8]) -> Vec<u8> {
205207
}
206208

207209
impl MountInfo {
208-
#[cfg(any(target_os = "linux", target_os = "android"))]
210+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
209211
fn new(file_name: &str, raw: &[&[u8]]) -> Option<Self> {
210212
use std::ffi::OsStr;
211213
use std::os::unix::ffi::OsStrExt;
@@ -459,9 +461,9 @@ use crate::error::UResult;
459461
target_os = "windows"
460462
))]
461463
use crate::error::USimpleError;
462-
#[cfg(any(target_os = "linux", target_os = "android"))]
464+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
463465
use std::fs::File;
464-
#[cfg(any(target_os = "linux", target_os = "android"))]
466+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
465467
use std::io::{BufRead, BufReader};
466468
#[cfg(any(
467469
target_vendor = "apple",
@@ -481,7 +483,7 @@ use std::slice;
481483

482484
/// Read file system list.
483485
pub fn read_fs_list() -> UResult<Vec<MountInfo>> {
484-
#[cfg(any(target_os = "linux", target_os = "android"))]
486+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))]
485487
{
486488
let (file_name, f) = File::open(LINUX_MOUNTINFO)
487489
.map(|f| (LINUX_MOUNTINFO, f))
@@ -722,6 +724,7 @@ impl FsMeta for StatFs {
722724
not(target_os = "solaris"),
723725
not(target_os = "redox"),
724726
not(target_arch = "s390x"),
727+
not(target_os = "cygwin"),
725728
target_pointer_width = "64"
726729
))]
727730
return self.f_bsize;
@@ -730,6 +733,7 @@ impl FsMeta for StatFs {
730733
not(target_os = "freebsd"),
731734
not(target_os = "netbsd"),
732735
not(target_os = "redox"),
736+
not(target_os = "cygwin"),
733737
any(
734738
target_arch = "s390x",
735739
target_vendor = "apple",
@@ -747,6 +751,7 @@ impl FsMeta for StatFs {
747751
target_os = "illumos",
748752
target_os = "solaris",
749753
target_os = "redox",
754+
target_os = "cygwin",
750755
all(target_os = "android", target_pointer_width = "64"),
751756
))]
752757
return self.f_bsize.try_into().unwrap();

src/uucore/src/lib/features/signals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Linux Programmer's Manual
3434
*/
3535

3636
/// The list of all signals.
37-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "redox"))]
37+
#[cfg(any(target_os = "linux", target_os = "android", target_os = "redox", target_os = "cygwin"))]
3838
pub static ALL_SIGNALS: [&str; 32] = [
3939
"EXIT", "HUP", "INT", "QUIT", "ILL", "TRAP", "ABRT", "BUS", "FPE", "KILL", "USR1", "SEGV",
4040
"USR2", "PIPE", "ALRM", "TERM", "STKFLT", "CHLD", "CONT", "STOP", "TSTP", "TTIN", "TTOU",

0 commit comments

Comments
 (0)