Skip to content

Commit d04c846

Browse files
committed
Fix compilation errors on illumos.
Make rustix compile under x86_64-unknown-illumos. This configuration is not yet tested; this just fixes the compilation errors.
1 parent 80fd11e commit d04c846

File tree

20 files changed

+263
-45
lines changed

20 files changed

+263
-45
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
x86_64-unknown-freebsd
5858
x86_64-unknown-netbsd
5959
x86_64-fuchsia
60+
x86_64-unknown-illumos
6061
i686-unknown-linux-gnu
6162
i686-unknown-linux-musl
6263
wasm32-unknown-emscripten
@@ -77,6 +78,7 @@ jobs:
7778
- run: cargo check --workspace --release -vv --target=x86_64-unknown-freebsd
7879
- run: cargo check --workspace --release -vv --target=x86_64-unknown-netbsd
7980
- run: cargo check --workspace --release -vv --target=x86_64-fuchsia
81+
- run: cargo check --workspace --release -vv --target=x86_64-unknown-illumos
8082
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-gnu
8183
- run: cargo check --workspace --release -vv --target=i686-unknown-linux-musl
8284
- run: cargo check --workspace --release -vv --target=wasm32-unknown-emscripten

src/fs/abs.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
//! POSIX-style filesystem functions which operate on bare paths.
22
3-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
3+
#[cfg(not(any(
4+
target_os = "illumos",
5+
target_os = "netbsd",
6+
target_os = "redox",
7+
target_os = "wasi"
8+
)))]
49
use crate::{imp, io, path};
5-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
10+
#[cfg(not(any(
11+
target_os = "illumos",
12+
target_os = "netbsd",
13+
target_os = "redox",
14+
target_os = "wasi"
15+
)))]
616
use imp::fs::StatFs;
717

818
/// `statfs`—Queries filesystem metadata.
@@ -11,7 +21,12 @@ use imp::fs::StatFs;
1121
/// - [Linux]
1222
///
1323
/// [Linux]: https://man7.org/linux/man-pages/man2/statfs.2.html
14-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
24+
#[cfg(not(any(
25+
target_os = "illumos",
26+
target_os = "netbsd",
27+
target_os = "redox",
28+
target_os = "wasi"
29+
)))]
1530
#[inline]
1631
pub fn statfs<P: path::Arg>(path: P) -> io::Result<StatFs> {
1732
path.into_with_z_str(|path| imp::syscalls::statfs(path))

src/fs/at.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ use crate::process::{Gid, Uid};
1818
use crate::{imp, path};
1919
use alloc::vec::Vec;
2020
use imp::fd::{AsFd, BorrowedFd};
21-
use imp::fs::{Access, AtFlags, Mode, OFlags, Stat};
21+
#[cfg(not(target_os = "illumos"))]
22+
use imp::fs::Access;
23+
use imp::fs::{AtFlags, Mode, OFlags, Stat};
2224
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "wasi")))]
2325
use imp::fs::{Dev, FileType};
2426

@@ -247,6 +249,7 @@ pub fn statat<P: path::Arg, Fd: AsFd>(dirfd: &Fd, path: P, flags: AtFlags) -> io
247249
///
248250
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/faccessat.html
249251
/// [Linux]: https://man7.org/linux/man-pages/man2/faccessat.2.html
252+
#[cfg(not(target_os = "illumos"))]
250253
#[inline]
251254
#[doc(alias = "faccessat")]
252255
pub fn accessat<P: path::Arg, Fd: AsFd>(

src/fs/fcntl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pub fn fcntl_setfl<Fd: AsFd>(fd: &Fd, flags: OFlags) -> io::Result<()> {
8181
not(any(
8282
target_os = "dragonfly",
8383
target_os = "freebsd",
84+
target_os = "illumos",
8485
target_os = "ios",
8586
target_os = "macos",
8687
target_os = "netbsd",

src/fs/fd.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ use crate::{imp, io};
88
use imp::fd::{AsFd, BorrowedFd};
99
#[cfg(not(any(
1010
target_os = "dragonfly",
11+
target_os = "illumos",
1112
target_os = "netbsd",
1213
target_os = "openbsd",
1314
target_os = "redox"
1415
)))]
1516
use imp::fs::FallocateFlags;
1617
use imp::fs::Stat;
17-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
18+
#[cfg(not(any(
19+
target_os = "illumos",
20+
target_os = "netbsd",
21+
target_os = "redox",
22+
target_os = "wasi"
23+
)))]
1824
// not implemented in libc for netbsd yet
1925
use imp::fs::StatFs;
2026
#[cfg(not(target_os = "wasi"))]
@@ -110,7 +116,12 @@ pub fn fstat<Fd: AsFd>(fd: &Fd) -> io::Result<Stat> {
110116
/// - [Linux]
111117
///
112118
/// [Linux]: https://man7.org/linux/man-pages/man2/fstatfs.2.html
113-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))] // not implemented in libc for netbsd yet
119+
#[cfg(not(any(
120+
target_os = "illumos",
121+
target_os = "netbsd",
122+
target_os = "redox",
123+
target_os = "wasi"
124+
)))] // not implemented in libc for netbsd yet
114125
#[inline]
115126
pub fn fstatfs<Fd: AsFd>(fd: &Fd) -> io::Result<StatFs> {
116127
let fd = fd.as_fd();
@@ -148,6 +159,7 @@ pub fn futimens<Fd: AsFd>(fd: &Fd, times: &Timestamps) -> io::Result<()> {
148159
/// [Linux `posix_fallocate`]: https://man7.org/linux/man-pages/man3/posix_fallocate.3.html
149160
#[cfg(not(any(
150161
target_os = "dragonfly",
162+
target_os = "illumos",
151163
target_os = "netbsd",
152164
target_os = "openbsd",
153165
target_os = "redox"

src/fs/mod.rs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mod cwd;
1515
mod dir;
1616
#[cfg(not(any(
1717
target_os = "dragonfly",
18+
target_os = "illumos",
1819
target_os = "ios",
1920
target_os = "macos",
2021
target_os = "netbsd",
@@ -33,6 +34,7 @@ mod file_type;
3334
mod getpath;
3435
#[cfg(not(any(
3536
target_os = "dragonfly",
37+
target_os = "illumos",
3638
target_os = "ios",
3739
target_os = "freebsd",
3840
target_os = "macos",
@@ -51,8 +53,15 @@ mod sendfile;
5153
#[cfg(all(target_os = "linux", target_env = "gnu"))]
5254
mod statx;
5355

54-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
56+
#[cfg(not(any(
57+
target_os = "illumos",
58+
target_os = "netbsd",
59+
target_os = "redox",
60+
target_os = "wasi"
61+
)))]
5562
pub use abs::statfs;
63+
#[cfg(not(any(target_os = "illumos", target_os = "redox")))]
64+
pub use at::accessat;
5665
#[cfg(any(target_os = "ios", target_os = "macos"))]
5766
pub use at::fclonefileat;
5867
#[cfg(not(any(
@@ -64,12 +73,12 @@ pub use at::fclonefileat;
6473
pub use at::mknodat;
6574
#[cfg(any(linux_raw, all(libc, any(target_os = "android", target_os = "linux"))))]
6675
pub use at::renameat_with;
76+
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
77+
pub use at::{chmodat, chownat};
6778
#[cfg(not(target_os = "redox"))]
6879
pub use at::{
69-
accessat, linkat, mkdirat, openat, readlinkat, renameat, statat, symlinkat, unlinkat, utimensat,
80+
linkat, mkdirat, openat, readlinkat, renameat, statat, symlinkat, unlinkat, utimensat,
7081
};
71-
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
72-
pub use at::{chmodat, chownat};
7382
#[cfg(not(target_os = "redox"))]
7483
pub use constants::AtFlags;
7584
#[cfg(any(target_os = "ios", target_os = "macos"))]
@@ -90,6 +99,7 @@ pub use cwd::cwd;
9099
pub use dir::{Dir, DirEntry};
91100
#[cfg(not(any(
92101
target_os = "dragonfly",
102+
target_os = "illumos",
93103
target_os = "ios",
94104
target_os = "macos",
95105
target_os = "netbsd",
@@ -102,6 +112,7 @@ pub use fcntl::fcntl_dupfd_cloexec;
102112
#[cfg(not(any(
103113
target_os = "dragonfly",
104114
target_os = "freebsd",
115+
target_os = "illumos",
105116
target_os = "ios",
106117
target_os = "macos",
107118
target_os = "netbsd",
@@ -120,6 +131,7 @@ pub use fcopyfile::{
120131
};
121132
#[cfg(not(any(
122133
target_os = "dragonfly",
134+
target_os = "illumos",
123135
target_os = "netbsd",
124136
target_os = "openbsd",
125137
target_os = "redox"
@@ -132,7 +144,12 @@ pub use fd::fallocate;
132144
target_os = "redox"
133145
)))]
134146
pub use fd::fdatasync;
135-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
147+
#[cfg(not(any(
148+
target_os = "illumos",
149+
target_os = "netbsd",
150+
target_os = "redox",
151+
target_os = "wasi"
152+
)))]
136153
// not implemented in libc for netbsd yet
137154
pub use fd::fstatfs;
138155
#[cfg(not(target_os = "wasi"))]
@@ -143,6 +160,7 @@ pub use file_type::FileType;
143160
pub use getpath::getpath;
144161
#[cfg(not(any(
145162
target_os = "dragonfly",
163+
target_os = "illumos",
146164
target_os = "ios",
147165
target_os = "freebsd",
148166
target_os = "macos",
@@ -163,13 +181,23 @@ pub use statx::{statx, StatxFlags};
163181

164182
pub use imp::fs::Stat;
165183

166-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
184+
#[cfg(not(any(
185+
target_os = "illumos",
186+
target_os = "netbsd",
187+
target_os = "redox",
188+
target_os = "wasi"
189+
)))]
167190
pub use imp::fs::StatFs;
168191

169192
#[cfg(any(linux_raw, all(libc, target_os = "linux", target_env = "gnu")))]
170193
pub use imp::fs::Statx;
171194

172-
#[cfg(not(any(target_os = "netbsd", target_os = "openbsd", target_os = "redox")))]
195+
#[cfg(not(any(
196+
target_os = "illumos",
197+
target_os = "netbsd",
198+
target_os = "openbsd",
199+
target_os = "redox"
200+
)))]
173201
pub use imp::fs::FallocateFlags;
174202

175203
/// `UTIME_NOW` for use with [`utimensat`].

src/imp/libc/fs/dir.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::super::c;
22
use super::super::conv::owned_fd;
3+
#[cfg(not(target_os = "illumos"))]
34
use super::FileType;
45
#[cfg(not(any(io_lifetimes_use_std, not(feature = "std"))))]
56
use crate::fd::IntoFd;
@@ -115,6 +116,7 @@ impl Dir {
115116
// struct, as the name is NUL-terminated and memory may not be allocated for
116117
// the full extent of the struct. Copy the fields one at a time.
117118
unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
119+
#[cfg(not(target_os = "illumos"))]
118120
let d_type = input.d_type;
119121

120122
#[cfg(not(any(
@@ -158,6 +160,7 @@ unsafe fn read_dirent(input: &libc_dirent) -> libc_dirent {
158160
// whole `d_name` field, which may not be entirely allocated.
159161
#[cfg_attr(target_os = "wasi", allow(unused_mut))]
160162
let mut dirent = libc_dirent {
163+
#[cfg(not(target_os = "illumos"))]
161164
d_type,
162165
#[cfg(not(any(
163166
target_os = "dragonfly",
@@ -269,6 +272,7 @@ impl DirEntry {
269272

270273
/// Returns the type of this directory entry.
271274
#[inline]
275+
#[cfg(not(target_os = "illumos"))]
272276
pub fn file_type(&self) -> FileType {
273277
FileType::from_dirent_d_type(self.dirent.d_type)
274278
}

src/imp/libc/fs/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub(crate) mod syscalls;
55
mod dir;
66
#[cfg(not(any(
77
target_os = "dragonfly",
8+
target_os = "illumos",
89
target_os = "ios",
910
target_os = "freebsd",
1011
target_os = "macos",
@@ -20,6 +21,7 @@ mod types;
2021
pub use dir::{Dir, DirEntry};
2122
#[cfg(not(any(
2223
target_os = "dragonfly",
24+
target_os = "illumos",
2325
target_os = "ios",
2426
target_os = "freebsd",
2527
target_os = "macos",
@@ -31,18 +33,29 @@ pub use dir::{Dir, DirEntry};
3133
pub use makedev::{major, makedev, minor};
3234
#[cfg(not(any(
3335
target_os = "dragonfly",
36+
target_os = "illumos",
3437
target_os = "ios",
3538
target_os = "macos",
3639
target_os = "netbsd",
3740
target_os = "openbsd",
3841
target_os = "redox"
3942
)))]
4043
pub use types::Advice;
41-
#[cfg(not(any(target_os = "netbsd", target_os = "openbsd", target_os = "redox")))]
44+
#[cfg(not(any(
45+
target_os = "illumos",
46+
target_os = "netbsd",
47+
target_os = "openbsd",
48+
target_os = "redox"
49+
)))]
4250
pub use types::FallocateFlags;
4351
#[cfg(not(target_os = "wasi"))]
4452
pub use types::FlockOperation;
45-
#[cfg(not(any(target_os = "netbsd", target_os = "redox", target_os = "wasi")))]
53+
#[cfg(not(any(
54+
target_os = "illumos",
55+
target_os = "netbsd",
56+
target_os = "redox",
57+
target_os = "wasi"
58+
)))]
4659
pub use types::StatFs;
4760
#[cfg(any(target_os = "ios", target_os = "macos"))]
4861
pub use types::{copyfile_state_t, CloneFlags, CopyfileFlags};

0 commit comments

Comments
 (0)