Flesh out tool/zsh/mkofs

It now prevents double-mounting.

Also adds vim filetype modelines.
This commit is contained in:
Jōshin 2024-01-08 05:18:18 +00:00
parent 16099801cc
commit cafea9a0a5
No known key found for this signature in database
3 changed files with 26 additions and 1 deletions

View file

@ -1 +1,24 @@
sudo mount -t tmpfs -o size=10G,noatime,nodiratime /dev/shm ${COSMO:-$PWD}/o
[[ -f /proc/mounts ]] || {
echo "mkofs: only supported on linux" >&2
return 1
}
local o
if [[ -d "$PWD/o" ]]; then
o=$PWD/o
elif [[ -n "$COSMO" && -d "$COSMO/o" ]]; then
o=$COSMO/o
else
echo "mkofs: o/ not found" >&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
return 0
fi
done
( set -x
sudo mount -t tmpfs -o size=10G,noatime,nodiratime /dev/shm "$o"
)
# vim:ft=zsh

View file

@ -42,3 +42,4 @@ local make=${MAKE:-${COSMOCC:-/opt/cosmocc/current}/bin/make}
[[ -x $make ]] || make=${COSMO:-$PWD}/build/bootstrap/make.com
( set -x
exec $make $j $flags MODE=$mode $targs )
# vim:ft=zsh

View file

@ -16,3 +16,4 @@ nproc() {
echo 2
}
nproc
# vim:ft=zsh