-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support F_GETFL and F_SETFL for fcntl #4212
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rustbot ready
@@ -22,7 +22,7 @@ const MAX_SOCKETPAIR_BUFFER_CAPACITY: usize = 212992; | |||
|
|||
/// One end of a pair of connected unnamed sockets. | |||
#[derive(Debug)] | |||
struct AnonSocket { | |||
pub struct AnonSocket { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for
// We only support F_GETFL for socketpair and pipe.
let anonsocket_fd = fd.downcast::<AnonSocket>().ok_or_else(|| {
err_unsup_format!("fcntl: only socketpair / pipe are supported for F_SETFL")
})?;
let [flag] = check_min_vararg_count(cmd_name, varargs)?; | ||
let flag = this.read_scalar(flag)?.to_i32()?; | ||
|
||
// FIXME: File access mode and file creation flags should be ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the man page:
F_SETFL (int)
Set the file status flags to the value specified by arg.
File access mode (O_RDONLY, O_WRONLY, O_RDWR) and file
creation flags (i.e., O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC)
in arg are ignored.
There are quite a few file access mode and file creation flags, would prefer to open an issue for this and do it later.
This PR supports
F_SETFL
andF_GETFL
flags forfcntl
. In this implementation,F_SETFL
can only setO_NONBLOCK
flag.The interaction between these
fcntl
operations and blocking fd is summarised here.Fixes #4119