Skip to content

Commit 44d105d

Browse files
authored
Add support in uucore for illumos and solaris (#5489)
* uucore support for illumos and solaris * use macro to consolidate illumos and solaris signals * fixing some CI issues * replaced macro with better cfg usage
1 parent 347bded commit 44d105d

File tree

3 files changed

+129
-4
lines changed

3 files changed

+129
-4
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ impl FileInformation {
115115
not(target_os = "android"),
116116
not(target_os = "freebsd"),
117117
not(target_os = "netbsd"),
118+
not(target_os = "illumos"),
119+
not(target_os = "solaris"),
118120
not(target_arch = "aarch64"),
119121
not(target_arch = "riscv64"),
120122
target_pointer_width = "64"
@@ -127,6 +129,8 @@ impl FileInformation {
127129
target_os = "android",
128130
target_os = "freebsd",
129131
target_os = "netbsd",
132+
target_os = "illumos",
133+
target_os = "solaris",
130134
target_arch = "aarch64",
131135
target_arch = "riscv64",
132136
not(target_pointer_width = "64")

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ use std::convert::{AsRef, From};
6969
target_os = "openbsd",
7070
target_os = "linux",
7171
target_os = "android",
72+
target_os = "illumos",
73+
target_os = "solaris",
7274
))]
7375
use std::ffi::CStr;
7476
#[cfg(not(windows))]
@@ -309,7 +311,7 @@ impl MountInfo {
309311
target_os = "freebsd",
310312
target_vendor = "apple",
311313
target_os = "netbsd",
312-
target_os = "openbsd"
314+
target_os = "openbsd",
313315
))]
314316
impl From<StatFs> for MountInfo {
315317
fn from(statfs: StatFs) -> Self {
@@ -615,6 +617,8 @@ impl FsMeta for StatFs {
615617
not(target_vendor = "apple"),
616618
not(target_os = "android"),
617619
not(target_os = "freebsd"),
620+
not(target_os = "illumos"),
621+
not(target_os = "solaris"),
618622
not(target_arch = "s390x"),
619623
target_pointer_width = "64"
620624
))]
@@ -630,7 +634,12 @@ impl FsMeta for StatFs {
630634
)
631635
))]
632636
return self.f_bsize.into();
633-
#[cfg(any(target_env = "musl", target_os = "freebsd"))]
637+
#[cfg(any(
638+
target_env = "musl",
639+
target_os = "freebsd",
640+
target_os = "illumos",
641+
target_os = "solaris"
642+
))]
634643
return self.f_bsize.try_into().unwrap();
635644
}
636645
fn total_blocks(&self) -> u64 {

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

Lines changed: 114 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
55

6-
// spell-checker:ignore (vars/api) fcntl setrlimit setitimer
7-
// spell-checker:ignore (vars/signals) ABRT ALRM CHLD SEGV SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGEMT SIGFPE SIGHUP SIGILL SIGINFO SIGINT SIGIO SIGIOT SIGKILL SIGPIPE SIGPROF SIGPWR SIGQUIT SIGSEGV SIGSTOP SIGSYS SIGTERM SIGTRAP SIGTSTP SIGTHR SIGTTIN SIGTTOU SIGURG SIGUSR SIGVTALRM SIGWINCH SIGXCPU SIGXFSZ STKFLT PWR THR TSTP TTIN TTOU VTALRM XCPU XFSZ
6+
// spell-checker:ignore (vars/api) fcntl setrlimit setitimer rubout pollable occured sysconf
7+
// spell-checker:ignore (vars/signals) ABRT ALRM CHLD SEGV SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGEMT SIGFPE SIGHUP SIGILL SIGINFO SIGINT SIGIO SIGIOT SIGKILL SIGPIPE SIGPROF SIGPWR SIGQUIT SIGSEGV SIGSTOP SIGSYS SIGTERM SIGTRAP SIGTSTP SIGTHR SIGTTIN SIGTTOU SIGURG SIGUSR SIGVTALRM SIGWINCH SIGXCPU SIGXFSZ STKFLT PWR THR TSTP TTIN TTOU VTALRM XCPU XFSZ SIGCLD SIGPOLL SIGWAITING SIGAIOCANCEL SIGLWP SIGFREEZE SIGTHAW SIGCANCEL SIGLOST SIGXRES SIGJVM SIGRTMIN SIGRT SIGRTMAX AIOCANCEL XRES RTMIN RTMAX
88
#[cfg(unix)]
99
use nix::errno::Errno;
1010
#[cfg(unix)]
1111
use nix::sys::signal::{
1212
signal, SigHandler::SigDfl, SigHandler::SigIgn, Signal::SIGINT, Signal::SIGPIPE,
1313
};
14+
1415
pub static DEFAULT_SIGNAL: usize = 15;
1516

1617
/*
@@ -178,6 +179,117 @@ pub static ALL_SIGNALS: [&str; 33] = [
178179
"XCPU", "XFSZ", "VTALRM", "PROF", "WINCH", "INFO", "USR1", "USR2", "THR",
179180
];
180181

182+
/*
183+
The following signals are defined in Solaris and illumos;
184+
(the signals for illumos are the same as Solaris, but illumos still has SIGLWP
185+
as well as the alias for SIGLWP (SIGAIOCANCEL)):
186+
187+
SIGHUP 1 hangup
188+
SIGINT 2 interrupt (rubout)
189+
SIGQUIT 3 quit (ASCII FS)
190+
SIGILL 4 illegal instruction (not reset when caught)
191+
SIGTRAP 5 trace trap (not reset when caught)
192+
SIGIOT 6 IOT instruction
193+
SIGABRT 6 used by abort, replace SIGIOT in the future
194+
SIGEMT 7 EMT instruction
195+
SIGFPE 8 floating point exception
196+
SIGKILL 9 kill (cannot be caught or ignored)
197+
SIGBUS 10 bus error
198+
SIGSEGV 11 segmentation violation
199+
SIGSYS 12 bad argument to system call
200+
SIGPIPE 13 write on a pipe with no one to read it
201+
SIGALRM 14 alarm clock
202+
SIGTERM 15 software termination signal from kill
203+
SIGUSR1 16 user defined signal 1
204+
SIGUSR2 17 user defined signal 2
205+
SIGCLD 18 child status change
206+
SIGCHLD 18 child status change alias (POSIX)
207+
SIGPWR 19 power-fail restart
208+
SIGWINCH 20 window size change
209+
SIGURG 21 urgent socket condition
210+
SIGPOLL 22 pollable event occured
211+
SIGIO SIGPOLL socket I/O possible (SIGPOLL alias)
212+
SIGSTOP 23 stop (cannot be caught or ignored)
213+
SIGTSTP 24 user stop requested from tty
214+
SIGCONT 25 stopped process has been continued
215+
SIGTTIN 26 background tty read attempted
216+
SIGTTOU 27 background tty write attempted
217+
SIGVTALRM 28 virtual timer expired
218+
SIGPROF 29 profiling timer expired
219+
SIGXCPU 30 exceeded cpu limit
220+
SIGXFSZ 31 exceeded file size limit
221+
SIGWAITING 32 reserved signal no longer used by threading code
222+
SIGAIOCANCEL 33 reserved signal no longer used by threading code (formerly SIGLWP)
223+
SIGFREEZE 34 special signal used by CPR
224+
SIGTHAW 35 special signal used by CPR
225+
SIGCANCEL 36 reserved signal for thread cancellation
226+
SIGLOST 37 resource lost (eg, record-lock lost)
227+
SIGXRES 38 resource control exceeded
228+
SIGJVM1 39 reserved signal for Java Virtual Machine
229+
SIGJVM2 40 reserved signal for Java Virtual Machine
230+
SIGINFO 41 information request
231+
SIGRTMIN ((int)_sysconf(_SC_SIGRT_MIN)) first realtime signal
232+
SIGRTMAX ((int)_sysconf(_SC_SIGRT_MAX)) last realtime signal
233+
*/
234+
235+
#[cfg(target_os = "solaris")]
236+
const SIGNALS_SIZE: usize = 46;
237+
238+
#[cfg(target_os = "illumos")]
239+
const SIGNALS_SIZE: usize = 47;
240+
241+
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
242+
static ALL_SIGNALS: [&str; SIGNALS_SIZE] = [
243+
"HUP",
244+
"INT",
245+
"QUIT",
246+
"ILL",
247+
"TRAP",
248+
"IOT",
249+
"ABRT",
250+
"EMT",
251+
"FPE",
252+
"KILL",
253+
"BUS",
254+
"SEGV",
255+
"SYS",
256+
"PIPE",
257+
"ALRM",
258+
"TERM",
259+
"USR1",
260+
"USR2",
261+
"CLD",
262+
"CHLD",
263+
"PWR",
264+
"WINCH",
265+
"URG",
266+
"POLL",
267+
"IO",
268+
"STOP",
269+
"TSTP",
270+
"CONT",
271+
"TTIN",
272+
"TTOU",
273+
"VTALRM",
274+
"PROF",
275+
"XCPU",
276+
"XFSZ",
277+
"WAITING",
278+
"AIOCANCEL",
279+
#[cfg(target_os = "illumos")]
280+
"LWP",
281+
"FREEZE",
282+
"THAW",
283+
"CANCEL",
284+
"LOST",
285+
"XRES",
286+
"JVM1",
287+
"JVM2",
288+
"INFO",
289+
"RTMIN",
290+
"RTMAX",
291+
];
292+
181293
pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<usize> {
182294
if let Ok(value) = signal_name_or_value.parse() {
183295
if is_signal(value) {

0 commit comments

Comments
 (0)