Skip to content

Commit

Permalink
fix(fd): extract StatusFlags into separate type
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Mar 5, 2025
1 parent eaba655 commit fcbc2dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,20 @@ bitflags! {
const O_CREAT = 0o0100;
const O_EXCL = 0o0200;
const O_TRUNC = 0o1000;
const O_APPEND = 0o2000;
const O_NONBLOCK = 0o4000;
const O_DIRECT = 0o40000;
const O_DIRECTORY = 0o200_000;
}
}

bitflags! {
/// File status flags.
#[derive(Debug, Copy, Clone, Default)]
pub struct StatusFlags: i32 {
const O_APPEND = 0o2000;
const O_NONBLOCK = 0o4000;
}
}

bitflags! {
#[derive(Debug, Copy, Clone, Default)]
pub struct PollEvent: i16 {
Expand Down
4 changes: 2 additions & 2 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub use self::tasks::*;
pub use self::timer::*;
use crate::executor::block_on;
use crate::fd::{
AccessPermission, EventFlags, FileDescriptor, IoCtl, OpenOption, PollFd, dup_object,
self, AccessPermission, EventFlags, FileDescriptor, IoCtl, OpenOption, PollFd, dup_object,
dup_object2, get_object, isatty, remove_object,
};
use crate::fs::{self, FileAttr};
Expand Down Expand Up @@ -537,7 +537,7 @@ pub extern "C" fn sys_fcntl(fd: i32, cmd: i32, arg: i32) -> i32 {

if cmd == F_SETFD && arg == FD_CLOEXEC {
0
} else if cmd == F_SETFL && arg == OpenOption::O_NONBLOCK.bits() {
} else if cmd == F_SETFL && arg == fd::StatusFlags::O_NONBLOCK.bits() {
let obj = get_object(fd);
obj.map_or_else(
|e| -num::ToPrimitive::to_i32(&e).unwrap(),
Expand Down

0 comments on commit fcbc2dc

Please sign in to comment.