in reply to Re: Usage of a sparse file
in thread Usage of a sparse file

By the way, block size is usually 512 (at least man 2 stat says so about the st_blocks field of the struct stat).
Sorry if my advice was wrong.

Replies are listed 'Best First'.
Re^3: Usage of a sparse file
by mishikal (Novice) on Mar 11, 2013 at 16:17 UTC
    Hi, as I noted in my original post,the information retrieved from stat is not usable, as it returns the blocks used by the full size of the sparse file, not actual usage size

    Thanks though!

      Isn't blocks*blocksize = (stat $file)[11]*512 the actual used size?
      $ ls -lh sparse_file -rw-r--r-- 1 aitap aitap 101M Mar 11 20:30 sparse_file $ du -h sparse_file 1,1M sparse_file $ du -B 1 sparse_file 1060864 sparse_file $ perl -E'say ((stat shift)[12]*512)' sparse_file 1060864
      Sorry if my advice was wrong.
        Hm, that works. I can grab the blocksize as well, and divide by 8 to get down to 512. Thanks!