On 05/01/11 17:27, Daniel Berger wrote: > > > On Jan 5, 10:04 am, Ryan Davis<ryand-r... / zenspider.com> 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") => #<File::Stat dev=0xfc0c, ino=160, mode=0100644, nlink=1, uid=1006, gid=1006, rdev=0x0, size=104857600, blksize=4096, blocks=0, atime=Wed Jan 05 18:02:08 +0000 2011, mtime=Wed Jan 05 18:02:08 +0000 2011, ctime=Wed Jan 05 18:02:08 +0000 2011> 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