From 10646959fadb3a130811fa2f30599eb98950440d Mon Sep 17 00:00:00 2001
From: TheOddGarlic <umutinanerdogan@pm.me>
Date: Sat, 26 Mar 2022 14:26:17 +0300
Subject: [PATCH] Add repbuild subcommands `mount` & `unmount`

These repbuild subcommands mount the filesystem root to the
userland/root_fs/mnt folder, and this makes editing the initial file
system easier.

This also renames userland/root_rs to userland/root_fs.
---
 .gitignore                             |   2 ++
 ableos/src/filesystem/mod.rs           |   2 +-
 repbuild/src/main.rs                   |  20 ++++++++++++++++++++
 userland/{root_rs => root_fs}/ext2.img | Bin 4194304 -> 4194304 bytes
 4 files changed, 23 insertions(+), 1 deletion(-)
 rename userland/{root_rs => root_fs}/ext2.img (99%)

diff --git a/.gitignore b/.gitignore
index 5311cc6..7fe889b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,5 @@ shadeable/target
 qprofiler
 userland/*/target
 kernel/target
+userland/root_fs/mnt/*
+!*/.gitkeep
diff --git a/ableos/src/filesystem/mod.rs b/ableos/src/filesystem/mod.rs
index 9eceb51..00afa56 100644
--- a/ableos/src/filesystem/mod.rs
+++ b/ableos/src/filesystem/mod.rs
@@ -9,7 +9,7 @@ use ext2::{
 
 fn load_fs() -> Synced<Ext2<Size1024, Vec<u8>>> {
     let mut volume = Vec::new();
-    volume.extend_from_slice(include_bytes!("../../../userland/root_rs/ext2.img"));
+    volume.extend_from_slice(include_bytes!("../../../userland/root_fs/ext2.img"));
 
     let fs = Synced::<Ext2<Size1024, _>>::new(volume).unwrap();
 
diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs
index 25c1dd9..9dfd24b 100644
--- a/repbuild/src/main.rs
+++ b/repbuild/src/main.rs
@@ -16,6 +16,16 @@ enum Command {
         #[clap(long, short, arg_enum)]
         machine: Option<MachineType>,
     },
+
+    Mount {
+        #[clap(long, short)]
+        path: Option<String>,
+    },
+
+    Unmount {
+        #[clap(long, short)]
+        path: Option<String>,
+    },
 }
 
 #[derive(clap::ArgEnum, Debug, Clone)]
@@ -89,6 +99,16 @@ fn main() -> anyhow::Result<()> {
                 }
             }
         }
+
+        Command::Mount { path } => {
+            let path = path.unwrap_or("./userland/root_fs/mnt".to_string());
+            xshell::cmd!("sudo mount userland/root_fs/ext2.img {path}").run()?;
+        },
+
+        Command::Unmount { path } => {
+            let path = path.unwrap_or("./userland/root_fs/mnt".to_string());
+            xshell::cmd!("sudo umount {path}").run()?;
+        },
     }
 
     Ok(())
diff --git a/userland/root_rs/ext2.img b/userland/root_fs/ext2.img
similarity index 99%
rename from userland/root_rs/ext2.img
rename to userland/root_fs/ext2.img
index 15b29de6a0b60f15ff7284502beb3d7acb87c552..bd5aa42224651443e9046f8068fec0d11c7ab0fa 100644
GIT binary patch
delta 307
zcmWN=$!<YW0D$4#LAj0^t4a;6sb-36Y!68{miBii>0?N4B0=IcJV4dL%UF8?!`A;L
zpKaT!&A*CnEU$7lzR6i)Z|Xma`YU$IQvG+WC)(*O_nYb5tsSp&A*_|K6spvy)4>Ni
z>7qe51wDMEmp=L#V2~j`G0bO1_`)b-d}W*oCYj<J-<f8HS>~AM2Ma8+#4;<avc@_a
b{A80YwrR4%E_>{Az#+f*O?eR3=(4>7gtJ$S

delta 307
zcmWN=NlwC00D$3i09u~R2>4niDRX7g;!u$V8<*_6l6#OeAwd(a;Q_#!a56To{J-Q2
z!%z)*banH$B{#k!H&*27D@FYfCuOhx7+>#N&X&<(y-jL=mfVTpQv?cCYSbBHoCz8<
znWW$qQ%p0%EOX4Wz#^|%Vwn}*P|~8!Dr>B>!6t9nqQf>j?6Su`2OQGn9Y-8<!YOCG
Y=L0>?`N$_e^MyWNx!~Jb1k20!Kd%o{4*&oF