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 67 68 69 70 71 72 73
|
#!/bin/bash
#
# reiserfs probing script
# Copyright (C) 2001, 2002, 2003 by Hans Reiser, licencing governed by
# reiser4progs/COPYING.
reiserx_probe() {
dev=$1
for block_off in 16 2; do
super_off=$(expr $block_off \* 4096)
magic_off=$(expr $super_off + 52)
magic=$(dd if=$dev bs=1 count=10 skip=$magic_off 2> /dev/null)
[ ! $? -eq 0 ] && {
echo "Can't read $1. Probably permissions denied."
return 1
}
magic=$(echo $magic | strings)
if [ ! $? -eq 0 ]; then
echo "Couldn't open device $dev"
return 0
fi
test x$magic = xReIsErFs && {
echo "reiser 3.5"
return 0
}
test x$magic = xReIsEr2Fs && {
echo "reiser 3.6 (standard journal)"
return 0
}
test x$magic = xReIsEr3Fs && {
echo "reiser 3.6 (relocated journal)"
return 0
}
magic=$(dd if=$dev bs=1 count=10 skip=$super_off 2> /dev/null)
magic=$(echo $magic | strings)
test x$magic = xReIsEr4 && {
echo "reiser 4.0"
return 0
}
done
}
[ -z $1 ] && {
echo "Usage: $0 FILE"
exit 1
}
if [ ! -b $1 -a ! -r $1 ]; then
echo "Specified device isn't a block device and not a file"
exit 1
fi
if [ ! -x /bin/dd ]; then
echo "Can't find \"dd\" program"
exit 1
fi
reiserx_probe $1
exit 0
|