@@ -22,12 +22,7 @@ use core::{cell::UnsafeCell, marker, mem, ptr};
22
22
use macros:: vtable;
23
23
24
24
/// Flags associated with a [`File`].
25
- ///
26
- /// It is tagged with `non_exhaustive` to prevent users from instantiating it.
27
- #[ non_exhaustive]
28
- pub struct FileFlags ;
29
-
30
- impl FileFlags {
25
+ pub mod flags {
31
26
/// File is opened in append mode.
32
27
pub const O_APPEND : u32 = bindings:: O_APPEND ;
33
28
@@ -46,7 +41,7 @@ impl FileFlags {
46
41
/// File must be a directory.
47
42
pub const O_DIRECTORY : u32 = bindings:: O_DIRECTORY ;
48
43
49
- /// Like `Self:: O_SYNC` except metadata is not synced.
44
+ /// Like [` O_SYNC`] except metadata is not synced.
50
45
pub const O_DSYNC : u32 = bindings:: O_DSYNC ;
51
46
52
47
/// Ensure that this file is created with the `open(2)` call.
@@ -69,7 +64,7 @@ impl FileFlags {
69
64
70
65
/// Also known as `O_NDELAY`.
71
66
///
72
- /// This is effectively the same flag as [`Self:: O_NONBLOCK`] on all architectures
67
+ /// This is effectively the same flag as [`O_NONBLOCK`] on all architectures
73
68
/// except SPARC64.
74
69
pub const O_NDELAY : u32 = bindings:: O_NDELAY ;
75
70
@@ -90,10 +85,10 @@ impl FileFlags {
90
85
/// # Examples
91
86
///
92
87
/// ```
93
- /// use kernel::file::FileFlags ;
88
+ /// use kernel::file;
94
89
/// # fn do_something() {}
95
90
/// # let flags = 0;
96
- /// if (flags & FileFlags:: O_ACCMODE) == FileFlags ::O_RDONLY {
91
+ /// if (flags & file::flags:: O_ACCMODE) == file::flags ::O_RDONLY {
97
92
/// do_something();
98
93
/// }
99
94
/// ```
@@ -163,7 +158,7 @@ impl File {
163
158
164
159
/// Returns the flags associated with the file.
165
160
///
166
- /// The flags are a combination of the constants in [`FileFlags `].
161
+ /// The flags are a combination of the constants in [`flags `].
167
162
pub fn flags ( & self ) -> u32 {
168
163
// SAFETY: The file is valid because the shared reference guarantees a nonzero refcount.
169
164
unsafe { core:: ptr:: addr_of!( ( * self . 0 . get( ) ) . f_flags) . read ( ) }
0 commit comments