diff options
author | Roland McGrath <roland@gnu.org> | 1999-07-11 01:51:30 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1999-07-11 01:51:30 +0000 |
commit | 5ade8fea0d30e88931f0d64927afd4a5034e8cee (patch) | |
tree | 7113eeee2e6fc32f32e27455153c44e373e62d42 /sutils | |
parent | 85be2fcd4e1bf5018a5022df6c305cf05effb89c (diff) |
1999-07-10 Roland McGrath <roland@baalperazim.frob.com>
* Makefile (special-targets): Add losetup.
(SCRIPTS): Add losetup.sh.
* losetup.sh: New file.
Diffstat (limited to 'sutils')
-rw-r--r-- | sutils/Makefile | 12 | ||||
-rw-r--r-- | sutils/losetup.sh | 66 |
2 files changed, 72 insertions, 6 deletions
diff --git a/sutils/Makefile b/sutils/Makefile index 6542166c..dcb6604b 100644 --- a/sutils/Makefile +++ b/sutils/Makefile @@ -1,6 +1,6 @@ -# Makefile for sutils -# -# Copyright (C) 1996, 1997 Free Software Foundation +# Makefile for sutils +# +# Copyright (C) 1996,97,99 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -20,10 +20,10 @@ dir := sutils makemode := utilities -targets = reboot halt fsck e2os MAKEDEV swapon swapoff -special-targets = e2os MAKEDEV +targets = $(special-targets) reboot halt fsck swapon swapoff +special-targets = e2os MAKEDEV losetup installationdir = $(sbindir) -SCRIPTS = e2os.sh MAKEDEV.sh +SCRIPTS = e2os.sh MAKEDEV.sh losetup.sh SRCS = reboot.c halt.c fsck.c fstab.c clookup.c swapon.c swapoff.c $(SCRIPTS) LCLHDRS = fstab.h diff --git a/sutils/losetup.sh b/sutils/losetup.sh new file mode 100644 index 00000000..85734571 --- /dev/null +++ b/sutils/losetup.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# +# This script is roughly compatible with the Linux `losetup' utility. +# The Hurd's `storeio' translator provides the equivalent functionality +# (and a whole lot more), and of course works on any old file you want +# to translate, not just magical "/dev/loopN" device files. +# + +PATH=/bin + +usage() { + echo >&2 ... + exit 1 +} + +offset=0 +while [ $# -gt 0 ]; do + case "$arg" in + -d) + [ $# -eq 2 ] || usage + exec settrans -g -- "$2" /hurd/null + ;; + -e) + echo >&2 "$0: encryption not supported" + exit 3 + ;; + -o) + [ $# -gt 1 ] || usage + offset="$1" + shift + ;; + --) + shift + break + ;; + -*) + usage + ;; + *) + break + ;; + esac +done + +[ $# -eq 2 ] || usage +device="$1" +file="$2" + +# If the device name is "/dev/loopN", then create it if necessary. (?) +create= +case "$device" in +'/dev/loop[0-9]*') ;; # smarty pants +/dev/loop[0-9]*) create=--create ;; +esac + +type='-Tfile ' +if [ "$offset" != 0 ]; then + blksz=`storeinfo -B -- "$file"` + if [ $[ $offset % $blksz ] -ne 0 ]; then + echo >&2 "$0: offset $offset is not a multiple of device block size $blksz" + exit 1 + fi + type="-Tremap $[ $offset / $blksz ]+:file:" +fi + +exec settrans $create -gap -- "${device}" /hurd/storeio ${type}"${file}" |