moth/sh4pwn/skeleton/sbin/mkrw

18 lines
361 B
Plaintext
Raw Normal View History

2011-10-11 15:38:34 -06:00
#! /bin/sh -e
if ! [ -d "$1" ]; then
echo "usage: $0 DIRECTORY"
echo
echo "Makes DIRECTORY a read/write tmpfs mount with the same"
echo "contents."
exit 1
fi
fsname=$(basename $1)
mkdir /tmp/$fsname
mount -t tmpfs $fsname /tmp/$fsname
(cd $1 && tar cf - .) | (cd /tmp/$fsname && tar xf -)
mount -o move /tmp/$fsname $1
rmdir /tmp/$fsname