forked from nccgroup/TriforceLinuxSyscallFuzzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeRoot
executable file
·38 lines (34 loc) · 880 Bytes
/
makeRoot
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
#!/bin/sh
#
# usage: ./makeRoot name cmd args..
#
# Make an init ramdisk image for the root filesystem based off
# of files in rootTemplate/. Copy in a driver if its not already
# in the template, and arrange for init to execute it.
#
# silently overwrites existing files.
#
if [ $# -lt 2 ] ; then
echo usage: $0 name driver
exit 1
fi
templ=rootTemplate
name="$1"
driver="$2"
shift; shift
args="$@"
# copy main root template and patch it
rm -rf "$name"
cp -r "$templ" "$name"
#cp heater "$name/bin/heater"
baseDriver="`basename $driver`"
if [ ! -f "$name/bin/$baseDriver" ] ; then
cp "$driver" "$name/bin/$baseDriver"
fi
sed "s#DRIVER#/bin/$baseDriver $args#" < "$name/init" > "$name/init.x" && mv "$name/init.x" "$name/init"
chmod 755 "$name/init"
# pack it up
cd "$name"
find . -print0 \
| cpio --null -ov --format=newc \
| gzip -9 > "../$name.cpio.gz"