Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial AIX support #6209

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl FileInformation {
#[cfg(all(
unix,
not(target_vendor = "apple"),
not(target_os = "aix"),
not(target_os = "android"),
not(target_os = "freebsd"),
not(target_os = "netbsd"),
Expand Down Expand Up @@ -142,6 +143,8 @@ impl FileInformation {
)
))]
return self.0.st_nlink.into();
#[cfg(target_os = "aix")]
return self.0.st_nlink.try_into().unwrap();
#[cfg(windows)]
return self.0.number_of_links();
}
Expand Down
19 changes: 14 additions & 5 deletions src/uucore/src/lib/features/fsext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const LINUX_MTAB: &str = "/etc/mtab";
#[cfg(any(target_os = "linux", target_os = "android"))]
const LINUX_MOUNTINFO: &str = "/proc/self/mountinfo";
#[cfg(all(unix, not(target_os = "redox")))]
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
static MOUNT_OPT_BIND: &str = "bind";
#[cfg(windows)]
const MAX_PATH: usize = 266;
Expand Down Expand Up @@ -83,6 +83,7 @@ use std::time::UNIX_EPOCH;
))]
pub use libc::statfs as StatFs;
#[cfg(any(
target_os = "aix",
target_os = "netbsd",
target_os = "bitrig",
target_os = "dragonfly",
Expand All @@ -101,6 +102,7 @@ pub use libc::statvfs as StatFs;
))]
pub use libc::statfs as statfs_fn;
#[cfg(any(
target_os = "aix",
target_os = "netbsd",
target_os = "bitrig",
target_os = "illumos",
Expand Down Expand Up @@ -304,7 +306,7 @@ impl From<StatFs> for MountInfo {
}
}

#[cfg(all(unix, not(target_os = "redox")))]
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
fn is_dummy_filesystem(fs_type: &str, mount_option: &str) -> bool {
// spell-checker:disable
match fs_type {
Expand All @@ -323,14 +325,14 @@ fn is_dummy_filesystem(fs_type: &str, mount_option: &str) -> bool {
// spell-checker:enable
}

#[cfg(all(unix, not(target_os = "redox")))]
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
fn is_remote_filesystem(dev_name: &str, fs_type: &str) -> bool {
dev_name.find(':').is_some()
|| (dev_name.starts_with("//") && fs_type == "smbfs" || fs_type == "cifs")
|| dev_name == "-hosts"
}

#[cfg(all(unix, not(target_os = "redox")))]
#[cfg(all(unix, not(any(target_os = "aix", target_os = "redox"))))]
fn mount_dev_id(mount_dir: &str) -> String {
use std::os::unix::fs::MetadataExt;

Expand Down Expand Up @@ -472,7 +474,12 @@ pub fn read_fs_list() -> Result<Vec<MountInfo>, std::io::Error> {
}
Ok(mounts)
}
#[cfg(any(target_os = "redox", target_os = "illumos", target_os = "solaris"))]
#[cfg(any(
target_os = "aix",
target_os = "redox",
target_os = "illumos",
target_os = "solaris"
))]
{
// No method to read mounts, yet
Ok(Vec::new())
Expand Down Expand Up @@ -633,6 +640,7 @@ impl FsMeta for StatFs {
#[cfg(all(
not(target_env = "musl"),
not(target_vendor = "apple"),
not(target_os = "aix"),
not(target_os = "android"),
not(target_os = "freebsd"),
not(target_os = "openbsd"),
Expand All @@ -658,6 +666,7 @@ impl FsMeta for StatFs {
return self.f_bsize.into();
#[cfg(any(
target_env = "musl",
target_os = "aix",
target_os = "freebsd",
target_os = "illumos",
target_os = "solaris",
Expand Down
51 changes: 50 additions & 1 deletion src/uucore/src/lib/features/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 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 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
// 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
#[cfg(unix)]
use nix::errno::Errno;
#[cfg(unix)]
Expand Down Expand Up @@ -290,6 +290,55 @@ static ALL_SIGNALS: [&str; SIGNALS_SIZE] = [
"RTMAX",
];

/*
The following signals are defined in AIX:

SIGHUP hangup, generated when terminal disconnects
SIGINT interrupt, generated from terminal special char
SIGQUIT quit, generated from terminal special char
SIGILL illegal instruction (not reset when caught)
SIGTRAP trace trap (not reset when caught)
SIGABRT abort process
SIGEMT EMT instruction
SIGFPE floating point exception
SIGKILL kill (cannot be caught or ignored)
SIGBUS bus error (specification exception)
SIGSEGV segmentation violation
SIGSYS bad argument to system call
SIGPIPE write on a pipe with no one to read it
SIGALRM alarm clock timeout
SIGTERM software termination signal
SIGURG urgent condition on I/O channel
SIGSTOP stop (cannot be caught or ignored)
SIGTSTP interactive stop
SIGCONT continue (cannot be caught or ignored)
SIGCHLD sent to parent on child stop or exit
SIGTTIN background read attempted from control terminal
SIGTTOU background write attempted to control terminal
SIGIO I/O possible, or completed
SIGXCPU cpu time limit exceeded (see setrlimit())
SIGXFSZ file size limit exceeded (see setrlimit())
SIGMSG input data is in the ring buffer
SIGWINCH window size changed
SIGPWR power-fail restart
SIGUSR1 user defined signal 1
SIGUSR2 user defined signal 2
SIGPROF profiling time alarm (see setitimer)
SIGDANGER system crash imminent; free up some page space
SIGVTALRM virtual time alarm (see setitimer)
SIGMIGRATE migrate process
SIGPRE programming exception
SIGVIRT AIX virtual time alarm
SIGTALRM per-thread alarm clock
*/
#[cfg(target_os = "aix")]
pub static ALL_SIGNALS: [&str; 37] = [
"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", "MSG", "WINCH", "PWR", "USR1", "USR2", "PROF", "DANGER", "VTALRM", "MIGRATE", "PRE",
"VIRT", "TALRM",
];

pub fn signal_by_name_or_value(signal_name_or_value: &str) -> Option<usize> {
if let Ok(value) = signal_name_or_value.parse() {
if is_signal(value) {
Expand Down
Loading