Skip to content

Commit

Permalink
rust: file: Add flags() method to File
Browse files Browse the repository at this point in the history
It's useful to know the flags associated with a file.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
  • Loading branch information
danobi committed Jan 2, 2022
1 parent 8ca7a7f commit 53df040
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rust/kernel/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ impl File {
// change over the lifetime of a file).
unsafe { CredentialRef::from_ptr(ptr) }
}

/// Returns the flags associated with the file.
pub fn flags(&self) -> u32 {
// SAFETY: `File::ptr` is guaranteed to be valid by the type invariants.
unsafe { (*self.ptr).f_flags }
}
}

impl Drop for File {
Expand Down

0 comments on commit 53df040

Please sign in to comment.