From 36aaa275a7a888a51d269072dabf338a4a6c7f4e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 16 Nov 2024 04:04:44 +0100 Subject: [PATCH] mo --- shell/mount.sh | 51 +++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/shell/mount.sh b/shell/mount.sh index cb7bb5a..118f8e9 100644 --- a/shell/mount.sh +++ b/shell/mount.sh @@ -1,26 +1,39 @@ mo() { local root="${1}" - local directory file - if [ -n "${root}" ]; then - root="$(realpath "${root}")" - file="${root}/filesystem.squashfs" - if mkdir "overlay"; then - cd "overlay" - for directory in "lower" "upper" "work" "mount"; do - mkdir "${directory}" - done - if mount "${file}" "lower"; then - mount \ - -o lowerdir="lower",upperdir="upper",workdir="work" \ - -t "overlay" \ - "overlay" "mount" - fi - cd .. - fi - else - log_fatal "No root" + if [ -z "${root}" ]; then + log_error "No root" return 1 fi + root="$(realpath "${root}")" + if ! mkdir "overlay"; then + log_error "Unable to make mount directory" + return 2 + fi + { + if ! cd "overlay"; then + log_error "Unable to move into mount directory" + return 3 + fi + local directory + for directory in "lower" "upper" "work" "mount"; do + if ! mkdir --parents "${directory}"; then + log_error "Unable to move into: ${directory}" + return 4 + fi + done + local file="${root}/filesystem.squashfs" + if ! mount "${file}" "lower"; then + log_error "Unable to mount: ${file}" + return 5 + fi + if ! mount \ + -o "lowerdir=lower,upperdir=upper,workdir=work" \ + -t "overlay" \ + "overlay" "mount"; then + log_error "Unable to mount: ${file}" + return 6 + fi + } } uo() {