"df" from C program - Redhat

This is a discussion on "df" from C program - Redhat ; I need to get the state of my disk from a C program, in particular, how much disk is used and how much is left. How do I do this? Thanks for your help. Mike....

+ Reply to Thread
Results 1 to 5 of 5

Thread: "df" from C program

  1. "df" from C program

    I need to get the state of my disk from
    a C program, in particular, how much disk
    is used and how much is left. How do I
    do this? Thanks for your help.
    Mike.


  2. Re: "df" from C program

    Mike - EMAIL IGNORED writes:

    > I need to get the state of my disk from
    > a C program, in particular, how much disk
    > is used and how much is left. How do I
    > do this? Thanks for your help.
    > Mike.


    Download the source of the df program and study it.

    If you are too lazy to do that (I am not saying it as an insult
    but as finding an even easier way), then just run "strace df"
    and see what system calls it execute. Or you can even run "ltrace df"
    to see the library calls as well.

    Hint. you need the statfs family of calls.

    Vilmos

  3. Re: "df" from C program

    Mike - EMAIL IGNORED wrote:
    >I need to get the state of my disk from
    >a C program, in particular, how much disk
    >is used and how much is left. How do I
    >do this? Thanks for your help.
    >Mike.


    man statfs

    You can either use fstatfs()/statfs(), or you can
    run df with popen().

    --
    Floyd L. Davidson
    Ukpeagvik (Barrow, Alaska) floyd@apaflo.com

  4. Re: =?UTF-8?B?ImRmIg==?= from C program

    Mike - EMAIL IGNORED writes:

    > I need to get the state of my disk from
    > a C program, in particular, how much disk
    > is used and how much is left. How do I
    > do this? Thanks for your help.


    See the man page for statfs and/or vstatfs



    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2.2 (GNU/Linux)

    iD8DBQBEblxAx9p3GYHlUOIRAuKYAJ4xSyURteAPVe7vwMJjjG Y3/VVnSACdFqU2
    m6QvnWBxuUeL5UJ1Iy0zxvk=
    =8R9d
    -----END PGP SIGNATURE-----


  5. Re: "df" from C program

    Mike - EMAIL IGNORED writes:
    >I need to get the state of my disk from
    >a C program, in particular, how much disk
    >is used and how much is left. How do I
    >do this? Thanks for your help.
    >Mike.
    >


    man statvfs

+ Reply to Thread