Command disabled: backlink

Check files for holes

It's quite hard to tell if a file under Linux has holes (eg. it is a sparse file). This script tries to determine this by comparing apparent and real file sizes.

#!/bin/sh
 
where=${1:-.}
 
find "$where" -type f | while read file; do
 
#    apparentsize=`du --apparent-size "$file" | cut -f 1`
#    realsize=`du "$file" | cut -f 1`
 
    blocks=`stat -c "%b" "$file"`
    blocksize=`stat -c "%B" "$file"`
    realsize=$(($blocks * $blocksize))
    apparentsize=`stat -c "%s" "$file"`
 
    diff=$(($apparentsize < $realsize))
 
    if [ $diff -eq 0 ]; then
        echo [has holes?] $file [real:${realsize} apparent:${apparentsize}]
        hole='found'
    fi
 
done
 
if [ -z $hole ]; then
 
    echo "no hole candidates found"
 
fi

Linkbacks

Use the following URL for manually sending trackbacks: http://rigo.info/lib/plugins/linkback/exe/trackback.php/en:blog:check_files_for_holes
en/blog/check_files_for_holes.txt · Utolsó módosítás: 2009-04-14 00:00 (külső szerkesztés)
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0