LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-26-2005, 02:50 PM   #1
srns
LQ Newbie
 
Registered: Sep 2004
Posts: 29

Rep: Reputation: 15
API for getting free space information in Linux.


Hello,

Is there an API in Linux that I can use to find the hard disk usage? I would like to know the available free space every once in a while. Right now, I am using df, but it's not efficient.

Thanks..
 
Old 04-26-2005, 03:01 PM   #2
Moloko
Member
 
Registered: Mar 2004
Location: Netherlands
Distribution: Debian
Posts: 729

Rep: Reputation: 30
Krusader 1.6 has a Disk Usage plugin or use Filelight:

http://www.kde-apps.org/content/show.php?content=9887
 
Old 04-26-2005, 03:46 PM   #3
csfalcon
Member
 
Registered: Jun 2004
Location: MD
Distribution: Fedora Core
Posts: 269

Rep: Reputation: 31
take a look at the man pages for:

getmntent()
setmntent()
 
Old 04-26-2005, 04:31 PM   #4
srns
LQ Newbie
 
Registered: Sep 2004
Posts: 29

Original Poster
Rep: Reputation: 15
Let me clarify..

I am storing some data continuously to the disk. Periodically I check the free space on the disk. I use df and some massaging of the data to get the number. But, it's a pain.

Is there a system call which I can use to get this info? getmntent() seems to show only the information in fstab and mtab.
 
Old 04-26-2005, 05:04 PM   #5
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
statvfs() and fstatvfs()

#include <sys/statvfs.h>
 
Old 04-26-2005, 05:52 PM   #6
srns
LQ Newbie
 
Registered: Sep 2004
Posts: 29

Original Poster
Rep: Reputation: 15
I went to the source code listing and went thru all available system calls. I already got the info, and implemented it in my code. Works fine!

Check out this site for source code (if you didn't knew):
http://lxr.linux.no/source/include/a...std.h?v=2.6.10


Thanks anyway..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Free space wiping in Linux? IamI Linux - Software 15 01-30-2012 09:03 AM
wipe free space with Linux? bigrobot Linux - Software 2 02-19-2005 04:08 AM
Not enough free space on hard drive with 50g of free space??? auoq SUSE / openSUSE 5 10-13-2004 08:21 PM
Socket API from Kernel Space codecowboy Programming 2 07-15-2004 02:20 AM
Formating free space: WinXP pro and RH9 dualboot with free space on 3rd drive Vermicious Linux - General 2 03-22-2004 05:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration