OT: multi-platform *nix blocksize detection

Fairlight fairlite at fairlite.com
Tue Oct 19 20:15:37 PDT 2004


Decidedly OT, but we have some people with *nix expertise here...

Anyone know how to standardly detect the block size on a *nix filesystem,
independant of platform type?

I know, for instance, that linux ext2 uses 512-byte blocks...at least on
most systems with SCSI drives that I've seen.

However, I know FBSD has like a 4K or 8K block size, and Solaris has a 4K
block size on the system I just checked.

I need to do something conditionally based on the block size--alter some
calculations, actually.  

Anyone know of a standard way to find out automatically in -any- kind of
code?  I can extrapolate.  I thought of using stat on a file and checking
st_blksize, but that's actually the desired I/O block size it wants, not
how it really stores it--at least not in reality on this system I'm working
on at the moment.  It says 4096.  I guarantee these are 512-byte blocks.

Checking manually with fdisk isn't something I'd like to suggest to an
end-user, ya know? :)

mark->
-- 
Fairlight->   ||| It's the "...or something" that    | Fairlight Consulting
  __/\__      ||| worries me.  It's -always- the     |
 <__<>__>     ||| "...or something" that worries me! | http://www.fairlite.com
    \/        |||                                    | info at fairlite.com


More information about the Filepro-list mailing list