[Sysfence-commit] sysfence getstats.c,1.6,1.7
Status: Alpha
Brought to you by:
emes
|
From: mkoperto <mko...@us...> - 2004-04-17 16:59:12
|
Update of /cvsroot/sysfence/sysfence In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3880 Modified Files: getstats.c Log Message: + fetch_pathspace(...) function Index: getstats.c =================================================================== RCS file: /cvsroot/sysfence/sysfence/getstats.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- getstats.c 1 Mar 2004 17:41:43 -0000 1.6 +++ getstats.c 17 Apr 2004 16:59:04 -0000 1.7 @@ -125,6 +125,44 @@ if (memfha < 0) bail_out (EXIT_IO, memfile); } +void fetch_pathspace(pathspaceval *pathspace) { + + char command[BUFSIZE]; + char *ptr; + FILE *pipe; + + /* getting inf. through pipe from 'df' */ + + sprintf(command, "df %s", pathspace->path); + pipe = popen(command, "r"); + fread ((char *) &fbuf, BUFSIZE,1,pipe); + pclose(pipe); + + /* reading space values for path */ + + /* 1. total space - 2nd line, 2nd column */ + ptr = fto_notspace (fto_space (fto_newline ((char *)&fbuf))); + pathspace->total = atoi(ptr); + + /* 2. used space - 2nd line, 3rd column */ + ptr = fto_notspace (fto_space (ptr)); + pathspace->used = atoi(ptr); + + /* 3. free space - 2nd line, 4th column */ + ptr = fto_notspace (fto_space (ptr)); + pathspace->free = atoi(ptr); + +#ifdef DEBUG + printf ("fetch_pathspace(): path %s total=%d used=%d free=%d\n", + pathspace->path, + pathspace->total, + pathspace->used, + pathspace->free + ); +#endif + +} + /* fast text parsing helpers */ char * fto_newline (char *b) |