Skip to content

Commit 184b2c8

Browse files
committed
mesg: adapt to API changes in nix
1 parent da8cede commit 184b2c8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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)