Skip to content

Commit 53df040

Browse files
committed
rust: file: Add flags() method to File
It's useful to know the flags associated with a file. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
1 parent 8ca7a7f commit 53df040

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

rust/kernel/file.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ impl File {
5454
// change over the lifetime of a file).
5555
unsafe { CredentialRef::from_ptr(ptr) }
5656
}
57+
58+
/// Returns the flags associated with the file.
59+
pub fn flags(&self) -> u32 {
60+
// SAFETY: `File::ptr` is guaranteed to be valid by the type invariants.
61+
unsafe { (*self.ptr).f_flags }
62+
}
5763
}
5864

5965
impl Drop for File {

0 commit comments

Comments
 (0)