Re: finding how much the file system is full, from a C program?



prasadjoshi124@xxxxxxxxx wrote:

Hi All,

I am writing a small tool which is supposed to fill the filesystem to a
specified percent.

For, that I need to read how much the file system is full in percent,
like the output given by df -k

lopgod10:~/mycrfile # df -k /mnt/mvdg1/vset
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/vx/dsk/mvdg1/vsetdg1
1536000 349854 1112370 24% /mnt/mvdg1/vset

How can I do it from a C program.


df is a C program and it's open source. It's part of the
GNU fileutils which is part of the GNU coreutils.

Source code is available here.

http://ftp.gnu.org/pub/gnu/coreutils/

As others have said, this is not portable C. Which means,
you may as well write a shell script which invokes df and,
say, dd to do the job.

Kind regards,

Iwo

.



Relevant Pages

  • Re: A Suggestion For Higher-Quality Open-Source Software
    ... perhaps as an hook to ... the filesystem, where it belongs. ... don't care whether or not open source wins out in the long run. ... But instead of suggesting ...
    (comp.os.linux.misc)
  • Re: Open Source testing versus Closed Source testing
    ... until now I've been testing mostly Open Source software by writing Open ... Closed Source software? ...
    (comp.software.testing)
  • Re: When static typing is worth it
    ... Of course not or I wouldn't spend what little free time I have writing ... open source Common Lisp software. ... more productive and potentially interesting than hurling abuse or ...
    (comp.lang.lisp)
  • Re: My Linux HA book is done! (yeah :-)
    ... me asking if I would write about Linux and Home Automation. ... magazine articles than writing the book). ... Automation and I'm not going to start charging for my normal support. ... BTW, you're not paying for the software, that's Open Source (except ...
    (comp.home.automation)
  • Re: Accidently Removed "Add/Remove Programs"
    ... ecosystem toolset achieves self-awareness and starts writing and ... implementing its own release policies, removing the need for any human ... As our world burns, open source advocates ...
    (Fedora)