Skip to content

Commit

Permalink
Adds flags for open function
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Jul 21, 2024
1 parent 7717418 commit b16508c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
3 changes: 2 additions & 1 deletion kernel-1100/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use self::thread::Thread;
use self::ucred::Ucred;
use self::uio::Uio;
use core::ffi::{c_char, c_int};
use okf::fcntl::OpenFlags;
use okf::malloc::MallocFlags;
use okf::queue::TailQueue;
use okf::socket::SockAddr;
Expand Down Expand Up @@ -74,7 +75,7 @@ impl okf::Kernel for Kernel {
fd: c_int,
path: *const c_char,
seg: UioSeg,
flags: c_int,
flags: OpenFlags,
mode: c_int,
) -> c_int;

Expand Down
20 changes: 20 additions & 0 deletions src/fcntl/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
use bitflags::bitflags;
use core::ffi::c_int;

pub const AT_FDCWD: c_int = -100;

bitflags! {
/// Flags for `open` and related functions.
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct OpenFlags: c_int {
const O_RDONLY = 0x00000000;
const O_WRONLY = 0x00000001;
const O_RDWR = 0x00000002;
const O_ACCMODE = Self::O_WRONLY.bits() | Self::O_RDWR.bits();
const O_SHLOCK = 0x00000010;
const O_EXLOCK = 0x00000020;
const O_CREAT = 0x00000200;
const O_TRUNC = 0x00000400;
const O_EXCL = 0x00000800;
const O_EXEC = 0x00040000;
const O_CLOEXEC = 0x00100000;
}
}
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![no_std]

use self::fcntl::OpenFlags;
use self::file::File;
use self::lock::{LockObject, Mtx};
use self::malloc::{Malloc, MallocFlags};
Expand Down Expand Up @@ -98,7 +99,7 @@ pub trait Kernel: MappedKernel {
fd: c_int,
path: *const c_char,
seg: UioSeg,
flags: c_int,
flags: OpenFlags,
mode: c_int,
) -> c_int;

Expand Down

0 comments on commit b16508c

Please sign in to comment.