. $OBDDIR/demos/config.sh
[ "$LOOPDEV" ] && losetup -d $LOOPDEV
-[ "$TMPFILE" ] && rm $TMPFILE
+#[ "$TMPFILE" ] && rm $TMPFILE
exit 2
fi
+# Ensure that we have the correct devices for OBD to work
+[ ! -c /dev/obd0 ] && mknod /dev/obd0 c $OBDMAJ 0
+[ ! -c /dev/obd1 ] && mknod /dev/obd1 c $OBDMAJ 1
+[ ! -c /dev/obd2 ] && mknod /dev/obd2 c $OBDMAJ 2
+
[ "$TMPFILE" ] && dd if=/dev/zero of=$TMPFILE bs=1k count=10k
[ "$LOOPDEV" ] && losetup $LOOPDEV $TMPFILE
# destructive).
#set -vx
+# Major number for OBD devices
+OBDMAJ=186
+
# If LOOPDEV is empty (""), then no loopback device will be configured.
# If TMPFILE is empty (""), then no temporary file will be created for loop.
TMPFILE="/tmp/obdfs.tmpfile"
# kernel code has a lot of debugging statements, so this helps us keep
# track of what is going on in user-land to generate the kernel messages.
plog () {
- LOGMETH="kern.debug"
if [ "$1" = "log" ]; then
- logger -p $LOGMETH "******** $* **********"
shift
+ echo "******** $* **********" >> /var/log/messages
echo "$*"
else
- logger -p $LOGMETH "****start**** $* *****"
+ echo "****start**** $* *****" >> /var/log/messages
echo "$*"
$*
- sleep 3
- logger -p $LOGMETH "*****end***** $* *****"
+ sleep 3 # to allow messages to be flushed
+ echo "*****end***** $* *****" >> /var/log/messages
fi
}
. $OBDDIR/demos/config.sh
[ ! -d $MNTSNAP/lost+found ] && echo "need to run obdsetup.sh first" && exit 1
+[ ! -f $MNTOBD/hosts ] && $OBDDIR/demos/snaptest.sh
+
plog umount $MNTSNAP
plog umount $MNTOBD
sync
sleep 1
-rm $SNAPTABLE
plog log "STARTING snaprestore"
+# To do a snapshot restore at this time, we need to do several steps. In
+# the future, this should all be wrapped into the snaprestore function.
+# - we reverse the current and restored entries in the snapshot table
+# - we proceed to delete the previous current snapshot
+# - we unconfigure the previous current snapshot
+# - we delete the previous current snapshot from the table and load it
$OBDDIR/class/obdcontrol -f << EOF
+XXX need to reverse current/restored entries here!!!
+snapset 0 $SNAPTABLE
+device /dev/obd2
+connect
+snaprestore 1
+device /dev/obd1
+cleanup
+detach
snaptable
$SNAPTABLE
-a
+d
1
-now
-a
-2
-current
q
y
snapset 0 $SNAPTABLE
-device /dev/obd2
-connect
-snaprestore 1
-disconnect
EOF
plog log "COMPLETE snaprestore"
plog chmod 777 $MNTOBD # change attributes on an existing file
plog rm $MNTOBD/a # delete an existing file
-plog echo "today" >> $MNTOBD/hello # modify an existing file
+echo "echo today >> $MNTOBD/hello" # modify an existing file
+echo today >> $MNTOBD/hello
plog cp /etc/group $MNTOBD # create a new file
plog ln -s goodbye $MNTOBD/newlink # create a new symlink