Fixed FreeBSD filesystem usage
This commit is contained in:
parent
f5009b2c36
commit
080ece1387
19
lib/mbfile.c
19
lib/mbfile.c
@ -2,7 +2,7 @@
|
||||
*
|
||||
* File ..................: mbfile
|
||||
* Purpose ...............: Basic File I/O
|
||||
* Last modification date : 12-Aug-2001
|
||||
* Last modification date : 29-Oct-2001
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
@ -262,28 +262,30 @@ int mkdirs(char *name)
|
||||
*/
|
||||
int diskfree(int needed)
|
||||
{
|
||||
#ifdef __linux__
|
||||
char *mtab, *dev, *fs, *type;
|
||||
FILE *fp;
|
||||
struct statfs sfs;
|
||||
int RetVal = TRUE;
|
||||
unsigned long temp;
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
if (! needed)
|
||||
return TRUE;
|
||||
|
||||
mtab = calloc(PATH_MAX, sizeof(char));
|
||||
#ifdef __linux__
|
||||
if ((fp = fopen((char *)"/etc/mtab", "r")) == 0) {
|
||||
WriteError("$Can't open /etc/mtab");
|
||||
#elif __FreeBSD__
|
||||
if ((fp = fopen((char *)"/etc/fstab", "r")) == 0) {
|
||||
WriteError("$Can't open /etc/fstab");
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
while (fgets(mtab, PATH_MAX, fp)) {
|
||||
dev = strtok(mtab, " ");
|
||||
fs = strtok(NULL, " ");
|
||||
type = strtok(NULL, " ");
|
||||
dev = strtok(mtab, " \t");
|
||||
fs = strtok(NULL, " \t");
|
||||
type = strtok(NULL, " \t");
|
||||
if (strncmp((char *)"/dev/", dev, 5) == 0) {
|
||||
/*
|
||||
* Filter out unwanted filesystems, floppy.
|
||||
@ -308,9 +310,6 @@ int diskfree(int needed)
|
||||
free(mtab);
|
||||
|
||||
return RetVal;
|
||||
#else /* ifdef __linux__ */
|
||||
return TRUE; /* Assume enough */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* File ..................: mbtask/statdisk.c
|
||||
* Purpose ...............: Give status of all filesystems
|
||||
* Last modification date : 23-May-2001
|
||||
* Last modification date : 29-Oct-2001
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
@ -50,16 +50,20 @@ char *get_diskstat()
|
||||
unsigned long temp;
|
||||
|
||||
buf[0] = '\0';
|
||||
mtab = calloc(256, sizeof(char));
|
||||
mtab = calloc(PATH_MAX, sizeof(char));
|
||||
#ifdef __linux__
|
||||
if ((fp = fopen((char *)"/etc/mtab", "r")) == 0) {
|
||||
#elif __FreeBSD__
|
||||
if ((fp = fopen((char *)"/etc/fstab", "r")) == 0) {
|
||||
#endif
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
while (fgets(mtab, 255, fp)) {
|
||||
dev = strtok(mtab, " ");
|
||||
fs = strtok(NULL, " ");
|
||||
type = strtok(NULL, " ");
|
||||
dev = strtok(mtab, " \t");
|
||||
fs = strtok(NULL, " \t");
|
||||
type = strtok(NULL, " \t");
|
||||
if (strncmp((char *)"/dev/", dev, 5) == 0) {
|
||||
if (statfs(fs, &sfs) == 0) {
|
||||
i++;
|
||||
|
Reference in New Issue
Block a user