From: Gary Wright Date: 2011-01-07T06:11:30+09:00 Subject: Re: Getting the actual size of a sparse file On Jan 6, 2011, at 3:44 PM, Daniel Berger wrote: > > Oh, wow, I don't think I knew that. It's strikes me as particularly > bizarre that they would return some notion of a "preferred block size" > instead of the actual block size. Seriously, what's the use of that? > > Now I need to check other platforms (Solaris, HP-UX) to see if they > use 512 byte convention. > > Is this something that's universal? Or is it something I can get via a > C call somewhere? I think you'll want to read up on the stat() system call. The POSIX standard leaves a bit of wiggle room though since while it does specify that st_blocks must be returned it doesn't specify the size of the blocks. I'm not sure I understand your concern about 'actual' vs. 'preferred'. I'm guessing they would be the same in almost any rational implementation but the main reason for having the information is to perform I/O in efficiently sized chunks. In that case, the 'preferred' block size would seem to be what you want even if the 'actual' block size was different. Gary Wright