![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| free some space in file system | fu4d | UNIX for Dummies Questions & Answers | 6 | 04-11-2008 04:27 AM |
| command to find free disk space on solaris | harishankar | SUN Solaris | 2 | 08-26-2007 11:47 AM |
| How to re-allocate disk space on solaris 10 | duke0001 | UNIX for Advanced & Expert Users | 2 | 12-13-2006 11:14 AM |
| free disk space calc | ninjanesto | High Level Programming | 1 | 11-10-2006 11:03 AM |
| Free size for File System | videsh77 | UNIX for Dummies Questions & Answers | 7 | 02-03-2005 06:44 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Needed to write something to get information from the disks and send it to a web app, so here is the code (the html stuff removed), this should give you the info (works on our AIX servers atleast). Only thing is it does give a slightly higher free space value than df, not certain what is causing it.
Code:
/*
################################################################################
## diskstat.c ##
################################################################################
## diskstat returns (or will soon return to be more precice) webified diskstat for specific disk, should change to ##
## XML'ified info at some point..... ##
################################################################################
*/
#include <sys/statvfs.h>
int main( int argc, char *argv[] )
{
struct statvfs fiData;
struct statvfs *fpData;
char fnPath[128];
int i;
if( argc < 2 ) {
printf("Usage, webdisk DEVICE0 ..... DEVICEX\n");
return(2);
}
//Lets loopyloop through the argvs
for( i = 1 ; i<argc; i++ ) {
strcpy(fnPath, argv[i]);
if((statvfs(fnPath,&fiData)) < 0 ) {
printf("Failed to stat %s:\n", fnPath);
} else {
printf("Disk %s: \n", fnPath);
printf("\tblock size: %u\n", fiData.f_bsize);
printf("\ttotal no blocks: %i\n", fiData.f_blocks);
printf("\tfree blocks: %i\n", fiData.f_bfree);
}
}
}
For the other members of the struct, check sys/statvfs.h. Just compile and send it the mountpoint of the disk. So for example ./a.out / BTW Thanks blowtorch for pointing me in the right direction whith statvls. |
|
||||
|
hi,
i have written the code to find free space for linux using native code of java like below. #include <sys/statvfs.h> JNIEXPORT jlong JNICALL Java_NativeUtils_getDiskFreeSpace (JNIEnv *env, jclass obj, jstring path) { struct statvfs fiData; struct statvfs *fpData; //char fnPath[128]; int i; const char *str = (*env)->GetStringUTFChars(env, path, 0); jlong ret; if((statvfs(str,&fiData)) < 0 ) { printf("Failed to stat %s:\n", str); } else { printf("\tblock size: %u\n", fiData.f_bsize); } (*env)->ReleaseStringUTFChars(env, path, str); ret = (jlong)fiData.QuadPart; return ret; } if any person is having the linux os and can u please test and get back to me thanks, prasad |
|
||||
|
I used ur code and compliled it using gcc compiler on Linux. But its giving the following error.
error: `JNIEXPORT' does not name a type any solution to that ??? |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|