diff --git a/ChangeLog b/ChangeLog index b618c359..1f575c5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,7 @@ v0.51.2 06-Mar-2004 was already transmitted to remove that file from the outbound queue. Removed some debug logging from inbound handler. + Updated to use new disk watcher. mbfido: 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. Doesn't write Magic Request into files description anymore, this is now handled outsite the description lines. + Updated to use new disk watcher. mbfile: Updated kill, index, check, pack, list, adopt, import, move, @@ -67,6 +69,7 @@ v0.51.2 06-Mar-2004 Added rearc command. The check command does now also check if the magic alias file request names are valid and removes the invalid entries. + Updated to use new disk watcher. mbaff: When scanning for uploads, files which were hatched now have @@ -77,6 +80,16 @@ v0.51.2 06-Mar-2004 database structure. The filefind function is updated to the new files database 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: Updated to the new files database structure. @@ -84,6 +97,9 @@ v0.51.2 06-Mar-2004 mball: Added support for files database Magic request field. + mbuser: + Updated to use new disk watcher. + mbsetup: Added auto upgrade for the files database. 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 items in menu 1.5 for child priority and filesystem sync calls. + In several menus that can change paths, a command to mbtask is + given to reread filesystem tables when something is changed. mbmon: Switched to use new filesystems command. @@ -102,6 +120,8 @@ v0.51.2 06-Mar-2004 mbtask: 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: Fixed removing of a OS created homedir. This may solve problems diff --git a/TODO b/TODO index f126867b..d4120a56 100644 --- a/TODO +++ b/TODO @@ -73,12 +73,6 @@ newuser: 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: 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 diff --git a/lib/mbfile.c b/lib/mbfile.c index 8924c2fd..544b59cb 100644 --- a/lib/mbfile.c +++ b/lib/mbfile.c @@ -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 * directory and return the filename with the correct case. This is diff --git a/lib/mbselib.h b/lib/mbselib.h index 3749a199..99ad5f63 100644 --- a/lib/mbselib.h +++ b/lib/mbselib.h @@ -2206,7 +2206,6 @@ long file_size(char *path); long file_crc(char *path, int); time_t file_time(char *path); int mkdirs(char *name, mode_t); -int diskfree(int); int getfilecase(char *, char *); diff --git a/lib/term.c b/lib/term.c index 55b226fd..df6bc3c7 100644 --- a/lib/term.c +++ b/lib/term.c @@ -41,7 +41,6 @@ int termy = 24; void TermInit(int mode, int x, int y) { - Syslog('-', "Terminit(%d, %d, %d)", mode, x, y); termmode = mode; termx = x; termy = y; diff --git a/mbcico/binkp.c b/mbcico/binkp.c index 0790177e..0b665b06 100644 --- a/mbcico/binkp.c +++ b/mbcico/binkp.c @@ -1085,7 +1085,7 @@ TrType binkp_receiver(void) gettimeofday(&rxtvstart, &bp.tz); bp.rxpos = bp.roffs; - if (!diskfree(CFG.freespace)) { + if (enoughspace(CFG.freespace) == 0) { Syslog('+', "Binkp: low diskspace, sending BSY"); binkp_send_command(MM_BSY, "Low diskspace, try again later"); bp.RxState = RxDone; diff --git a/mbcico/mbcico.c b/mbcico/mbcico.c index f8529257..45ecd983 100644 --- a/mbcico/mbcico.c +++ b/mbcico/mbcico.c @@ -346,8 +346,10 @@ int main(int argc, char *argv[]) /* * 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); + } if (addr == NULL) { WriteError("Calling mbcico without node address not supported anymore"); diff --git a/mbfido/mbaff.c b/mbfido/mbaff.c index 0d11335b..dfb1ffb6 100644 --- a/mbfido/mbaff.c +++ b/mbfido/mbaff.c @@ -143,8 +143,10 @@ int main(int argc, char **argv) if (!do_quiet) printf("\n"); - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (lockprogram((char *)"mbaff")) { if (!do_quiet) diff --git a/mbfido/mbdiff.c b/mbfido/mbdiff.c index 1ffbb4f1..6d3ead74 100644 --- a/mbfido/mbdiff.c +++ b/mbfido/mbdiff.c @@ -167,8 +167,10 @@ int main(int argc, char **argv) printf("\n"); } - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } /* * Extract work directory from the first commandline parameter diff --git a/mbfido/mbfido.c b/mbfido/mbfido.c index c01c87a7..632921cf 100644 --- a/mbfido/mbfido.c +++ b/mbfido/mbfido.c @@ -424,8 +424,10 @@ int main(int argc, char **argv) /* * 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); + } if (do_mail) { /* @@ -671,7 +673,8 @@ int TossMail(void) Syslog('+', "Detected upsalarm semafore, aborting toss"); break; } - if (!diskfree(CFG.freespace)) { + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, aborting toss"); rc = MBERR_DISK_FULL; break; } @@ -742,8 +745,10 @@ int TossPkts(void) */ while ((fname = pull_fdlist(&fdl)) != NULL) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort tossing packet"); return FALSE; + } packets++; /* diff --git a/mbfido/mbfile.c b/mbfido/mbfile.c index 2adea69f..58c8aab5 100644 --- a/mbfido/mbfile.c +++ b/mbfido/mbfile.c @@ -234,8 +234,10 @@ int main(int argc, char **argv) if (!do_quiet) printf("\n"); - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (lockprogram((char *)"mbfile")) { if (!do_quiet) diff --git a/mbfido/mbfimport.c b/mbfido/mbfimport.c index 638148a6..b4aec552 100644 --- a/mbfido/mbfimport.c +++ b/mbfido/mbfimport.c @@ -173,8 +173,10 @@ void ImportFiles(int Area) /* * Check diskspace */ - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } Files++; memset(&f_db, 0, sizeof(f_db)); diff --git a/mbfido/mbfindex.c b/mbfido/mbfindex.c index f8456282..9655bbda 100644 --- a/mbfido/mbfindex.c +++ b/mbfido/mbfindex.c @@ -358,8 +358,10 @@ void ReqIndex(void) if (area.Available) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (!do_quiet) { printf("\r%4ld => %-44s \b\b\b\b", i, area.Name); @@ -597,8 +599,10 @@ void HtmlIndex(char *Lang) if (area.Available) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (!do_quiet) { printf("\r%4ld => %-44s \b\b\b\b", i, area.Name); diff --git a/mbfido/mbfkill.c b/mbfido/mbfkill.c index 18a8becd..52872646 100644 --- a/mbfido/mbfkill.c +++ b/mbfido/mbfkill.c @@ -86,8 +86,10 @@ void Kill(void) 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); + } if (!do_quiet) { printf("\r%4d => %-44s \b\b\b\b", i, area.Name); diff --git a/mbfido/mbfpack.c b/mbfido/mbfpack.c index 8c25eb12..ee2b0367 100644 --- a/mbfido/mbfpack.c +++ b/mbfido/mbfpack.c @@ -79,8 +79,10 @@ void PackFileBase(void) if (area.Available && !area.CDrom) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (!do_quiet) { printf("\r%4d => %-44s", i, area.Name); diff --git a/mbfido/mbfsort.c b/mbfido/mbfsort.c index 7747a7bd..9d53fd67 100644 --- a/mbfido/mbfsort.c +++ b/mbfido/mbfsort.c @@ -158,8 +158,10 @@ void SortFileBase(int Area) if (area.Available) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (!do_quiet) { printf("Sorting area %d: %-44s", Area, area.Name); diff --git a/mbfido/mbindex.c b/mbfido/mbindex.c index 21897db7..e51f258b 100644 --- a/mbfido/mbindex.c +++ b/mbfido/mbindex.c @@ -177,8 +177,10 @@ int main(int argc,char *argv[]) Syslog(' ', cmd); free(cmd); - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (lockprogram((char *)"mbindex")) { if (!do_quiet) diff --git a/mbfido/mbmsg.c b/mbfido/mbmsg.c index d692af2e..ac19ec37 100644 --- a/mbfido/mbmsg.c +++ b/mbfido/mbmsg.c @@ -277,8 +277,10 @@ void DoMsgBase() fread(&msgs, msgshdr.recsize, 1, pAreas); if (msgs.Active) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } if (!do_quiet) { colour(3, 0); @@ -306,8 +308,10 @@ void DoMsgBase() arearec++; if (msgs.Active) { - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); die(MBERR_DISK_FULL); + } Nopper(); if (!do_quiet) { diff --git a/mbfido/queue.c b/mbfido/queue.c index 30a20acb..3d3f3eb2 100644 --- a/mbfido/queue.c +++ b/mbfido/queue.c @@ -610,8 +610,10 @@ void flush_queue(void) DIR *dp; Syslog('+', "Flushing outbound queue"); - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, not flushing outbound queue"); return; + } IsDoing("Flush queue"); if (!do_quiet) { diff --git a/mbfido/tic.c b/mbfido/tic.c index b39f9f27..50968edb 100644 --- a/mbfido/tic.c +++ b/mbfido/tic.c @@ -76,7 +76,8 @@ int Tic() } Syslog('+', "Pass: process ticfiles (%s)", inbound); - if (!diskfree(CFG.freespace)) { + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort tic processing"); free(inbound); return -1; } @@ -128,7 +129,8 @@ int Tic() Syslog('+', "Detected upsalarm semafore, aborting tic processing"); break; } - if (!diskfree(CFG.freespace)) { + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, aborting tic processing"); rc = 0; break; } diff --git a/mbsebbs/mbuser.c b/mbsebbs/mbuser.c index 4150cbc7..bf7126bd 100644 --- a/mbsebbs/mbuser.c +++ b/mbsebbs/mbuser.c @@ -100,8 +100,10 @@ int main(int argc, char **argv) Syslog(' ', cmd); free(cmd); - if (!diskfree(CFG.freespace)) + if (enoughspace(CFG.freespace) == 0) { + Syslog('+', "Low diskspace, abort"); ExitClient(MBERR_DISK_FULL); + } if (lockprogram((char *)"mbuser")) { if (!do_quiet) diff --git a/mbsetup/m_farea.c b/mbsetup/m_farea.c index b787504f..217d9325 100644 --- a/mbsetup/m_farea.c +++ b/mbsetup/m_farea.c @@ -162,6 +162,7 @@ void CloseFilearea(int force) unlink(fout); chmod(fin, 0640); Syslog('+', "Updated \"fareas.data\""); + disk_reset(); if (!force) working(6, 0, 0); return; diff --git a/mbsetup/m_fgroup.c b/mbsetup/m_fgroup.c index 5e82a990..9b8dd228 100644 --- a/mbsetup/m_fgroup.c +++ b/mbsetup/m_fgroup.c @@ -197,6 +197,7 @@ void CloseFGroup(int force) fclose(fo); unlink(fout); chmod(fin, 0640); + disk_reset(); Syslog('+', "Updated \"fgroups.data\""); if (!force) working(6, 0, 0); diff --git a/mbsetup/m_global.c b/mbsetup/m_global.c index a90c2ccb..7e389438 100644 --- a/mbsetup/m_global.c +++ b/mbsetup/m_global.c @@ -1476,6 +1476,7 @@ void global_menu(void) if (crc != crc1) { if (yes_no((char *)"Configuration is changed, save") == 1) { cf_close(); + disk_reset(); Syslog('+', "Saved main config"); working(6, 0, 0); } diff --git a/mbsetup/m_hatch.c b/mbsetup/m_hatch.c index 3b34b092..7b171e2a 100644 --- a/mbsetup/m_hatch.c +++ b/mbsetup/m_hatch.c @@ -183,6 +183,7 @@ void CloseHatch(int force) fclose(fo); unlink(fout); chmod(fin, 0640); + disk_reset(); Syslog('+', "Updated \"hatch.data\""); if (!force) working(6, 0, 0); diff --git a/mbsetup/m_lang.c b/mbsetup/m_lang.c index 25d547c0..3b480a31 100644 --- a/mbsetup/m_lang.c +++ b/mbsetup/m_lang.c @@ -239,6 +239,7 @@ void CloseLanguage(int force) tidy_stlist(&lan); chmod(fin, 0640); Syslog('+', "Updated \"language.data\""); + disk_reset(); if (!force) working(6, 0, 0); return; diff --git a/mbsetup/m_magic.c b/mbsetup/m_magic.c index f6557abe..267c1d8a 100644 --- a/mbsetup/m_magic.c +++ b/mbsetup/m_magic.c @@ -174,6 +174,7 @@ void CloseMagics(int force) tidy_stlist(&mag); unlink(fout); chmod(fin, 0640); + disk_reset(); Syslog('+', "Updated \"magic.data\""); if (!force) working(6, 0, 0); diff --git a/mbsetup/m_marea.c b/mbsetup/m_marea.c index 96925077..4ef6600e 100644 --- a/mbsetup/m_marea.c +++ b/mbsetup/m_marea.c @@ -270,6 +270,7 @@ void CloseMsgarea(int Force) unlink(fout); chmod(fin, 0660); Syslog('+', "Updated \"mareas.data\""); + disk_reset(); if (!Force) working(6, 0, 0); return; diff --git a/mbsetup/m_mgroup.c b/mbsetup/m_mgroup.c index f88371f9..1cf9fab7 100644 --- a/mbsetup/m_mgroup.c +++ b/mbsetup/m_mgroup.c @@ -206,6 +206,7 @@ void CloseMGroup(int force) fclose(fo); unlink(fout); chmod(fin, 0640); + disk_reset(); Syslog('+', "Updated \"mgroups.data\""); if (!force) working(6, 0, 0); diff --git a/mbsetup/m_node.c b/mbsetup/m_node.c index f7cb25b7..62a7d146 100644 --- a/mbsetup/m_node.c +++ b/mbsetup/m_node.c @@ -259,6 +259,7 @@ void CloseNoderec(int Force) free(fin); free(fout); Syslog('+', "Updated \"nodes.data\""); + disk_reset(); CreateSema((char *)"scanout"); working(6, 0, 0); return; diff --git a/mbsetup/mutil.c b/mbsetup/mutil.c index c5f12899..198024f2 100644 --- a/mbsetup/mutil.c +++ b/mbsetup/mutil.c @@ -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;"); +} + + diff --git a/mbsetup/mutil.h b/mbsetup/mutil.h index ea78cecb..85747335 100644 --- a/mbsetup/mutil.h +++ b/mbsetup/mutil.h @@ -1,10 +1,12 @@ #ifndef _MUTIL_H #define _MUTIL_H +/* $Id$ */ + unsigned char readkey(int, int, int, int); unsigned char testkey(int, int); int newpage(FILE *, int); void addtoc(FILE *, FILE *, int, int, int, char *); +void disk_reset(void); #endif - diff --git a/mbtask/taskdisk.c b/mbtask/taskdisk.c index 0d162e69..9b15337e 100644 --- a/mbtask/taskdisk.c +++ b/mbtask/taskdisk.c @@ -34,11 +34,6 @@ #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 { struct _mfs_list *next; /* Linked list */ char *mountpoint; /* Mountpoint */ @@ -48,6 +43,12 @@ typedef struct _mfs_list { } mfs_list; 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]; mfs_list *tmp; unsigned long needed; + int rc; strtok(token, ","); needed = atol(strtok(NULL, ";")); - Syslog('d', "disk_check(%ld)", needed); if (! needed) { /* @@ -153,16 +154,24 @@ char *disk_check(char *token) 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) { if (tmp->avail < needed) { /* * 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"); return buf; } } + if ((rc = pthread_mutex_unlock(&a_mutex))) + Syslog('!', "disk_check() mutex_unlock failed rc=%d", rc); + /* * Enough space */ @@ -181,7 +190,7 @@ char *disk_getfs() static char buf[SS_BUFSIZE]; char tt[80], *ans = NULL; mfs_list *tmp; - int i = 0; + int rc, i = 0; buf[0] = '\0'; if (mfs == NULL) { @@ -189,6 +198,9 @@ char *disk_getfs() 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) { i++; if (ans == NULL) @@ -201,6 +213,8 @@ char *disk_getfs() if (i == 10) /* No more then 10 filesystems */ break; } + if ((rc = pthread_mutex_unlock(&a_mutex))) + Syslog('!', "disk_getfs() mutex_unlock failed rc=%d", rc); if (strlen(ans) > (SS_BUFSIZE - 8)) sprintf(buf, "100:0;"); @@ -223,6 +237,10 @@ void update_diskstat(void) struct statfs sfs; unsigned long temp; 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) { if (statfs(tmp->mountpoint, &sfs) == 0) { @@ -231,6 +249,9 @@ void update_diskstat(void) 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; char *temp; mfs_list *tmp; + int rc; Syslog('+', "Start disk thread"); disk_run = TRUE; @@ -348,6 +370,10 @@ void *disk_thread(void) if (disk_reread) { disk_reread = FALSE; Syslog('+', "Reread disk filesystems"); + + if ((rc = pthread_mutex_lock(&a_mutex))) + Syslog('!', "disk_thread() mutex_lock failed rc=%d", rc); + tidy_mfslist(&mfs); add_path(getenv("MBSE_ROOT")); @@ -489,6 +515,9 @@ void *disk_thread(void) for (tmp = mfs; tmp; tmp = tmp->next) { 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();