From: Daniel Sedlak <daniel@sedlak.dev>
To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
rust-for-linux@vger.kernel.org,
"Daniel Sedlak" <daniel@sedlak.dev>
Subject: [RFC PATCH 1/3] rust: kernel: types: add mode wrapper
Date: Sun, 8 Dec 2024 14:15:43 +0100 [thread overview]
Message-ID: <20241208131545.386897-2-daniel@sedlak.dev> (raw)
In-Reply-To: <20241208131545.386897-1-daniel@sedlak.dev>
Add rust variant for representing file mode. This is needed
in order to set file permissions.
Signed-off-by: Daniel Sedlak <daniel@sedlak.dev>
---
rust/kernel/types.rs | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs
index ec6457bb3084..35ac2898433a 100644
--- a/rust/kernel/types.rs
+++ b/rust/kernel/types.rs
@@ -517,3 +517,20 @@ pub enum Either<L, R> {
/// [`NotThreadSafe`]: type@NotThreadSafe
#[allow(non_upper_case_globals)]
pub const NotThreadSafe: NotThreadSafe = PhantomData;
+
+/// Mode represents file permissions.
+///
+/// TODO: add link to header files.
+pub struct Mode(bindings::umode_t);
+
+impl Mode {
+ /// Creates [`Mode`] from the number.
+ pub const fn from_u16(num: u16) -> Self {
+ Self(num)
+ }
+
+ /// Returns [`Mode`] as an number.
+ pub const fn as_u16(&self) -> u16 {
+ self.0
+ }
+}
--
2.47.1
next prev parent reply other threads:[~2024-12-08 13:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-08 13:15 [RFC PATCH 0/3] rust abstractions for interacting with sysfs Daniel Sedlak
2024-12-08 13:15 ` Daniel Sedlak [this message]
2024-12-09 7:21 ` [RFC PATCH 1/3] rust: kernel: types: add mode wrapper Alice Ryhl
2024-12-09 16:19 ` Daniel Sedlak
2024-12-08 13:15 ` [RFC PATCH 2/3] rust: kernel: kobject: basic sysfs implementation Daniel Sedlak
2024-12-08 13:43 ` Greg KH
2024-12-09 15:04 ` Daniel Sedlak
2024-12-08 13:56 ` Greg KH
2024-12-08 13:15 ` [RFC PATCH 3/3] samples: rust: add kobject sample Daniel Sedlak
2024-12-08 13:46 ` Greg KH
2024-12-09 15:17 ` Daniel Sedlak
2024-12-08 13:34 ` [RFC PATCH 0/3] rust abstractions for interacting with sysfs Greg KH
2024-12-09 16:12 ` Daniel Sedlak
2024-12-09 16:38 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241208131545.386897-2-daniel@sedlak.dev \
--to=daniel@sedlak.dev \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.