This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Subject: Re: again How to get the block size of the disk
From: Steve Borho <steve@borho.myip.org>
Date: Thu, 4 Nov 1999 17:40:41 -0600
On Thu, Nov 04, 1999 at 09:55:39AM +0000, Thomas Ribbrock Design/DEG" wrote:
> On Wed, Nov 03, 1999 at 10:46:08AM -0700, Jiang XU wrote:
> > What I need is to get such information through the function call, not through
> > the command line. So that I can put it in my program. My Program needs that.
>
> I'm not 100% sure, but might "stat()" ("man stat" for details) be what
> you need?
> Under Solaris, there's also "getmntent()" and related functions, though
> I'm not sure whether they exist under Linux.
I had to do this for a dock app I wrote a couple years ago. The stat()
function call will return a structure with:
struct stat
{
dev_t st_dev; /* device */
ino_t st_ino; /* inode */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device type (if inode device) */
off_t st_size; /* total size, in bytes */
unsigned long st_blksize; /* blocksize for filesystem I/O */
unsigned long st_blocks; /* number of blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last change */
};
If I recall right, you have to stat the filesystem mount point.
===