mkofs improvements

- Always use $PWD/o. if it doesn't exist, say how to create it.

- return 2 on unsupported platforms.
This commit is contained in:
Jōshin 2024-01-08 17:23:09 +00:00
parent b580080af1
commit 6cb0354e19
No known key found for this signature in database

View file

@ -1,17 +1,16 @@
[[ -f /proc/mounts ]] || {
echo "mkofs: only supported on linux" >&2
return 1
return 2
}
local o
if [[ -d "$PWD/o" ]]; then
o=$PWD/o
elif [[ -n "$COSMO" && -d "$COSMO/o" ]]; then
o=$COSMO/o
if [[ -d o ]]; then
o=$(pwd -P)/o
else
echo "mkofs: o/ not found" >&2
echo "suggested preparation:" >&2
echo " mkdir -m 555 o" >&2
return 1
fi
o=$(realpath "$o")
cut -d' ' -f2 /proc/mounts | while read -r line; do
if [[ "$o" = "$line" ]]; then
echo "mkofs: $o already mounted" >&2