Skip to content

Commit a786000

Browse files
committed
Merges fcntl module into fd module
1 parent 1f75719 commit a786000

File tree

4 files changed

+24
-27
lines changed

4 files changed

+24
-27
lines changed

kernel-1100/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use self::thread::Thread;
1010
use self::ucred::Ucred;
1111
use self::uio::Uio;
1212
use core::ffi::{c_char, c_int};
13-
use okf::fcntl::OpenFlags;
13+
use okf::fd::OpenFlags;
1414
use okf::malloc::MallocFlags;
1515
use okf::queue::TailQueue;
1616
use okf::socket::SockAddr;

src/fcntl/mod.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/fd/mod.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use crate::errno::Errno;
2-
use crate::fcntl::OpenFlags;
32
use crate::pcpu::Pcpu;
43
use crate::thread::Thread;
54
use crate::uio::{IoVec, Uio, UioRw, UioSeg};
65
use crate::Kernel;
6+
use bitflags::bitflags;
77
use core::ffi::{c_char, c_int};
88
use core::marker::PhantomData;
99

10+
pub const AT_FDCWD: c_int = -100;
11+
1012
/// # Safety
1113
/// `path` cannot be null and must point to a null-terminated string if `seg` is [`UioSeg::Kernel`].
1214
pub unsafe fn openat<K: Kernel>(
@@ -57,6 +59,25 @@ pub unsafe fn write<K: Kernel>(
5759
}
5860
}
5961

62+
bitflags! {
63+
/// Flags for `open` and related functions.
64+
#[repr(transparent)]
65+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
66+
pub struct OpenFlags: c_int {
67+
const O_RDONLY = 0x00000000;
68+
const O_WRONLY = 0x00000001;
69+
const O_RDWR = 0x00000002;
70+
const O_ACCMODE = Self::O_WRONLY.bits() | Self::O_RDWR.bits();
71+
const O_SHLOCK = 0x00000010;
72+
const O_EXLOCK = 0x00000020;
73+
const O_CREAT = 0x00000200;
74+
const O_TRUNC = 0x00000400;
75+
const O_EXCL = 0x00000800;
76+
const O_EXEC = 0x00040000;
77+
const O_CLOEXEC = 0x00100000;
78+
}
79+
}
80+
6081
/// RAII struct to call [`Kernel::kern_close()`] when dropped.
6182
pub struct OwnedFd<K: Kernel> {
6283
kern: K,

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![no_std]
22

3-
use self::fcntl::OpenFlags;
3+
use self::fd::OpenFlags;
44
use self::file::File;
55
use self::lock::{LockObject, Mtx};
66
use self::malloc::{Malloc, MallocFlags};
@@ -17,7 +17,6 @@ use core::ops::Deref;
1717
pub use okf_macros::*;
1818

1919
pub mod errno;
20-
pub mod fcntl;
2120
pub mod fd;
2221
pub mod file;
2322
pub mod lock;

0 commit comments

Comments
 (0)