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