Completed mbtask new disk watcher

This commit is contained in:
Michiel Broek 2004-03-20 23:00:22 +00:00
parent f2a5b62745
commit f55ff6280f
33 changed files with 132 additions and 126 deletions

View File

@ -42,6 +42,7 @@ v0.51.2 06-Mar-2004
was already transmitted to remove that file from the outbound was already transmitted to remove that file from the outbound
queue. queue.
Removed some debug logging from inbound handler. Removed some debug logging from inbound handler.
Updated to use new disk watcher.
mbfido: mbfido:
When removing files during tic import due to replace or maximum When removing files during tic import due to replace or maximum
@ -55,6 +56,7 @@ v0.51.2 06-Mar-2004
file was deleted or moved. file was deleted or moved.
Doesn't write Magic Request into files description anymore, Doesn't write Magic Request into files description anymore,
this is now handled outsite the description lines. this is now handled outsite the description lines.
Updated to use new disk watcher.
mbfile: mbfile:
Updated kill, index, check, pack, list, adopt, import, move, Updated kill, index, check, pack, list, adopt, import, move,
@ -67,6 +69,7 @@ v0.51.2 06-Mar-2004
Added rearc command. Added rearc command.
The check command does now also check if the magic alias file The check command does now also check if the magic alias file
request names are valid and removes the invalid entries. request names are valid and removes the invalid entries.
Updated to use new disk watcher.
mbaff: mbaff:
When scanning for uploads, files which were hatched now have When scanning for uploads, files which were hatched now have
@ -77,6 +80,16 @@ v0.51.2 06-Mar-2004
database structure. database structure.
The filefind function is updated to the new files database The filefind function is updated to the new files database
structure. structure.
Updated to use new disk watcher.
mbindex:
Updated to use new disk watcher.
mbdiff:
Updated to use new disk watcher.
mbmsg:
Updated to use new disk watcher.
mbsebbs: mbsebbs:
Updated to the new files database structure. Updated to the new files database structure.
@ -84,6 +97,9 @@ v0.51.2 06-Mar-2004
mball: mball:
Added support for files database Magic request field. Added support for files database Magic request field.
mbuser:
Updated to use new disk watcher.
mbsetup: mbsetup:
Added auto upgrade for the files database. Added auto upgrade for the files database.
Changed menus 14, 7.n.6, 10.1 and 8.4. Changed menus 14, 7.n.6, 10.1 and 8.4.
@ -92,6 +108,8 @@ v0.51.2 06-Mar-2004
Added setup for filefind keyword length in menu 13. Added setup for filefind keyword length in menu 13.
Added setup items in menu 1.5 for child priority and filesystem Added setup items in menu 1.5 for child priority and filesystem
sync calls. sync calls.
In several menus that can change paths, a command to mbtask is
given to reread filesystem tables when something is changed.
mbmon: mbmon:
Switched to use new filesystems command. Switched to use new filesystems command.
@ -102,6 +120,8 @@ v0.51.2 06-Mar-2004
mbtask: mbtask:
Added communication commands for disk watch thread. Added communication commands for disk watch thread.
Added disk watch thread, this will monitor filesystems usage
for only the filesystems that are used by mbse.
mbuseradd: mbuseradd:
Fixed removing of a OS created homedir. This may solve problems Fixed removing of a OS created homedir. This may solve problems

6
TODO
View File

@ -73,12 +73,6 @@ newuser:
N: Add menu setup to set users preffered character set. N: Add menu setup to set users preffered character set.
mbtask:
N: Add a thread that keeps track of disk usage of all partitions used
by mbse, update partition list after setup changes. Make the info
available for all other programs so they know very fast if enough
space is still available.
mbfido: mbfido:
N: The elist rules files are named (8.3) areaname.rul where areaname N: The elist rules files are named (8.3) areaname.rul where areaname
is the first 8 characters of the area name and we use the full name is the first 8 characters of the area name and we use the full name

View File

@ -252,95 +252,6 @@ int mkdirs(char *name, mode_t mode)
/*
* Check free diskspace on most filesystems. Exclude check on floppyies,
* CD's and /boot partition. The amount of needed space is given in MBytes.
*/
int diskfree(int needed)
{
int RetVal = TRUE;
struct statfs sfs;
unsigned long temp;
#if defined(__linux__)
char *mtab, *dev, *fs, *type;
FILE *fp;
#elif defined(__FreeBSD__) || defined(__NetBSD__)
struct statfs *mntbuf;
long mntsize;
int i;
#endif
if (! needed)
return TRUE;
#if defined(__linux__)
if ((fp = fopen((char *)"/etc/mtab", "r")) == 0) {
WriteError("$Can't open /etc/mtab");
return TRUE;
}
mtab = calloc(PATH_MAX, sizeof(char));
while (fgets(mtab, PATH_MAX, fp)) {
dev = strtok(mtab, " \t");
fs = strtok(NULL, " \t");
type = strtok(NULL, " \t");
if (strncmp((char *)"/dev/", dev, 5) == 0) {
/*
* Filter out unwanted filesystems, floppy.
* Also filter out the /boot file system.
*/
if (strncmp((char *)"/dev/fd", dev, 7) && strncmp((char *)"/boot", fs, 5) &&
(!strncmp((char *)"ext2", type, 4) || !strncmp((char *)"reiserfs", type, 8) ||
!strncmp((char *)"vfat", type, 4) || !strncmp((char *)"msdos", type, 5) ||
!strncmp((char *)"ext3", type, 4))) {
if (statfs(fs, &sfs) == 0) {
temp = (unsigned long)(sfs.f_bsize / 512L);
if (((unsigned long)(sfs.f_bavail * temp) / 2048L) < needed) {
RetVal = FALSE;
WriteError("On \"%s\" only %d kb left, need %d kb", fs,
(sfs.f_bavail * sfs.f_bsize) / 1024, needed * 1024);
}
}
}
}
}
fclose(fp);
free(mtab);
#elif defined(__FreeBSD__) || defined(__NetBSD__)
if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) {
WriteError("Huh, no filesystems mounted??");
return TRUE;
}
for (i = 0; i < mntsize; i++) {
/*
* Don't check kernfs (NetBSD) and procfs (FreeBSD), floppy and CD.
*/
if ((strncmp(mntbuf[i].f_fstypename, (char *)"kernfs", 6)) &&
(strncmp(mntbuf[i].f_fstypename, (char *)"procfs", 6)) &&
(strncmp(mntbuf[i].f_mntfromname, (char *)"/dev/fd", 7)) &&
(strncmp(mntbuf[i].f_fstypename, (char *)"cd9660", 6)) &&
(strncmp(mntbuf[i].f_fstypename, (char *)"msdos", 5)) &&
(statfs(mntbuf[i].f_mntonname, &sfs) == 0)) {
temp = (unsigned long)(sfs.f_bsize / 512L);
if (((unsigned long)(sfs.f_bavail * temp) / 2048L) < needed) {
RetVal = FALSE;
WriteError("On \"%s\" only %d kb left, need %d kb", mntbuf[i].f_mntonname,
(sfs.f_bavail * sfs.f_bsize) / 1024, needed * 1024);
}
}
}
#endif
return RetVal;
}
/* /*
* Give a directory path and a filename, locate that filename in that * Give a directory path and a filename, locate that filename in that
* directory and return the filename with the correct case. This is * directory and return the filename with the correct case. This is

View File

@ -2206,7 +2206,6 @@ long file_size(char *path);
long file_crc(char *path, int); long file_crc(char *path, int);
time_t file_time(char *path); time_t file_time(char *path);
int mkdirs(char *name, mode_t); int mkdirs(char *name, mode_t);
int diskfree(int);
int getfilecase(char *, char *); int getfilecase(char *, char *);

View File

@ -41,7 +41,6 @@ int termy = 24;
void TermInit(int mode, int x, int y) void TermInit(int mode, int x, int y)
{ {
Syslog('-', "Terminit(%d, %d, %d)", mode, x, y);
termmode = mode; termmode = mode;
termx = x; termx = x;
termy = y; termy = y;

View File

@ -1085,7 +1085,7 @@ TrType binkp_receiver(void)
gettimeofday(&rxtvstart, &bp.tz); gettimeofday(&rxtvstart, &bp.tz);
bp.rxpos = bp.roffs; bp.rxpos = bp.roffs;
if (!diskfree(CFG.freespace)) { if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Binkp: low diskspace, sending BSY"); Syslog('+', "Binkp: low diskspace, sending BSY");
binkp_send_command(MM_BSY, "Low diskspace, try again later"); binkp_send_command(MM_BSY, "Low diskspace, try again later");
bp.RxState = RxDone; bp.RxState = RxDone;

View File

@ -346,8 +346,10 @@ int main(int argc, char *argv[])
/* /*
* Don't do outbound calls if low diskspace * Don't do outbound calls if low diskspace
*/ */
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
WriteError("Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (addr == NULL) { if (addr == NULL) {
WriteError("Calling mbcico without node address not supported anymore"); WriteError("Calling mbcico without node address not supported anymore");

View File

@ -143,8 +143,10 @@ int main(int argc, char **argv)
if (!do_quiet) if (!do_quiet)
printf("\n"); printf("\n");
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (lockprogram((char *)"mbaff")) { if (lockprogram((char *)"mbaff")) {
if (!do_quiet) if (!do_quiet)

View File

@ -167,8 +167,10 @@ int main(int argc, char **argv)
printf("\n"); printf("\n");
} }
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
/* /*
* Extract work directory from the first commandline parameter * Extract work directory from the first commandline parameter

View File

@ -424,8 +424,10 @@ int main(int argc, char **argv)
/* /*
* Not yet locked, if anything goes wrong, exit with die(MBERR_NO_PROGLOCK) * Not yet locked, if anything goes wrong, exit with die(MBERR_NO_PROGLOCK)
*/ */
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (do_mail) { if (do_mail) {
/* /*
@ -671,7 +673,8 @@ int TossMail(void)
Syslog('+', "Detected upsalarm semafore, aborting toss"); Syslog('+', "Detected upsalarm semafore, aborting toss");
break; break;
} }
if (!diskfree(CFG.freespace)) { if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, aborting toss");
rc = MBERR_DISK_FULL; rc = MBERR_DISK_FULL;
break; break;
} }
@ -742,8 +745,10 @@ int TossPkts(void)
*/ */
while ((fname = pull_fdlist(&fdl)) != NULL) { while ((fname = pull_fdlist(&fdl)) != NULL) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort tossing packet");
return FALSE; return FALSE;
}
packets++; packets++;
/* /*

View File

@ -234,8 +234,10 @@ int main(int argc, char **argv)
if (!do_quiet) if (!do_quiet)
printf("\n"); printf("\n");
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (lockprogram((char *)"mbfile")) { if (lockprogram((char *)"mbfile")) {
if (!do_quiet) if (!do_quiet)

View File

@ -173,8 +173,10 @@ void ImportFiles(int Area)
/* /*
* Check diskspace * Check diskspace
*/ */
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
Files++; Files++;
memset(&f_db, 0, sizeof(f_db)); memset(&f_db, 0, sizeof(f_db));

View File

@ -358,8 +358,10 @@ void ReqIndex(void)
if (area.Available) { if (area.Available) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (!do_quiet) { if (!do_quiet) {
printf("\r%4ld => %-44s \b\b\b\b", i, area.Name); printf("\r%4ld => %-44s \b\b\b\b", i, area.Name);
@ -597,8 +599,10 @@ void HtmlIndex(char *Lang)
if (area.Available) { if (area.Available) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (!do_quiet) { if (!do_quiet) {
printf("\r%4ld => %-44s \b\b\b\b", i, area.Name); printf("\r%4ld => %-44s \b\b\b\b", i, area.Name);

View File

@ -86,8 +86,10 @@ void Kill(void)
if ((area.Available) && (area.DLdays || area.FDdays) && (!area.CDrom)) { if ((area.Available) && (area.DLdays || area.FDdays) && (!area.CDrom)) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (!do_quiet) { if (!do_quiet) {
printf("\r%4d => %-44s \b\b\b\b", i, area.Name); printf("\r%4d => %-44s \b\b\b\b", i, area.Name);

View File

@ -79,8 +79,10 @@ void PackFileBase(void)
if (area.Available && !area.CDrom) { if (area.Available && !area.CDrom) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (!do_quiet) { if (!do_quiet) {
printf("\r%4d => %-44s", i, area.Name); printf("\r%4d => %-44s", i, area.Name);

View File

@ -158,8 +158,10 @@ void SortFileBase(int Area)
if (area.Available) { if (area.Available) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (!do_quiet) { if (!do_quiet) {
printf("Sorting area %d: %-44s", Area, area.Name); printf("Sorting area %d: %-44s", Area, area.Name);

View File

@ -177,8 +177,10 @@ int main(int argc,char *argv[])
Syslog(' ', cmd); Syslog(' ', cmd);
free(cmd); free(cmd);
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (lockprogram((char *)"mbindex")) { if (lockprogram((char *)"mbindex")) {
if (!do_quiet) if (!do_quiet)

View File

@ -277,8 +277,10 @@ void DoMsgBase()
fread(&msgs, msgshdr.recsize, 1, pAreas); fread(&msgs, msgshdr.recsize, 1, pAreas);
if (msgs.Active) { if (msgs.Active) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
if (!do_quiet) { if (!do_quiet) {
colour(3, 0); colour(3, 0);
@ -306,8 +308,10 @@ void DoMsgBase()
arearec++; arearec++;
if (msgs.Active) { if (msgs.Active) {
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
die(MBERR_DISK_FULL); die(MBERR_DISK_FULL);
}
Nopper(); Nopper();
if (!do_quiet) { if (!do_quiet) {

View File

@ -610,8 +610,10 @@ void flush_queue(void)
DIR *dp; DIR *dp;
Syslog('+', "Flushing outbound queue"); Syslog('+', "Flushing outbound queue");
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, not flushing outbound queue");
return; return;
}
IsDoing("Flush queue"); IsDoing("Flush queue");
if (!do_quiet) { if (!do_quiet) {

View File

@ -76,7 +76,8 @@ int Tic()
} }
Syslog('+', "Pass: process ticfiles (%s)", inbound); Syslog('+', "Pass: process ticfiles (%s)", inbound);
if (!diskfree(CFG.freespace)) { if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort tic processing");
free(inbound); free(inbound);
return -1; return -1;
} }
@ -128,7 +129,8 @@ int Tic()
Syslog('+', "Detected upsalarm semafore, aborting tic processing"); Syslog('+', "Detected upsalarm semafore, aborting tic processing");
break; break;
} }
if (!diskfree(CFG.freespace)) { if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, aborting tic processing");
rc = 0; rc = 0;
break; break;
} }

View File

@ -100,8 +100,10 @@ int main(int argc, char **argv)
Syslog(' ', cmd); Syslog(' ', cmd);
free(cmd); free(cmd);
if (!diskfree(CFG.freespace)) if (enoughspace(CFG.freespace) == 0) {
Syslog('+', "Low diskspace, abort");
ExitClient(MBERR_DISK_FULL); ExitClient(MBERR_DISK_FULL);
}
if (lockprogram((char *)"mbuser")) { if (lockprogram((char *)"mbuser")) {
if (!do_quiet) if (!do_quiet)

View File

@ -162,6 +162,7 @@ void CloseFilearea(int force)
unlink(fout); unlink(fout);
chmod(fin, 0640); chmod(fin, 0640);
Syslog('+', "Updated \"fareas.data\""); Syslog('+', "Updated \"fareas.data\"");
disk_reset();
if (!force) if (!force)
working(6, 0, 0); working(6, 0, 0);
return; return;

View File

@ -197,6 +197,7 @@ void CloseFGroup(int force)
fclose(fo); fclose(fo);
unlink(fout); unlink(fout);
chmod(fin, 0640); chmod(fin, 0640);
disk_reset();
Syslog('+', "Updated \"fgroups.data\""); Syslog('+', "Updated \"fgroups.data\"");
if (!force) if (!force)
working(6, 0, 0); working(6, 0, 0);

View File

@ -1476,6 +1476,7 @@ void global_menu(void)
if (crc != crc1) { if (crc != crc1) {
if (yes_no((char *)"Configuration is changed, save") == 1) { if (yes_no((char *)"Configuration is changed, save") == 1) {
cf_close(); cf_close();
disk_reset();
Syslog('+', "Saved main config"); Syslog('+', "Saved main config");
working(6, 0, 0); working(6, 0, 0);
} }

View File

@ -183,6 +183,7 @@ void CloseHatch(int force)
fclose(fo); fclose(fo);
unlink(fout); unlink(fout);
chmod(fin, 0640); chmod(fin, 0640);
disk_reset();
Syslog('+', "Updated \"hatch.data\""); Syslog('+', "Updated \"hatch.data\"");
if (!force) if (!force)
working(6, 0, 0); working(6, 0, 0);

View File

@ -239,6 +239,7 @@ void CloseLanguage(int force)
tidy_stlist(&lan); tidy_stlist(&lan);
chmod(fin, 0640); chmod(fin, 0640);
Syslog('+', "Updated \"language.data\""); Syslog('+', "Updated \"language.data\"");
disk_reset();
if (!force) if (!force)
working(6, 0, 0); working(6, 0, 0);
return; return;

View File

@ -174,6 +174,7 @@ void CloseMagics(int force)
tidy_stlist(&mag); tidy_stlist(&mag);
unlink(fout); unlink(fout);
chmod(fin, 0640); chmod(fin, 0640);
disk_reset();
Syslog('+', "Updated \"magic.data\""); Syslog('+', "Updated \"magic.data\"");
if (!force) if (!force)
working(6, 0, 0); working(6, 0, 0);

View File

@ -270,6 +270,7 @@ void CloseMsgarea(int Force)
unlink(fout); unlink(fout);
chmod(fin, 0660); chmod(fin, 0660);
Syslog('+', "Updated \"mareas.data\""); Syslog('+', "Updated \"mareas.data\"");
disk_reset();
if (!Force) if (!Force)
working(6, 0, 0); working(6, 0, 0);
return; return;

View File

@ -206,6 +206,7 @@ void CloseMGroup(int force)
fclose(fo); fclose(fo);
unlink(fout); unlink(fout);
chmod(fin, 0640); chmod(fin, 0640);
disk_reset();
Syslog('+', "Updated \"mgroups.data\""); Syslog('+', "Updated \"mgroups.data\"");
if (!force) if (!force)
working(6, 0, 0); working(6, 0, 0);

View File

@ -259,6 +259,7 @@ void CloseNoderec(int Force)
free(fin); free(fin);
free(fout); free(fout);
Syslog('+', "Updated \"nodes.data\""); Syslog('+', "Updated \"nodes.data\"");
disk_reset();
CreateSema((char *)"scanout"); CreateSema((char *)"scanout");
working(6, 0, 0); working(6, 0, 0);
return; return;

View File

@ -136,3 +136,9 @@ void addtoc(FILE *fp, FILE *toc, int chapt, int par, int page, char *title)
void disk_reset(void)
{
SockS("DRES:0;");
}

View File

@ -1,10 +1,12 @@
#ifndef _MUTIL_H #ifndef _MUTIL_H
#define _MUTIL_H #define _MUTIL_H
/* $Id$ */
unsigned char readkey(int, int, int, int); unsigned char readkey(int, int, int, int);
unsigned char testkey(int, int); unsigned char testkey(int, int);
int newpage(FILE *, int); int newpage(FILE *, int);
void addtoc(FILE *, FILE *, int, int, int, char *); void addtoc(FILE *, FILE *, int, int, int, char *);
void disk_reset(void);
#endif #endif

View File

@ -34,11 +34,6 @@
#include "taskutil.h" #include "taskutil.h"
int disk_reread = FALSE; /* Reread tables */
extern int T_Shutdown; /* Program shutdown */
int disk_run = FALSE; /* Thread running */
typedef struct _mfs_list { typedef struct _mfs_list {
struct _mfs_list *next; /* Linked list */ struct _mfs_list *next; /* Linked list */
char *mountpoint; /* Mountpoint */ char *mountpoint; /* Mountpoint */
@ -48,6 +43,12 @@ typedef struct _mfs_list {
} mfs_list; } mfs_list;
mfs_list *mfs = NULL; /* List of filesystems */ mfs_list *mfs = NULL; /* List of filesystems */
int disk_reread = FALSE; /* Reread tables */
extern int T_Shutdown; /* Program shutdown */
int disk_run = FALSE; /* Thread running */
pthread_mutex_t a_mutex = PTHREAD_MUTEX_INITIALIZER;
/* /*
@ -132,10 +133,10 @@ char *disk_check(char *token)
static char buf[SS_BUFSIZE]; static char buf[SS_BUFSIZE];
mfs_list *tmp; mfs_list *tmp;
unsigned long needed; unsigned long needed;
int rc;
strtok(token, ","); strtok(token, ",");
needed = atol(strtok(NULL, ";")); needed = atol(strtok(NULL, ";"));
Syslog('d', "disk_check(%ld)", needed);
if (! needed) { if (! needed) {
/* /*
@ -153,16 +154,24 @@ char *disk_check(char *token)
return buf; return buf;
} }
if ((rc = pthread_mutex_lock(&a_mutex)))
Syslog('!', "disk_check() mutex_lock failed rc=%d", rc);
for (tmp = mfs; tmp; tmp = tmp->next) { for (tmp = mfs; tmp; tmp = tmp->next) {
if (tmp->avail < needed) { if (tmp->avail < needed) {
/* /*
* Answer Not enough space * Answer Not enough space
*/ */
if ((rc = pthread_mutex_unlock(&a_mutex)))
Syslog('!', "disk_check() mutex_unlock failed rc=%d", rc);
sprintf(buf, "100:1,0"); sprintf(buf, "100:1,0");
return buf; return buf;
} }
} }
if ((rc = pthread_mutex_unlock(&a_mutex)))
Syslog('!', "disk_check() mutex_unlock failed rc=%d", rc);
/* /*
* Enough space * Enough space
*/ */
@ -181,7 +190,7 @@ char *disk_getfs()
static char buf[SS_BUFSIZE]; static char buf[SS_BUFSIZE];
char tt[80], *ans = NULL; char tt[80], *ans = NULL;
mfs_list *tmp; mfs_list *tmp;
int i = 0; int rc, i = 0;
buf[0] = '\0'; buf[0] = '\0';
if (mfs == NULL) { if (mfs == NULL) {
@ -189,6 +198,9 @@ char *disk_getfs()
return buf; return buf;
} }
if ((rc = pthread_mutex_lock(&a_mutex)))
Syslog('!', "disk_getfs() mutex_lock failed rc=%d", rc);
for (tmp = mfs; tmp; tmp = tmp->next) { for (tmp = mfs; tmp; tmp = tmp->next) {
i++; i++;
if (ans == NULL) if (ans == NULL)
@ -201,6 +213,8 @@ char *disk_getfs()
if (i == 10) /* No more then 10 filesystems */ if (i == 10) /* No more then 10 filesystems */
break; break;
} }
if ((rc = pthread_mutex_unlock(&a_mutex)))
Syslog('!', "disk_getfs() mutex_unlock failed rc=%d", rc);
if (strlen(ans) > (SS_BUFSIZE - 8)) if (strlen(ans) > (SS_BUFSIZE - 8))
sprintf(buf, "100:0;"); sprintf(buf, "100:0;");
@ -223,6 +237,10 @@ void update_diskstat(void)
struct statfs sfs; struct statfs sfs;
unsigned long temp; unsigned long temp;
mfs_list *tmp; mfs_list *tmp;
int rc;
if ((rc = pthread_mutex_lock(&a_mutex)))
Syslog('!', "update_diskstat() mutex_lock failed rc=%d", rc);
for (tmp = mfs; tmp; tmp = tmp->next) { for (tmp = mfs; tmp; tmp = tmp->next) {
if (statfs(tmp->mountpoint, &sfs) == 0) { if (statfs(tmp->mountpoint, &sfs) == 0) {
@ -231,6 +249,9 @@ void update_diskstat(void)
tmp->avail = (unsigned long)(sfs.f_bavail * temp) / 2048L; tmp->avail = (unsigned long)(sfs.f_bavail * temp) / 2048L;
} }
} }
if ((rc = pthread_mutex_unlock(&a_mutex)))
Syslog('!', "update_diskstat() mutex_unlock failed rc=%d", rc);
} }
@ -338,6 +359,7 @@ void *disk_thread(void)
FILE *fp; FILE *fp;
char *temp; char *temp;
mfs_list *tmp; mfs_list *tmp;
int rc;
Syslog('+', "Start disk thread"); Syslog('+', "Start disk thread");
disk_run = TRUE; disk_run = TRUE;
@ -348,6 +370,10 @@ void *disk_thread(void)
if (disk_reread) { if (disk_reread) {
disk_reread = FALSE; disk_reread = FALSE;
Syslog('+', "Reread disk filesystems"); Syslog('+', "Reread disk filesystems");
if ((rc = pthread_mutex_lock(&a_mutex)))
Syslog('!', "disk_thread() mutex_lock failed rc=%d", rc);
tidy_mfslist(&mfs); tidy_mfslist(&mfs);
add_path(getenv("MBSE_ROOT")); add_path(getenv("MBSE_ROOT"));
@ -489,6 +515,9 @@ void *disk_thread(void)
for (tmp = mfs; tmp; tmp = tmp->next) { for (tmp = mfs; tmp; tmp = tmp->next) {
Syslog('+', "%s %s %ld %ld", tmp->mountpoint, tmp->fstype, tmp->size, tmp->avail); Syslog('+', "%s %s %ld %ld", tmp->mountpoint, tmp->fstype, tmp->size, tmp->avail);
} }
if ((rc = pthread_mutex_unlock(&a_mutex)))
Syslog('!', "disk_thread() mutex_unlock failed rc=%d", rc);
} }
update_diskstat(); update_diskstat();