Skip to content

Commit 4f082c4

Browse files
authored
Merge pull request torvalds#603 from danobi/file_flags
rust: file: Add flags() method to `File`
2 parents 8ca7a7f + 53df040 commit 4f082c4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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)