diff mbox series

[RFC,18/19] rust: fs: export file type from mode constants

Message ID 20231018122518.128049-19-wedsonaf@gmail.com (mailing list archive)
State New, archived
Headers show
Series Rust abstractions for VFS | expand

Commit Message

Wedson Almeida Filho Oct. 18, 2023, 12:25 p.m. UTC
From: Wedson Almeida Filho <walmeida@microsoft.com>

Allow Rust file system modules to use these constants if needed.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
---
 rust/kernel/fs.rs | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/rust/kernel/fs.rs b/rust/kernel/fs.rs
index b07203758674..235a86ed1127 100644
--- a/rust/kernel/fs.rs
+++ b/rust/kernel/fs.rs
@@ -20,6 +20,33 @@ 
 #[cfg(CONFIG_BUFFER_HEAD)]
 pub mod buffer;
 
+/// Contains constants related to Linux file modes.
+pub mod mode {
+    /// A bitmask used to the file type from a mode value.
+    pub const S_IFMT: u32 = bindings::S_IFMT;
+
+    /// File type constant for block devices.
+    pub const S_IFBLK: u32 = bindings::S_IFBLK;
+
+    /// File type constant for char devices.
+    pub const S_IFCHR: u32 = bindings::S_IFCHR;
+
+    /// File type constant for directories.
+    pub const S_IFDIR: u32 = bindings::S_IFDIR;
+
+    /// File type constant for pipes.
+    pub const S_IFIFO: u32 = bindings::S_IFIFO;
+
+    /// File type constant for symbolic links.
+    pub const S_IFLNK: u32 = bindings::S_IFLNK;
+
+    /// File type constant for regular files.
+    pub const S_IFREG: u32 = bindings::S_IFREG;
+
+    /// File type constant for sockets.
+    pub const S_IFSOCK: u32 = bindings::S_IFSOCK;
+}
+
 /// Maximum size of an inode.
 pub const MAX_LFS_FILESIZE: i64 = bindings::MAX_LFS_FILESIZE;