From: Matthew Bloch Date: 2011-01-06T03:07:45+09:00 Subject: Re: Getting the actual size of a sparse file On 05/01/11 17:27, Daniel Berger wrote: > > > On Jan 5, 10:04 am, Ryan Davis wrote: >> On Jan 5, 2011, at 08:37 , Daniel Berger wrote: >> >>> Hi, >> >>> How do you get the true size of a sparse file? Using /var/log/lastlog >>> on Ubuntu as an example I see this with "ls -lh" >> >> If you're on ubuntu you should be able to provide extra options to du: >> >> http://en.wikipedia.org/wiki/Sparse_file > > True, but I'd like to use pure Ruby (not system calls) if possible, at > least for *nix systems. Or will this require an extension? dd if=/dev/zero bs=1 seek=100M count=0 of=out2 irb(main):011:0> stat=File.stat("out2") => # irb(main):013:0> [stat.blocks*stat.blksize, stat.size] => [0, 104857600] Gives you allocated size & filesystem size. -- Matthew Bloch Bytemark Hosting http://www.bytemark.co.uk/ tel: +44 (0) 1904 890890