Implement F_DUPFD_CLOEXEC
This commit is contained in:
Generated
+2
-2
@@ -208,8 +208,8 @@ checksum = "64072665120942deff5fd5425d6c1811b854f4939e7f1c01ce755f64432bbea7"
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.17"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/syscall.git?branch=master#aedadf4d5cb915e0c6a22a5c7358fa853354e21d"
|
||||
version = "0.5.18"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/syscall.git?branch=master#2d346f1d610a358d74cd40360cf7e5dcfc2120d7"
|
||||
dependencies = [
|
||||
"bitflags 2.9.4",
|
||||
]
|
||||
|
||||
@@ -111,6 +111,7 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
|
||||
F_SETFD => "F_SETFD",
|
||||
F_SETFL => "F_SETFL",
|
||||
F_GETFL => "F_GETFL",
|
||||
F_DUPFD_CLOEXEC => "F_DUPFD_CLOEXEC",
|
||||
_ => "UNKNOWN",
|
||||
},
|
||||
c,
|
||||
|
||||
+7
-6
@@ -265,6 +265,7 @@ pub fn close(fd: FileHandle, token: &mut CleanLockToken) -> Result<()> {
|
||||
fn duplicate_file(
|
||||
fd: FileHandle,
|
||||
user_buf: UserSliceRo,
|
||||
cloexec: bool,
|
||||
token: &mut CleanLockToken,
|
||||
) -> Result<FileDescriptor> {
|
||||
let (caller_ctx, file) = {
|
||||
@@ -279,7 +280,7 @@ fn duplicate_file(
|
||||
if user_buf.is_empty() {
|
||||
Ok(FileDescriptor {
|
||||
description: Arc::clone(&file.description),
|
||||
cloexec: false,
|
||||
cloexec,
|
||||
})
|
||||
} else {
|
||||
let description = { *file.description.read() };
|
||||
@@ -306,14 +307,14 @@ fn duplicate_file(
|
||||
|
||||
Ok(FileDescriptor {
|
||||
description: new_description,
|
||||
cloexec: false,
|
||||
cloexec,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Duplicate file descriptor
|
||||
pub fn dup(fd: FileHandle, buf: UserSliceRo, token: &mut CleanLockToken) -> Result<FileHandle> {
|
||||
let new_file = duplicate_file(fd, buf, token)?;
|
||||
let new_file = duplicate_file(fd, buf, false, token)?;
|
||||
|
||||
context::current()
|
||||
.read(token.token())
|
||||
@@ -332,7 +333,7 @@ pub fn dup2(
|
||||
Ok(new_fd)
|
||||
} else {
|
||||
let _ = close(new_fd, token);
|
||||
let new_file = duplicate_file(fd, buf, token)?;
|
||||
let new_file = duplicate_file(fd, buf, false, token)?;
|
||||
|
||||
let context_ref = context::current();
|
||||
let context = context_ref.read(token.token());
|
||||
@@ -526,9 +527,9 @@ pub fn fcntl(fd: FileHandle, cmd: usize, arg: usize, token: &mut CleanLockToken)
|
||||
|
||||
let description = file.description.read();
|
||||
|
||||
if cmd == F_DUPFD {
|
||||
if cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC {
|
||||
// Not in match because 'files' cannot be locked
|
||||
let new_file = duplicate_file(fd, UserSlice::empty(), token)?;
|
||||
let new_file = duplicate_file(fd, UserSlice::empty(), cmd == F_DUPFD_CLOEXEC, token)?;
|
||||
|
||||
let context_lock = context::current();
|
||||
let context = context_lock.read(token.token());
|
||||
|
||||
Reference in New Issue
Block a user