diff --git a/lib/mbfile.c b/lib/mbfile.c index 3641c11e..ccea838a 100644 --- a/lib/mbfile.c +++ b/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 } diff --git a/mbtask/taskdisk.c b/mbtask/taskdisk.c index a3019138..13d74132 100644 --- a/mbtask/taskdisk.c +++ b/mbtask/taskdisk.c @@ -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++;