Skip to content

Commit

Permalink
Update to rustix 0.38 and MSRV Rust 1.63 (#321)
Browse files Browse the repository at this point in the history
Update to rustix 0.38 and io-lifetimes 2.0, and update the MSRV to Rust
1.63.
  • Loading branch information
sunfishcode authored Jun 29, 2023
1 parent 6f7e9d4 commit 3e86e37
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ jobs:
include:
- build: msrv
os: ubuntu-latest
rust: 1.58
rust: 1.63

steps:
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2018"
publish = false
exclude = ["/.*"]
# This is also checked in CI.
rust-version = "1.56"
rust-version = "1.63"

[dev-dependencies]
#async-std = { version = "1.10.0", features = ["attributes"] }
Expand All @@ -30,10 +30,10 @@ rand = "0.8.1"
tempfile = "3.1.0"
camino = "1.0.5"
libc = "0.2.100"
io-lifetimes = "1.0.0"
io-lifetimes = "2.0.0"

[target.'cfg(not(windows))'.dev-dependencies]
rustix = { version = "0.37.9", features = ["fs"] }
rustix = { version = "0.38.0", features = ["fs"] }

[target.'cfg(windows)'.dev-dependencies]
# nt_version uses internal Windows APIs, however we're only using it
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ the process filesystem namespace.

## Minimum Supported Rust Version (MSRV)

This crate currently works on Rust 1.58, when default features are enabled.
This crate currently works on Rust 1.63, when default features are enabled.
Some of the optional features have stricter requirements.

[`arf-strings`]: https://github.com/bytecodealliance/arf-strings/
Expand Down
4 changes: 2 additions & 2 deletions cap-async-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ arf-strings = { version = "0.7.0", optional = true }
# Enable "unstable" for `spawn_blocking`.
async-std = { version = "1.10.0", features = ["attributes", "unstable"] }
cap-primitives = { path = "../cap-primitives", version = "^0.25.0" }
io-lifetimes = { version = "1.0.0", default-features = false, features = ["async-std"] }
io-lifetimes = { version = "2.0.0", default-features = false, features = ["async-std"] }
io-extras = { version = "0.17.0", features = ["use_async_std"] }
camino = { version = "1.0.5", optional = true }

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.37.9", features = ["fs"] }
rustix = { version = "0.38.0", features = ["fs"] }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion cap-directories/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cap-std = { path = "../cap-std", version = "^1.0.15" }
directories-next = "2.0.0"

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.37.9" }
rustix = { version = "0.38.0" }

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.48.0"
Expand Down
2 changes: 1 addition & 1 deletion cap-fs-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ arf-strings = { version = "0.7.0", optional = true }
#cap-async-std = { path = "../cap-async-std", optional = true, version = "^0.25.0" }
cap-std = { path = "../cap-std", optional = true, version = "^1.0.15" }
cap-primitives = { path = "../cap-primitives", version = "^1.0.15" }
io-lifetimes = { version = "1.0.0", default-features = false }
io-lifetimes = { version = "2.0.0", default-features = false }
# Enable "unstable" for `spawn_blocking`.
#async-std = { version = "1.10.0", features = ["attributes", "unstable"], optional = true }
#async-trait = { version = "0.1.42", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion cap-net-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ edition = "2018"
[dependencies]
cap-std = { path = "../cap-std", version = "^1.0.15" }
cap-primitives = { path = "../cap-primitives", version = "^1.0.15" }
rustix = { version = "0.37.9", features = ["net"] }
rustix = { version = "0.38.0", features = ["net"] }
smallvec = "1.10"
2 changes: 1 addition & 1 deletion cap-net-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ fn socket(
address_family.into(),
socket_type,
socket_flags(blocking),
rustix::net::Protocol::default(),
None,
)?;

// Set the desired flags if we couldn't set them at creation.
Expand Down
10 changes: 5 additions & 5 deletions cap-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ ambient-authority = "0.0.2"
arbitrary = { version = "1.0.0", optional = true, features = ["derive"] }
ipnet = "2.3.0"
maybe-owned = "0.3.4"
fs-set-times = "0.19.0"
io-extras = "0.17.0"
io-lifetimes = { version = "1.0.0", default-features = false }
fs-set-times = "0.20.0"
io-extras = "0.18.0"
io-lifetimes = { version = "2.0.0", default-features = false }

[dev-dependencies]
cap-tempfile = { path = "../cap-tempfile" }

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.37.9", features = ["fs", "process", "procfs", "termios", "time"] }
rustix = { version = "0.38.0", features = ["fs", "process", "procfs", "termios", "time"] }

[target.'cfg(windows)'.dependencies]
winx = "0.35.0"
winx = "0.36.0"

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.48.0"
Expand Down
4 changes: 2 additions & 2 deletions cap-primitives/src/rustix/fs/open_unchecked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::compute_oflags;
use crate::fs::{stat_unchecked, OpenOptions, OpenUncheckedError};
use crate::AmbientAuthority;
use io_lifetimes::AsFilelike;
use rustix::fs::{cwd, openat, Mode};
use rustix::fs::{openat, Mode, CWD};
use rustix::io;
use std::fs;
use std::path::Path;
Expand Down Expand Up @@ -67,5 +67,5 @@ pub(crate) fn open_ambient_impl(
ambient_authority: AmbientAuthority,
) -> Result<fs::File, OpenUncheckedError> {
let _ = ambient_authority;
open_unchecked(&cwd().as_filelike_view::<fs::File>(), path, options)
open_unchecked(&CWD.as_filelike_view::<fs::File>(), path, options)
}
4 changes: 2 additions & 2 deletions cap-primitives/src/rustix/fs/reopen_impl.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::fs::{open_unchecked, OpenOptions};
use crate::rustix::fs::file_path;
use io_lifetimes::AsFilelike;
use rustix::fs::cwd;
use rustix::fs::CWD;
use std::{fs, io};

/// Implementation of `reopen`.
pub(crate) fn reopen_impl(file: &fs::File, options: &OpenOptions) -> io::Result<fs::File> {
if let Some(path) = file_path(file) {
Ok(open_unchecked(
&cwd().as_filelike_view::<fs::File>(),
&CWD.as_filelike_view::<fs::File>(),
&path,
options,
)?)
Expand Down
2 changes: 1 addition & 1 deletion cap-primitives/src/rustix/fs/stat_unchecked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(crate) fn stat_unchecked(
// the current working directory returns a similar error,
// then stop using `statx`.
if let Err(rustix::io::Errno::PERM) = statx(
rustix::fs::cwd(),
rustix::fs::CWD,
"",
AtFlags::EMPTY_PATH,
StatxFlags::empty(),
Expand Down
11 changes: 8 additions & 3 deletions cap-primitives/src/rustix/linux/fs/procfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::fs::{
errors, open, read_link_unchecked, set_times_follow_unchecked, OpenOptions, SystemTimeSpec,
};
use io_lifetimes::{AsFd, AsFilelike};
use rustix::fs::{chmodat, Mode, OFlags, RawMode};
use rustix::io::proc_self_fd;
use rustix::fs::{chmodat, AtFlags, Mode, OFlags, RawMode};
use rustix::path::DecInt;
use rustix::procfs::proc_self_fd;
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
use std::path::{Path, PathBuf};
use std::{fs, io};
Expand Down Expand Up @@ -46,7 +46,12 @@ pub(crate) fn set_permissions_through_proc_self_fd(

let dirfd = proc_self_fd()?;
let mode = Mode::from_bits(perm.mode() as RawMode).ok_or_else(errors::invalid_flags)?;
Ok(chmodat(dirfd, DecInt::from_fd(&opath), mode)?)
Ok(chmodat(
dirfd,
DecInt::from_fd(&opath),
mode,
AtFlags::empty(),
)?)
}

pub(crate) fn set_times_through_proc_self_fd(
Expand Down
6 changes: 3 additions & 3 deletions cap-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ rustdoc-args = ["--cfg=doc_cfg"]
[dependencies]
arf-strings = { version = "0.7.0", optional = true }
cap-primitives = { path = "../cap-primitives", version = "^1.0.15" }
io-extras = "0.17.0"
io-lifetimes = { version = "1.0.0", default-features = false }
io-extras = "0.18.0"
io-lifetimes = { version = "2.0.0", default-features = false }
camino = { version = "1.0.5", optional = true }

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.37.9", features = ["fs"] }
rustix = { version = "0.38.0", features = ["fs"] }

[features]
default = []
Expand Down
2 changes: 1 addition & 1 deletion cap-tempfile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ camino = { version = "1.0.5", optional = true }
rand = "0.8.1"

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.37.9", features = ["procfs"] }
rustix = { version = "0.38.0", features = ["procfs"] }

[target.'cfg(windows)'.dev-dependencies.windows-sys]
version = "0.48.0"
Expand Down
2 changes: 1 addition & 1 deletion cap-tempfile/src/tempfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn new_tempfile_linux(d: &Dir, anonymous: bool) -> io::Result<Option<File>> {
fn generate_name_in(subdir: &Dir, f: &File) -> io::Result<String> {
use rustix::fd::AsFd;
use rustix::fs::AtFlags;
let procself_fd = rustix::io::proc_self_fd()?;
let procself_fd = rustix::procfs::proc_self_fd()?;
let fdnum = rustix::path::DecInt::from_fd(f.as_fd());
let fdnum = fdnum.as_c_str();
super::retry_with_name_ignoring(io::ErrorKind::AlreadyExists, |name| {
Expand Down
2 changes: 1 addition & 1 deletion cap-time-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ cap-primitives = { path = "../cap-primitives", version = "^1.0.15" }
cap-std = { path = "../cap-std", optional = true, version = "^1.0.15" }

[target.'cfg(not(windows))'.dependencies]
rustix = { version = "0.37.9", features = ["time"] }
rustix = { version = "0.38.0", features = ["time"] }

[target.'cfg(windows)'.dependencies]
once_cell = "1.5.2"
Expand Down
2 changes: 1 addition & 1 deletion fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cap-primitives = { path = "../cap-primitives", features = ["arbitrary"] }
# Depend on io-lifetimes with default features, as the fuzzing framework
# seems to add a dependency on `io_lifetimes::OwnedFd::drop` even when the
# code itself doesn't have one.
io-lifetimes = "1.0.0"
io-lifetimes = "2.0.0"

[[bin]]
name = "cap-primitives"
Expand Down
10 changes: 6 additions & 4 deletions tests/dir-ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ fn remove_symlink_to_dir() {
}

let tempdir = TempDir::new(ambient_authority()).expect("create tempdir");
let target = tempdir.create_dir("target").expect("create target dir");
drop(target);
{
let _target = tempdir.create_dir("target").expect("create target dir");
}
tempdir.symlink("target", "link").expect("create symlink");
assert!(tempdir.exists("link"), "link exists");
tempdir
Expand All @@ -53,8 +54,9 @@ fn remove_symlink_to_dir() {
#[test]
fn do_not_remove_dir() {
let tempdir = TempDir::new(ambient_authority()).expect("create tempdir");
let subdir = tempdir.create_dir("subdir").expect("create dir");
drop(subdir);
{
let _subdir = tempdir.create_dir("subdir").expect("create dir");
}
assert!(tempdir.exists("subdir"), "subdir created");
tempdir
.remove_file_or_symlink("subdir")
Expand Down

0 comments on commit 3e86e37

Please sign in to comment.