Skip to content

Commit 6007bbc

Browse files
authored
Merge pull request #310 from cakebaker/bump_nix
Bump nix & adapt to its API changes
2 parents 1c78319 + 184b2c8 commit 6007bbc

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

Cargo.lock

Lines changed: 22 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ libc = "0.2.171"
5555
libmount-sys = "0.1.1"
5656
linux-raw-sys = { version = "0.9.0", features = ["ioctl"] }
5757
md-5 = "0.10.6"
58-
nix = { version = "0.29", default-features = false }
58+
nix = { version = "0.30", default-features = false }
5959
phf = "0.11.2"
6060
phf_codegen = "0.11.2"
6161
rand = { version = "0.9.0", features = ["small_rng"] }

src/uu/mesg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ path = "src/main.rs"
1212

1313
[dependencies]
1414
clap = { workspace = true }
15-
nix = { workspace = true }
15+
nix = { workspace = true, features = ["fs"] }
1616
uucore = { workspace = true }

src/uu/mesg/src/mesg.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use clap::{builder::PossibleValuesParser, crate_version, Arg, ArgAction, ArgMatches, Command};
77
#[cfg(target_family = "unix")]
8-
use uucore::error::{set_exit_code, UIoError};
8+
use uucore::error::{set_exit_code, UIoError, USimpleError};
99
use uucore::{error::UResult, format_usage, help_about, help_usage};
1010

1111
const ABOUT: &str = help_about!("mesg.md");
@@ -14,7 +14,7 @@ const USAGE: &str = help_usage!("mesg.md");
1414
#[cfg(target_family = "unix")]
1515
pub fn do_mesg(matches: &ArgMatches) -> UResult<()> {
1616
use nix::sys::stat::{fchmod, fstat, Mode};
17-
use std::{io, os::fd::AsRawFd};
17+
use std::io;
1818
use std::{io::IsTerminal, os::fd::AsFd};
1919

2020
for fd in &[
@@ -23,7 +23,7 @@ pub fn do_mesg(matches: &ArgMatches) -> UResult<()> {
2323
std::io::stderr().as_fd(),
2424
] {
2525
if fd.is_terminal() {
26-
let st = fstat(fd.as_raw_fd())?;
26+
let st = fstat(fd.as_fd()).map_err(|e| USimpleError::new(1, e.desc()))?;
2727
if let Some(enable) = matches.get_one::<String>("enable") {
2828
// 'mesg y' on the GNU version seems to only modify the group write bit,
2929
// but 'mesg n' modifies both group and others write bits.
@@ -32,7 +32,8 @@ pub fn do_mesg(matches: &ArgMatches) -> UResult<()> {
3232
} else {
3333
st.st_mode & !0o022
3434
};
35-
fchmod(fd.as_raw_fd(), Mode::from_bits_retain(new_mode))?;
35+
fchmod(fd.as_fd(), Mode::from_bits_retain(new_mode))
36+
.map_err(|e| USimpleError::new(1, e.desc()))?;
3637
if enable == "n" {
3738
set_exit_code(1);
3839
}

0 commit comments

Comments
 (0)