blob: 85734571c3a9f9ae75ced8bcf82723391e59bf59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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}"
|