From 3ed4ca0e99510052066133272b3f254b129d014e Mon Sep 17 00:00:00 2001
From: Kenneth R Hancock <krhancoc@uwaterloo.ca>
Date: Sat, 15 Jan 2022 11:00:40 -0700
Subject: [PATCH] Quality of life changes, silence errors, clean_kernel command
 etc

---
 README.md                  | 14 ++++++++++----
 os161-container/helpers.sh | 14 +++++++++++++-
 run.sh                     |  1 +
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index ba7075d..fde0341 100644
--- a/README.md
+++ b/README.md
@@ -47,11 +47,20 @@ assignment number. You can run these commands from the shell container. These fu
 # build_kernel ASST0
 # test_kernel ASST0
 ```
+If you would like to run the kernel normally (no scripts), once built, you can run the kernel
+```
+# cd /os-compile
+# sys161 kernel
+```
+
 You can evaluate your assignment based on public test cases. There will  be hidden test cases that are not avaiable in this repository.
 ```
 # /evalaute /logs/test_public.log /assignments/ASST0
 ```
 
+There also exists a `clean_kernel ASST#` command which will try and clean up old builds, this may be necessary if running into issues. If this 
+fails that is okay (means there was no build to begin with), just run `build_kernel ASST#` as normal.
+
 ## Running GDB
 * Make sure you have built the kernel using `build_kernel ASST0`.
 * To run GDB, open a terminal with the cs350-container running, and enter the following commands:
@@ -85,10 +94,7 @@ be given to the scripts used to run and evaluate userspace code.
 
 When mounting other directories that are not os161 note that the `build_kernel` and `test_kernel` functionality will not work.
 
-## Running, building and testing userspace code
-* 
-
-## Layout
+## [Layout](Layout)
 There are some noted directories within the container
 * `/kernel` holds YOUR assignment code
 * `/os161-1.99` holds unchanged os161 kernel code
diff --git a/os161-container/helpers.sh b/os161-container/helpers.sh
index a5174c7..2bf6f9e 100755
--- a/os161-container/helpers.sh
+++ b/os161-container/helpers.sh
@@ -8,9 +8,21 @@ unpack_kernel() {
 	tar -xf /assignment.tgz -C /kernel --strip-components 1
 }
 
+_clean_kernel_h() {
+    set -e
+    cd /os161-1.99/kern/compile/$1
+    bmake clean
+    cd -
+}
+
+clean_kernel() {
+    _clean_kernel_h $1 &
+    wait
+}
+
 build_k_helper() {
 	cd $OS161_DIR
-	mkdir /os-compile
+	mkdir /os-compile 2> /dev/null
 	cp -r /kernel/kern/* $OS161_DIR/kern/
 	set -e
 	# Configure - step 1
diff --git a/run.sh b/run.sh
index 6960cce..3c0a23a 100755
--- a/run.sh
+++ b/run.sh
@@ -13,6 +13,7 @@ fi
 
 
 mkdir -p logs
+chmod a+rwx logs
 
 KERNFILE=$1
 docker run -it --rm \
-- 
GitLab