From 121705eb1cacad315fa1e11cae794bf07e487e5f Mon Sep 17 00:00:00 2001 From: Wedson Almeida Filho Date: Fri, 29 Sep 2023 17:58:13 -0300 Subject: [PATCH] rust: fs: export file type from mode constants This allows file systems modules to use these constants if needed. Signed-off-by: Wedson Almeida Filho --- rust/kernel/fs.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/rust/kernel/fs.rs b/rust/kernel/fs.rs index a0aa783d6b3445..4e261996e39446 100644 --- a/rust/kernel/fs.rs +++ b/rust/kernel/fs.rs @@ -11,6 +11,33 @@ pub mod buffer; /// Maximum size of an inode. pub const MAX_LFS_FILESIZE: i64 = bindings::MAX_LFS_FILESIZE; +/// 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; +} + /// Read-only file systems. pub mod ro { use crate::error::{code::*, from_result, to_result, Error, Result};