diff options
author | Miles Bader <miles@gnu.org> | 1995-04-04 17:24:25 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1995-04-04 17:24:25 +0000 |
commit | e462c241597b4ab78412ac6369fe360ead4af24e (patch) | |
tree | 0dc17ce7e3bc1190763d590d4119c1f00d23a7a6 | |
parent | 08c37e57274177500fd1bb3131bc0461dbac7d01 (diff) |
Initial revision
-rwxr-xr-x | utils/mount.sh | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/utils/mount.sh b/utils/mount.sh new file mode 100755 index 00000000..667b0481 --- /dev/null +++ b/utils/mount.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# +# A simple version of mount for the hurd +# + +USAGE="Usage: $0: [ -rnvf | -o DEVOPTS | -t TYPE ] ( DEVICE NODE | DEVICE | NODE )" + +PATH=/bin + +default_type=ufs +type=- +fstab=/etc/fstab +exec=true +echo=false + +while :; do + case $1 in + -v) echo=true; margs="$margs -v"; shift;; + -n) exec=false; margs="$margs -n"; shift;; + -r) targs="$targs -r"; shift;; + -t) case "$type" in + -|$2) type=$2; shift 2; margs="$margs -t $type";; + *) echo 1>&2 $0: filesystem type specified multiple times + exit 7;; + esac;; + -f) fstab=$2; shift 2;; + -o) targs="$targs $2"; shift 2;; + -*) echo 1>&2 $0: $1: unknown flag; echo 1>&2 "$USAGE"; exit 1;; + *) break;; + esac +done + +case "$targs" in ?*) + # We embed quotes so that spaces are preserved in targs later on + margs="$margs -o \"$targs\"" +esac + +if [ X"$type" != X"-" && ! -x /hurd/$type ]; then + echo 1>&2 $0: $type: unknown filesystem type + exit 1 +fi + +case $# in + 1) + # Lookup the given single arg in /etc/fstab for the rest of the args + args=`gawk -f - $fstab <<END +\\$1 == "$1" || \\$2 == "$1" { + for (i = 4; i <= NF; i++) + printf("%s ", \\$i); + printf("-t %s %s %s", \\$3, \\$1, \\$2); + exit(0); +} +END +` + case "$args" in + "") echo 1>&2 $0: $1: not found in $fstab; exit 3;; + *) eval $0 $margs $args;; + esac + ;; + + 2) + # Do the mount, by putting an active translator on the node + case "$type" in -) type=$default_type;; esac + $echo && echo settrans -a $2 -- /hurd/$type $targs $1 + $exec && settrans -a $2 -- /hurd/$type $targs $1 + ;; + + *) + echo 1>&2 "$USAGE"; exit 1 + ;; +esac |