1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

Merge pull request #2330 from miDeb/cp/close-fd

cp: close file descriptors after cow on linux
This commit is contained in:
Sylvestre Ledru 2021-06-03 07:54:34 +02:00 committed by GitHub
commit 5de623cfab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 64 additions and 9 deletions

View file

@ -1,4 +1,4 @@
// spell-checker:ignore (flags) reflink (fs) tmpfs
// spell-checker:ignore (flags) reflink (fs) tmpfs (linux) rlimit Rlim NOFILE
use crate::common::util::*;
#[cfg(not(windows))]
@ -14,6 +14,8 @@ use std::os::windows::fs::symlink_file;
#[cfg(target_os = "linux")]
use filetime::FileTime;
#[cfg(target_os = "linux")]
use rlimit::Resource;
#[cfg(not(windows))]
use std::env;
#[cfg(target_os = "linux")]
@ -1276,3 +1278,15 @@ fn test_cp_reflink_insufficient_permission() {
.fails()
.stderr_only("cp: 'unreadable' -> 'existing_file.txt': Permission denied (os error 13)");
}
#[cfg(target_os = "linux")]
#[test]
fn test_closes_file_descriptors() {
new_ucmd!()
.arg("-r")
.arg("--reflink=auto")
.arg("dir_with_10_files/")
.arg("dir_with_10_files_new/")
.with_limit(Resource::NOFILE, 9, 9)
.succeeds();
}