From: Trevor Gross <tmgross@umich.edu>
To: Ariel Miculas <amiculas@cisco.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, tycho@tycho.pizza,
brauner@kernel.org, viro@zeniv.linux.org.uk, ojeda@kernel.org,
alex.gaynor@gmail.com, wedsonaf@gmail.com
Subject: Re: [RFC PATCH v2 10/10] rust: puzzlefs: add oci_root_dir and image_manifest filesystem parameters
Date: Wed, 26 Jul 2023 17:08:40 -0400 [thread overview]
Message-ID: <CALNs47ss3kV3mTx4ksYTWaHWdRG48=97DTi3OEnPom2nFcYhHw@mail.gmail.com> (raw)
In-Reply-To: <20230726164535.230515-11-amiculas@cisco.com>
On Wed, Jul 26, 2023 at 12:55 PM Ariel Miculas <amiculas@cisco.com> wrote:
>
> These parameters are passed when mounting puzzlefs using '-o' option of
> mount:
> -o oci_root_dir="/path/to/oci/dir"
> -o image_manifest="root_hash_of_image_manifest"
>
> For a particular manifest in the manifests array in index.json (located
> in the oci_root_dir), the root hash of the image manifest is found in
> the digest field.
>
> It would be nicer if we could pass the tag, but we don't support json
> deserialization.
>
> Example of mount:
> mount -t puzzlefs -o oci_root_dir="/home/puzzlefs_oci" -o \
> image_manifest="2d6602d678140540dc7e96de652a76a8b16e8aca190bae141297bcffdcae901b" \
> none /mnt
>
> Signed-off-by: Ariel Miculas <amiculas@cisco.com>
> ---
> samples/rust/puzzlefs.rs | 63 ++++++++++++++++++++++++++--------------
> 1 file changed, 41 insertions(+), 22 deletions(-)
>
> diff --git a/samples/rust/puzzlefs.rs b/samples/rust/puzzlefs.rs
> index dad7ecc76eca..4e9a8aedf0c1 100644
> --- a/samples/rust/puzzlefs.rs
> +++ b/samples/rust/puzzlefs.rs
> @@ -7,6 +7,7 @@
> use kernel::{
> c_str, file, fs,
> io_buffer::IoBufferWriter,
> + str::CString,
> sync::{Arc, ArcBorrow},
> };
>
> @@ -31,27 +32,29 @@ struct PuzzlefsInfo {
> puzzlefs: Arc<PuzzleFS>,
> }
>
> +#[derive(Default)]
> +struct PuzzleFsParams {
> + oci_root_dir: Option<CString>,
> + image_manifest: Option<CString>,
> +}
> +
> #[vtable]
> impl fs::Context<Self> for PuzzleFsModule {
> - type Data = ();
> -
> - kernel::define_fs_params! {(),
> - {flag, "flag", |_, v| { pr_info!("flag passed-in: {v}\n"); Ok(()) } },
> - {flag_no, "flagno", |_, v| { pr_info!("flagno passed-in: {v}\n"); Ok(()) } },
> - {bool, "bool", |_, v| { pr_info!("bool passed-in: {v}\n"); Ok(()) } },
> - {u32, "u32", |_, v| { pr_info!("u32 passed-in: {v}\n"); Ok(()) } },
> - {u32oct, "u32oct", |_, v| { pr_info!("u32oct passed-in: {v}\n"); Ok(()) } },
> - {u32hex, "u32hex", |_, v| { pr_info!("u32hex passed-in: {v}\n"); Ok(()) } },
> - {s32, "s32", |_, v| { pr_info!("s32 passed-in: {v}\n"); Ok(()) } },
> - {u64, "u64", |_, v| { pr_info!("u64 passed-in: {v}\n"); Ok(()) } },
> - {string, "string", |_, v| { pr_info!("string passed-in: {v}\n"); Ok(()) } },
> - {enum, "enum", [("first", 10), ("second", 20)], |_, v| {
> - pr_info!("enum passed-in: {v}\n"); Ok(()) }
> - },
> + type Data = Box<PuzzleFsParams>;
> +
> + kernel::define_fs_params! {Box<PuzzleFsParams>,
> + {string, "oci_root_dir", |s, v| {
> + s.oci_root_dir = Some(CString::try_from_fmt(format_args!("{v}"))?);
> + Ok(())
> + }},
> + {string, "image_manifest", |s, v| {
> + s.image_manifest = Some(CString::try_from_fmt(format_args!("{v}"))?);
> + Ok(())
> + }},
> }
>
> - fn try_new() -> Result {
> - Ok(())
> + fn try_new() -> Result<Self::Data> {
> + Ok(Box::try_new(PuzzleFsParams::default())?)
> }
> }
>
> @@ -136,11 +139,27 @@ impl fs::Type for PuzzleFsModule {
> const FLAGS: i32 = fs::flags::USERNS_MOUNT;
> const DCACHE_BASED: bool = true;
>
> - fn fill_super(_data: (), sb: fs::NewSuperBlock<'_, Self>) -> Result<&fs::SuperBlock<Self>> {
> - let puzzlefs = PuzzleFS::open(
> - c_str!("/home/puzzlefs_oci"),
> - c_str!("2d6602d678140540dc7e96de652a76a8b16e8aca190bae141297bcffdcae901b"),
> - );
> + fn fill_super(
> + data: Box<PuzzleFsParams>,
> + sb: fs::NewSuperBlock<'_, Self>,
> + ) -> Result<&fs::SuperBlock<Self>> {
> + let oci_root_dir = match data.oci_root_dir {
> + Some(val) => val,
> + None => {
> + pr_err!("missing oci_root_dir parameter!\n");
> + return Err(ENOTSUPP);
> + }
> + };
> +
> + let image_manifest = match data.image_manifest {
> + Some(val) => val,
> + None => {
> + pr_err!("missing image_manifest parameter!\n");
> + return Err(ENOTSUPP);
> + }
> + };
> +
The guard syntax (available since 1.65) can make these kinds of match statements
cleaner:
let Some(oci_root_dir) = data.oci_root_dir else {
pr_err!("missing oci_root_dir parameter!\n");
return Err(ENOTSUPP);
}
let Some(image_manifest) ...
> + let puzzlefs = PuzzleFS::open(&oci_root_dir, &image_manifest);
>
> if let Err(ref e) = puzzlefs {
> pr_info!("error opening puzzlefs {e}\n");
> --
> 2.41.0
>
>
next prev parent reply other threads:[~2023-07-26 21:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 16:45 [RFC PATCH v2 00/10] Rust PuzleFS filesystem driver Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 01/10] samples: puzzlefs: add initial puzzlefs sample, copied from rust_fs.rs Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 02/10] kernel: configs: enable rust samples in rust.config Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 03/10] rust: kernel: add an abstraction over vfsmount to allow cloning a new private mount Ariel Miculas
2023-07-26 22:34 ` Trevor Gross
2023-07-27 13:10 ` Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 04/10] rust: file: Add a new RegularFile newtype useful for reading files Ariel Miculas
2023-07-26 23:52 ` Trevor Gross
2023-07-27 13:18 ` Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 05/10] samples: puzzlefs: add basic deserializing support for the puzzlefs metadata Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 06/10] rust: file: pass the filesystem context to the open function Ariel Miculas
2023-07-27 13:32 ` Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 07/10] samples: puzzlefs: populate the directory entries with the inodes from the puzzlefs metadata file Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 08/10] rust: puzzlefs: read the puzzlefs image manifest instead of an individual metadata layer Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 09/10] rust: puzzlefs: add support for reading files Ariel Miculas
2023-07-26 16:45 ` [RFC PATCH v2 10/10] rust: puzzlefs: add oci_root_dir and image_manifest filesystem parameters Ariel Miculas
2023-07-26 21:08 ` Trevor Gross [this message]
2023-07-26 23:47 ` Wedson Almeida Filho
2023-07-27 0:02 ` Trevor Gross
2023-07-27 8:06 ` Wedson Almeida Filho
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='CALNs47ss3kV3mTx4ksYTWaHWdRG48=97DTi3OEnPom2nFcYhHw@mail.gmail.com' \
--to=tmgross@umich.edu \
--cc=alex.gaynor@gmail.com \
--cc=amiculas@cisco.com \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tycho@tycho.pizza \
--cc=viro@zeniv.linux.org.uk \
--cc=wedsonaf@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).