[ale] system interface for df info?
Christopher Fowler
cfowler at outpostsentinel.com
Wed Jan 18 10:01:14 EST 2006
df gets its information using statfs()
statfs("/", &buf);
bsize = buf.f_bsize;
printf("\tTotal Bytes: %10lu Kb\n", (buf.f_blocks * bsize) /
1024);
printf("\tUsed Bytes: %10lu Kb\n", ((buf.f_blocks -
buf.f_bfree) * bsize) / 1024);
printf("\tFree Bytes: %10lu Kb\n", (buf.f_bfree * bsize) /
1024);
Thats how I do it on our embedded device.
On Wed, 2006-01-18 at 05:53 -0500, Jim wrote:
> Ah, good old strace. Thanks for reminding me of a useful tool.
>
> Jim.
> Joe Steele wrote:
>
> >An easy way to find out:
> >strace df 2>&1 | less
> >
> >You'll see that it opens /etc/mtab, and then performs an statfs64() on
> >each mounted filesystem found there.
> >
> >--Joe
> >
> >Jim wrote:
> >
> >
> >>Where does df get its information? I'd like to programatically get the
> >>same info without calling df. I've looked at /proc but nothing jumped
> >>out. Obviously, df doesn't add up all the files to get "used" space,
> >>'cause it doesn't take that long.
> >>
> >>
> >_______________________________________________
> >Ale mailing list
> >Ale at ale.org
> >http://www.ale.org/mailman/listinfo/ale
> >
> >
> >
> >
> >
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list