Last change
on this file was 95666, checked in by vboxsync, 2 years ago |
Devices/PC/ipxe: scm fixes and export to OSE, bugref:10254
|
-
Property svn:eol-style
set to
LF
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.1 KB
|
Line | |
---|
1 | #!/bin/sh
|
---|
2 |
|
---|
3 | set -e
|
---|
4 |
|
---|
5 | imgloop=
|
---|
6 | tmpfile=
|
---|
7 | tmploop=
|
---|
8 | dmname=
|
---|
9 | cowlink=
|
---|
10 |
|
---|
11 | function cleanup () {
|
---|
12 | set +e
|
---|
13 | [ -n "$cowlink" ] && rm $cowlink
|
---|
14 | [ -n "$dmname" ] && dmsetup remove $dmname
|
---|
15 | [ -n "$tmploop" ] && losetup -d $tmploop
|
---|
16 | [ -n "$tmpfile" ] && rm $tmpfile
|
---|
17 | [ -n "$imgloop" ] && losetup -d $imgloop
|
---|
18 | }
|
---|
19 |
|
---|
20 | trap cleanup EXIT
|
---|
21 |
|
---|
22 | imgfile=$1 ; shift
|
---|
23 | command=$1 ; shift
|
---|
24 | if [ -z "$imgfile" -o -z "$command" ] ; then
|
---|
25 | echo Syntax: $0 /path/to/image/file command [args..]
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | # Set up image loop device
|
---|
30 | x=`losetup -f` ; losetup -r $x $imgfile ; imgloop=$x
|
---|
31 |
|
---|
32 | # Create temporary file and set up temporary loop device
|
---|
33 | tmpfile=`mktemp $imgfile.XXXXXXXXXX`
|
---|
34 | truncate -r $imgfile $tmpfile
|
---|
35 | x=`losetup -f` ; losetup $x $tmpfile ; tmploop=$x
|
---|
36 |
|
---|
37 | # Create snapshot device
|
---|
38 | imgsize=`blockdev --getsz $imgloop`
|
---|
39 | x=`basename $imgfile` ; echo 0 $imgsize snapshot $imgloop $tmploop N 16 | \
|
---|
40 | dmsetup create $x ; dmname=$x
|
---|
41 | chown --reference=$imgfile /dev/mapper/$dmname
|
---|
42 | chmod --reference=$imgfile /dev/mapper/$dmname
|
---|
43 |
|
---|
44 | # Create symlink
|
---|
45 | x=$imgfile.cow ; ln -s /dev/mapper/$dmname $x ; cowlink=$x
|
---|
46 |
|
---|
47 | # Wait until killed
|
---|
48 | echo "Created $cowlink"
|
---|
49 | $command "$@" $cowlink
|
---|
Note:
See
TracBrowser
for help on using the repository browser.