1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

fix: address test failures

This commit is contained in:
Orhun Parmaksız 2022-11-04 13:35:54 +03:00
parent f2f2f7033e
commit be49eb68f3
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 11 additions and 4 deletions

View file

@ -11,6 +11,8 @@ extern crate libc;
use clap::{crate_version, Arg, ArgAction, Command}; use clap::{crate_version, Arg, ArgAction, Command};
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use nix::errno::Errno;
#[cfg(any(target_os = "linux", target_os = "android"))]
use nix::fcntl::{open, OFlag}; use nix::fcntl::{open, OFlag};
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use nix::sys::stat::Mode; use nix::sys::stat::Mode;
@ -170,9 +172,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// Use the Nix open to be able to set the NONBLOCK flags for fifo files // Use the Nix open to be able to set the NONBLOCK flags for fifo files
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
{ {
open(Path::new(&f), OFlag::O_NONBLOCK, Mode::empty()) let path = Path::new(&f);
.map_err_context(|| format!("cannot stat {}", f.quote()))?; if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) {
if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) {
return e.map_err_context(|| format!("cannot stat {}", f.quote()))?;
}
}
} }
#[cfg(not(any(target_os = "linux", target_os = "android")))] #[cfg(not(any(target_os = "linux", target_os = "android")))]
{ {
if !Path::new(&f).exists() { if !Path::new(&f).exists() {

View file

@ -64,9 +64,9 @@ fn test_sync_no_permission_dir() {
ts.ccmd("chmod").arg("0").arg(dir).succeeds(); ts.ccmd("chmod").arg("0").arg(dir).succeeds();
let result = ts.ucmd().arg("--data").arg(dir).fails(); let result = ts.ucmd().arg("--data").arg(dir).fails();
result.stderr_contains("sync: error opening 'foo': Permission denied"); result.stderr_contains("sync: cannot stat 'foo': Permission denied");
let result = ts.ucmd().arg(dir).fails(); let result = ts.ucmd().arg(dir).fails();
result.stderr_contains("sync: error opening 'foo': Permission denied"); result.stderr_contains("sync: cannot stat 'foo': Permission denied");
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]