Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gitbls committed Jan 8, 2024
1 parent d73e830 commit 067cc0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion sdm-cmdsubs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function sdm_burndevfile() {
setdiskid $burndev $newdiskid
sync ; sleep 1 ; sync
declare -x SDMPT=$(makemtpt)
mountburn $burndev
domount "$burndev" "Device"
else
#
# Burning to a file
Expand Down
33 changes: 13 additions & 20 deletions sdm-cparse
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ function isactive() {
return $sts
}

function getfilegroup() {
#
# $1: /path/to/file
#
# Returns the string for the group owning the file
#
local tfile="$1" gx
gx=$(stat -c '%G' $tfile)
[ "$gx" == "" ] && gx=users
echo $gx
}

function getgbstr() {
#
# $1: # of bytes in partition
Expand Down Expand Up @@ -1357,15 +1369,14 @@ function domount() {
#
# $1: device name/IMG Name/directory name
# $2: "Directory" "IMG" or "Device"
# Tree will be mounted on $SDMPT which must be set with declare -x SDMPT=$(makemtpt)
# Tree will be mounted on $SDMPT which must be set with: declare -x SDMPT=$(makemtpt)
#
local dmimg=$1 imgtype=$2
local p1="1" p2="2" pinfo csize bootstart bootsize rootstart rootsize mdir

[ ! -d $SDMPT ] && mkdir $SDMPT
if [ "$imgtype" == "Directory" ]
then
#ismounted $(realpath $dmimg) && errexit "? Directory '$dmimg' is already mounted"
ismounted $(realpath $dmimg) && echo "% Directory '$dmimg' is mounted; Continuing..."
mount --bind $dmimg $SDMPT
notmounted $SDMPT && errexit "? Error mounting --bind '$dmimg'"
Expand Down Expand Up @@ -1412,24 +1423,6 @@ function domount() {
fi
}

function mountburn() {
local burndev="$1" p1="1" p2="2"
[[ "$burndev" =~ "mmcblk" ]] && p1="p1" && p2="p2"
[ "$SDMPT" == "" ] && declare -x SDMPT=$(makemtpt)
mount -v ${burndev}${p2} $SDMPT
if [ -d $SDMPT/boot/firmware ]
then
mount -v ${burndev}${p1} $SDMPT/boot/firmware
else
mount -v ${burndev}${p1} $SDMPT/boot
fi
! ismounted ${burndev}${p2} && errexit "? Unable to mount ${burndev}${p2}"
}

function umountburn() {
docleanup keep
}

function docleanup() {
#
# $1: if 'keep' (don't unset SDMPT)
Expand Down

0 comments on commit 067cc0e

Please sign in to comment.