Initial AIX support (#6209)

* Initial AIX support

Add support to build on AIX operating system. Most of the changes are
in fs part. Since AIX is still tier-3 target, current support is minimal
and does not require passing all tests.

* Fix spell checking failure
This commit is contained in:
Qiu Chaofan 2024-04-10 19:40:44 +08:00 committed by GitHub
parent f95a8ebd3d
commit 11c9351a9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 69 additions and 8 deletions

4
Cargo.lock generated
View file

@ -1960,9 +1960,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
dependencies = [
"libc",
]

View file

@ -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"),
@ -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();
}

View file

@ -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;
@ -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",
@ -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",
@ -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 {
@ -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;
@ -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())
@ -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"),
@ -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",

View file

@ -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)]
@ -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) {