|
1 | 1 | use crate::errno::Errno;
|
2 |
| -use crate::fcntl::OpenFlags; |
3 | 2 | use crate::pcpu::Pcpu;
|
4 | 3 | use crate::thread::Thread;
|
5 | 4 | use crate::uio::{IoVec, Uio, UioRw, UioSeg};
|
6 | 5 | use crate::Kernel;
|
| 6 | +use bitflags::bitflags; |
7 | 7 | use core::ffi::{c_char, c_int};
|
8 | 8 | use core::marker::PhantomData;
|
9 | 9 |
|
| 10 | +pub const AT_FDCWD: c_int = -100; |
| 11 | + |
10 | 12 | /// # Safety
|
11 | 13 | /// `path` cannot be null and must point to a null-terminated string if `seg` is [`UioSeg::Kernel`].
|
12 | 14 | pub unsafe fn openat<K: Kernel>(
|
@@ -57,6 +59,25 @@ pub unsafe fn write<K: Kernel>(
|
57 | 59 | }
|
58 | 60 | }
|
59 | 61 |
|
| 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 | + |
60 | 81 | /// RAII struct to call [`Kernel::kern_close()`] when dropped.
|
61 | 82 | pub struct OwnedFd<K: Kernel> {
|
62 | 83 | kern: K,
|
|
0 commit comments