[RFC PATCH v3 21/22] fs: puzzlefs: add oci_root_dir and image_manifest mount parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 fs/puzzlefs/puzzlefs.rs | 49 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 44 insertions(+), 5 deletions(-)

diff --git a/fs/puzzlefs/puzzlefs.rs b/fs/puzzlefs/puzzlefs.rs
index f4e94568c9cc..932f31917992 100644
--- a/fs/puzzlefs/puzzlefs.rs
+++ b/fs/puzzlefs/puzzlefs.rs
@@ -36,6 +36,32 @@ fn mode_to_fs_type(inode: &Inode) -> Result<DirEntryType> {
     })
 }
 
+#[derive(Default)]
+struct PuzzleFsParams {
+    oci_root_dir: Option<CString>,
+    image_manifest: Option<CString>,
+}
+
+#[vtable]
+impl fs::Context<Self> for PuzzleFsModule {
+    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<Self::Data> {
+        Ok(Box::new(PuzzleFsParams::default(), GFP_KERNEL)?)
+    }
+}
+
 const DIR_FOPS: file::Ops<PuzzleFsModule> = file::Ops::new::<PuzzleFsModule>();
 const DIR_IOPS: inode::Ops<PuzzleFsModule> = inode::Ops::new::<PuzzleFsModule>();
 const FILE_AOPS: address_space::Ops<PuzzleFsModule> = address_space::Ops::new::<PuzzleFsModule>();
@@ -98,24 +124,37 @@ fn iget(sb: &sb::SuperBlock<Self>, ino: u64) -> Result<ARef<INode<Self>>> {
 }
 
 impl fs::FileSystem for PuzzleFsModule {
+    type Context = Self;
     type Data = Box<PuzzleFS>;
     type INodeData = Inode;
     const NAME: &'static CStr = c_str!("puzzlefs");
 
     fn fill_super(
-        _data: (),
+        data: Box<PuzzleFsParams>,
         sb: &mut sb::SuperBlock<Self, sb::New>,
         _: Option<inode::Mapper>,
     ) -> Result<Box<PuzzleFS>> {
-        let puzzlefs = PuzzleFS::open(
-            c_str!("/home/puzzlefs_xattr"),
-            c_str!("ed63ace21eccceabab08d89afb75e94dae47973f82a17a172396a19ea953c8ab"),
-        );
+        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) = data.image_manifest else {
+            pr_err!("missing image_manifest parameter!\n");
+            return Err(ENOTSUPP);
+        };
+
+        let puzzlefs = PuzzleFS::open(&oci_root_dir, &image_manifest);
         if let Err(ref e) = puzzlefs {
             pr_info!("error opening puzzlefs {e}\n");
         }
 
+        pr_info!(
+            "opened puzzlefs [{}]:[{}]\n",
+            &*oci_root_dir,
+            &*image_manifest
+        );
+
         let puzzlefs = puzzlefs?;
         sb.set_magic(0x7a7a7570);
         Ok(Box::new(puzzlefs, GFP_KERNEL)?)
-- 
2.34.1





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux