Skip to content

Commit

Permalink
Initial AIX support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ecnelises committed Apr 10, 2024
1 parent f95a8eb commit bdff941
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 7 deletions.
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
49 changes: 49 additions & 0 deletions src/uucore/src/lib/features/signals.rs
Original file line number Diff line number Diff line change
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 intruction
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 contition 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

0 comments on commit bdff941

Please sign in to comment.