SUMMARY : Actual disk space available for storage?

From: Pravin Chavan (prchavan@pcsbom.patni.com)
Date: Tue Feb 17 1998 - 11:53:10 CST


Hi Sun-managers,

Thanks to the foll. and anybody else I inadvertently missed out:

Rich Kulawiec <rsk@gsp.org>
David Thorburn-Gundlach <david@bae.uga.edu>
Michael Hill <Michael_Hill@csgsystems.com>
"Serguei I.Revtov" <sir@cb.tver.ru>
Jochen Bern <bern@penthesilea.uni-trier.de>
--------------------------------------------------------------------------

>From Rich Kulaweic

This has been discussed numerous times, and the answer appears in the
list archives in many, many places. When you seach them, you'll also find
that you don't need to write a program to do this -- it's already been
done. The one that I use is lifted from the NOCOL distribution (also
covered in the archives), but there are many to choose from.

---Rsk
--------------------------------------------------------------------------

The following response (from Serguei I.Revtov) helped me:

Hi!

Check for statvfs(2) manpage.

statvfs structure (see /usr/include/sys/statvfs.h) has fields you want:

        fsblkcnt_t f_bavail; /* free blocks avail to non-superuser */
        fsfilcnt_t f_favail; /* free nodes avail to non-superuser */

--------------------------------------------------------------------------
Other responses suggested unix utilities, but I am writing a C program and
was looking for C related commands only.

Original Question
-----------------

Hi Sun-managers,

I am writing a C program which will find out
whether it is possible to create a file of
given size on a disk after taking into
account the amount of free space on that disk.

As I understand, Solaris does not allow
usage of 100% of disk space. About 10% of the
available space is reserved.

Also I have to take into account the way a file is
stored on a disk (e.g. space required for inodes, etc.)
I am not very clear about these concepts.

Can somebody help me in deriving a formula for
the above which will be applicable to files
of variable size?

Thanks in advance. Will summarize.

Regards,

Pravin
prchavan@pcsbom.patni.com



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:31 CDT