From 9e91e4f05bef556b2271f852a08bcad88b0d522a Mon Sep 17 00:00:00 2001 From: Luka Vandervelden Date: Sun, 29 Nov 2020 00:23:28 +0100 Subject: [PATCH] mount and unmount commands added. --- src/main.cr | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.cr b/src/main.cr index 2d152b4..c25282b 100644 --- a/src/main.cr +++ b/src/main.cr @@ -60,6 +60,12 @@ class RootFS::Context "restore" => ->(args : Array(String)){ RootFS.load(args[0]).restore(args[1]) }, + "mount" => ->(args : Array(String)){ + RootFS.load(args[0]).mount(args[1]?) + }, + "unmount" => ->(args : Array(String)){ + RootFS.load(args[0]).unmount(args[1]?) + }, # FIXME: This needs access to the list of commands. "help" => ->(args : Array(String)){ STDOUT << options_parser << "\n" @@ -168,13 +174,23 @@ class RootFS::RootFS end def mount(directory = nil) - show! - puts "UNIMPLEMENTED: binding file systems here" + if directory + execute "mount --bind '#{directory}' '#{@directory}/#{directory}'" + return + end + + mount "/proc" + mount "/sys" end def unmount(directory = nil) - show! - puts "UNIMPLEMENTED: unbinding file systems here" + if directory + execute "umount '#{@directory}/#{directory}'" + return + end + + unmount "/proc" + unmount "/sys" end def show!