LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-30-2005, 01:22 AM   #1
syseeker
Member
 
Registered: Aug 2003
Posts: 66

Rep: Reputation: 15
What glibc command to query hard disk space?


Hi,

Is there glib command to query local disk space (space used, space available)?
Thanks.
 
Old 11-30-2005, 03:27 AM   #2
syseeker
Member
 
Registered: Aug 2003
Posts: 66

Original Poster
Rep: Reputation: 15
Or ... Is there any glibc or other kernel command/library exists to allow retrieval of hard disk information? I checked glibc doc and get commands to track processes, memory resources usage. But none for hard disk... I believe there should be some command...
 
Old 11-30-2005, 03:11 PM   #3
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
There is afaik no simple function to return df type output, but see:
man 2 stat
man 2 statfs

statfs returns a pointer to struct which contains:
Code:
struct statfs {
     long    f_type;     /* type of filesystem (see below) */
     long    f_bsize;    /* optimal transfer block size */
     long    f_blocks;   /* total data blocks in file system */
     long    f_bfree;    /* free blocks in fs */
     long    f_bavail;   /* free blocks avail to non-superuser */
     long    f_files;    /* total file nodes in file system */
     long    f_ffree;    /* free file nodes in fs */
     fsid_t  f_fsid;     /* file system id */
     long    f_namelen;  /* maximum length of filenames */
};
(f_blocks - f_bfree) * f_bsize = free space

HTH
 
Old 11-30-2005, 03:56 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
You could also try:

popen ("df -k", "r")

The advantage of "popen()" is that you can use it with any system command (df, netstat, ps, vmstat, etc etc)

'Hope that helps .. pSM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
URGENT: Hard disk Query mailnickykav Red Hat 4 02-25-2005 01:55 PM
Hard disk space shaahul Linux - Newbie 1 08-25-2003 10:48 AM
hard disk space kafnir Linux - Newbie 4 02-20-2003 01:57 AM
Disk space wastage 73 GB Hard disk rajgopalhg Linux - Hardware 2 10-18-2002 03:41 PM
space in hard disk jaac Linux - Software 3 11-13-2001 10:57 PM

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

All times are GMT -5. The time now is 04:31 PM.

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