local fstype
local inode
- echo "$device: ext2-4 filesystem detected" 1>&2
+ echo "# $device: ext2-4 filesystem detected" 1>&2
- fstype="`file -s $device | sed -e 's/.*\(ext[0-9]\).*/\1/'`"
+ fstype="`file -bkrs $device | sed -ne 's/.*\(ext[0-9]\).*/\1/' -eT -ep`"
echo "fstype $fstype"
# Step 6: Get filesystem blocksize and convert sector number to filesystem block number
# Step 8: Find inode, to which the block belongs
- inode="`echo "icheck $fsblock" | debugfs $device 2>/dev/null | awk 'FNR>1{print $2}'`" #`"
+ inode="`echo "icheck $fsblock" | debugfs $device 2>/dev/null | awk '/^[0-9]+[ \t]+[0-9]+$/{print $2}'`" #`"
if [ -z "$inode" ]; then
echo "blocktype meta?"
namefound="$(\
echo "ncheck $inode" \
| debugfs $device 2>/dev/null \
- | sed -e '1d' -e 's/^[0-9]*[ ]*//' -e 's/^\/\//\//' \
+ | sed -n -e 's/^[0-9]\+[ \t]\+//' -eT -e 's/^\/\//\//' -ep \
| while read name; do \
if [ -z "$firstname" ]; then \
echo "blocktype data" 1>&3; \