bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug#294206: stat(1) unclear about block size


From: James Youngman
Subject: Re: Bug#294206: stat(1) unclear about block size
Date: Wed, 9 Feb 2005 08:52:35 +0000
User-agent: Mutt/1.3.28i

On Tue, Feb 08, 2005 at 11:37:54PM +0100, Jeroen van Wolffelaar wrote:

> If you're going to offer %S to retrieve fundamental blocksize, I think
> it'd be best to actually really retrieve that value, and do something
> smart otherwise (error out, noting in the documentation that %S might
> not always be available?), unless of course it is for a given system
> actually known that f_bsize is indeed the unit size for free/total
> blocks.

findutils calls this "ST_NBLOCKSIZE" and does it this way: -

/* Extract or fake data from a `struct stat'.
   ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
   ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
   ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS.  */
#ifndef HAVE_STRUCT_STAT_ST_BLOCKS
/* ... */
# if defined(hpux) || defined(__hpux__) || defined(__hpux)
/* HP-UX counts st_blocks in 1024-byte units.
   This loses when mixing HP-UX and BSD filesystems with NFS.  */
#  define ST_NBLOCKSIZE 1024
# else /* !hpux */
#  if defined(_AIX) && defined(_I386)
/* AIX PS/2 counts st_blocks in 4K units.  */
#   define ST_NBLOCKSIZE (4 * 1024)
# endif /* !hpux */
#endif

#ifndef ST_NBLOCKSIZE
# define ST_NBLOCKSIZE 512
#endif

(The actual code is a bit more complex, as it also defines a macro
ST_BLKSIZE and defines a more complex value for ST_NBLOCKS on Crays
(i.e. UNICOS)).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]