3 which tune2fs >/dev/null 2>&1 && tune2fs -l $device >/dev/null 2>&1
19 echo "$device: ext2-4 filesystem detected" 1>&2
21 fstype="`file -s $device | sed -e 's/.*\(ext[0-9]\).*/\1/'`"
24 # Step 6: Get filesystem blocksize and convert sector number to filesystem block number
26 fsblocksize="`tune2fs -l $device | awk '/Block size/{print $3/512}'`"
28 if [ -z "$fsblocksize" ]; then
29 echo "! $device is not ext2/ext3" 1>&2
33 fsblock="`dc -e "$sector $fsblocksize ~ n [ ] n p"`" #`"
34 fssubsector="${fsblock% *}"
35 fsblock="${fsblock#* }"
37 echo "blocksize $fsblocksize"
39 echo "subsector $fssubsector"
41 # Step 7: Check, whether block is in use
43 if echo "testb $fsblock" | debugfs $device 2>/dev/null | grep -qF "not in use"; then
44 echo "blockstate free"
47 echo "blockstate used"
49 # Step 8: Find inode, to which the block belongs
51 inode="`echo "icheck $fsblock" | debugfs $device 2>/dev/null | awk 'FNR>1{print $2}'`" #`"
53 if [ -z "$inode" ]; then
54 echo "blocktype meta?"
60 # Step 9: Find file name(s) referencing the inode
64 echo "ncheck $inode" \
65 | debugfs $device 2>/dev/null \
66 | sed -e '1d' -e 's/^[0-9]*[ ]*//' -e 's/^\/\//\//' \
67 | while read name; do \
68 if [ -z "$firstname" ]; then \
69 echo "blocktype data" 1>&3; \
73 echo "name $name" 1>&3; \
76 if [ -z "$namefound" ]; then
77 echo "blocktype journal?"
84 register_scanner "extfs"