Commit bad50ed8 authored by rswindell's avatar rswindell
Browse files

Added a "MinFreeDiskSpace" setting to the root section of sbbsecho.ini

(defaults to 10 megabytes, "10M").
When SBBSecho starts up, if this minimum amount of free space is not
available in any of the following directories, SBBSecho will display an
error and immediately exit:
- data directory (in SCFG)
- logs directory (in SCFG)
- netmail directory (in SCFG)
- outbound directory (from sbbsecho.ini)
- temp directory
- each linked-node's outbox, if configured

If the sysop runs out of disk space for some reason, at least SBBSecho
won't contribute to the problem.
parent 9192bd8f
......@@ -79,6 +79,8 @@ void global_settings(void)
sprintf(opt[i++], "%-25s %s", "Log Timestamp Format", cfg.logtime);
sprintf(opt[i++], "%-25s %s", "Strict Packet Passwords", cfg.strict_packet_passwords ? "Enabled" : "Disabled");
sprintf(opt[i++], "%-25s %u", "Config File Backups", cfg.cfgfile_backups);
sprintf(opt[i++], "%-25s %s bytes", "Minimum Free Disk Space"
, byte_count_to_str(cfg.min_free_diskspace, str, sizeof(str)));
sprintf(opt[i++], "%-25s %s", "BSY Mutex File Timeout", duration_to_vstr(cfg.bsy_timeout, duration, sizeof(duration)));
if(cfg.flo_mailer) {
sprintf(opt[i++], "%-25s %s", "BSO Lock Attempt Delay", duration_to_vstr(cfg.bso_lock_delay, duration, sizeof(duration)));
......@@ -119,6 +121,11 @@ void global_settings(void)
" SBBSecho configuration file (e.g. `sbbsecho.ini`) that will be\n"
" maintained by FidoNet Config (`echocfg`) and SBBSecho AreaFix.\n"
"\n"
"`Minimum Free Disk Space` determines the minimum amount of free disk\n"
" space for SBBSecho to run. SBBSecho will just exit with an error\n"
" message (and an error level of 1) if the minimum amount of free\n"
" space is not found in directories into which SBBSecho may write.\n"
"\n"
"`BSY Mutex File Timeout` determines the maximum age of an existing\n"
" mutex file (`*.bsy`) before SBBSecho will act as though the mutex\n"
" file was not present. This setting applies to the global\n"
......@@ -185,29 +192,35 @@ void global_settings(void)
break;
case 5:
byte_count_to_str(cfg.min_free_diskspace, str, sizeof(str));
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Minimum Free Disk Space (in bytes)", str, 10, K_EDIT) > 0)
cfg.min_free_diskspace = parse_byte_count(str, 1);
break;
case 6:
duration_to_vstr(cfg.bsy_timeout, duration, sizeof(duration));
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "BSY Mutex File Timeout", duration, 10, K_EDIT) > 0)
cfg.bsy_timeout = (ulong)parse_duration(duration);
break;
case 6:
case 7:
duration_to_vstr(cfg.bso_lock_delay, duration, sizeof(duration));
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Delay Between BSO Lock Attempts", duration, 10, K_EDIT) > 0)
cfg.bso_lock_delay = (ulong)parse_duration(duration);
break;
case 7:
case 8:
sprintf(str, "%lu", cfg.bso_lock_attempts);
if(uifc.input(WIN_MID|WIN_SAV, 0, 0, "Maximum BSO Lock Attempts", str, 5, K_EDIT|K_NUMBER) > 0)
cfg.bso_lock_attempts = atoi(str);
break;
case 8:
case 9:
uifc.input(WIN_MID|WIN_SAV,0,0
,"BinkP Capabilities (BinkIT)", cfg.binkp_caps, sizeof(cfg.binkp_caps)-1, K_EDIT);
break;
case 9:
case 10:
uifc.input(WIN_MID|WIN_SAV,0,0
,"BinkP Sysop Name (BinkIT)", cfg.binkp_sysop, sizeof(cfg.binkp_sysop)-1, K_EDIT);
break;
......@@ -587,7 +600,7 @@ int main(int argc, char **argv)
"\n"
"The `Archive Types` sub-menu is where you configure your archive\n"
"programs (a.k.a. \"packers\") used for the packing and unpacking of\n"
"EchoMail bundle files (usually in 'zip' format).\n"
"EchoMail bundle files (usually in 'PKZIP' format).\n"
"\n"
"The `NetMail Settings` sub-menu is where you configure settings specific\n"
"to NetMail (private one-on-one networked mail).\n"
......
......@@ -227,6 +227,7 @@ void get_default_echocfg(sbbsecho_cfg_t* cfg)
cfg->areafile_backups = 100;
cfg->cfgfile_backups = 100;
cfg->auto_add_subs = true;
cfg->min_free_diskspace = 10*1024*1024;
}
char* pktTypeStringList[] = {"2+", "2e", "2.2", "2", NULL}; // Must match enum pkt_type
......@@ -275,6 +276,7 @@ bool sbbsecho_read_ini(sbbsecho_cfg_t* cfg)
cfg->umask = iniGetInteger(ini, ROOT_SECTION, "umask", cfg->umask);
cfg->areafile_backups = iniGetInteger(ini, ROOT_SECTION, "AreaFileBackups", cfg->areafile_backups);
cfg->cfgfile_backups = iniGetInteger(ini, ROOT_SECTION, "CfgFileBackups", cfg->cfgfile_backups);
cfg->min_free_diskspace = iniGetBytes(ini, ROOT_SECTION, "MinFreeDiskSpace", 1, cfg->min_free_diskspace);
/* EchoMail options: */
cfg->maxbdlsize = (ulong)iniGetBytes(ini, ROOT_SECTION, "BundleSize", 1, cfg->maxbdlsize);
......@@ -482,6 +484,7 @@ bool sbbsecho_write_ini(sbbsecho_cfg_t* cfg)
iniSetString(&ini, ROOT_SECTION, "AreaFile" ,cfg->areafile ,NULL);
iniSetInteger(&ini, ROOT_SECTION, "AreaFileBackups" ,cfg->areafile_backups ,NULL);
iniSetInteger(&ini, ROOT_SECTION, "CfgFileBackups" ,cfg->cfgfile_backups ,NULL);
iniSetBytes(&ini, ROOT_SECTION, "MinFreeDiskSpace" ,1,cfg->min_free_diskspace ,NULL);
iniSetString(&ini, ROOT_SECTION, "BadAreaFile" ,cfg->badareafile ,NULL);
iniSetString(&ini, ROOT_SECTION, "EchoStats" ,cfg->echostats ,NULL);
if(cfg->logfile[0])
......
......@@ -5898,6 +5898,19 @@ void import_packets(const char* inbound, nodecfg_t* inbox, bool secure)
globfree(&g);
}
void check_free_diskspace(const char* path)
{
if(cfg.min_free_diskspace) {
ulong freek = getfreediskspace(path, 1024);
if(freek < cfg.min_free_diskspace / 1024) {
fprintf(stderr, "!Insufficient free disk space (%luK < %"PRId64"K bytes) in %s\n"
, freek, cfg.min_free_diskspace / 1024, path);
bail(1);
}
}
}
/***********************************/
/* Synchronet/FidoNet Message util */
/***********************************/
......@@ -6138,12 +6151,14 @@ int main(int argc, char **argv)
bail(1);
}
backslash(cfg.temp_dir);
char* inbound = FULLPATH(NULL, cfg.inbound, sizeof(cfg.inbound)-1);
if(inbound != NULL) {
SAFECOPY(cfg.inbound, inbound);
free(inbound);
}
backslash(cfg.inbound);
if(cfg.secure_inbound[0]) {
char* secure_inbound = FULLPATH(NULL, cfg.secure_inbound, sizeof(cfg.secure_inbound)-1);
if(secure_inbound != NULL) {
......@@ -6152,15 +6167,24 @@ int main(int argc, char **argv)
}
backslash(cfg.secure_inbound);
}
backslash(cfg.temp_dir);
char* outbound = FULLPATH(NULL, cfg.outbound, sizeof(cfg.outbound)-1);
if(outbound != NULL) {
SAFECOPY(cfg.outbound, outbound);
free(outbound);
}
check_free_diskspace(scfg.data_dir);
check_free_diskspace(scfg.logs_dir);
check_free_diskspace(scfg.netmail_dir);
check_free_diskspace(cfg.outbound);
check_free_diskspace(cfg.temp_dir);
for(uint u=0; u<cfg.nodecfgs; u++) {
if(cfg.nodecfg[u].inbox[0])
backslash(cfg.nodecfg[u].inbox);
if(cfg.nodecfg[u].outbox[0])
check_free_diskspace(cfg.nodecfg[u].outbox);
}
truncsp(cmdline);
......
......@@ -213,6 +213,7 @@ typedef struct {
ulong bso_lock_delay; /* in seconds */
ulong max_netmail_age;
ulong max_echomail_age;
int64_t min_free_diskspace;
struct fido_domain* domain_list;
unsigned domain_count;
char binkp_caps[64];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment