Provide some anti-footshooting. Don't allow the user to set the interval

for acctwatch() runs to be negative or zero as this could result in either
a possible hang (or panic if INVARIANTS is on).  Previously the accounting
code handled the <= 0 case by calling acctwatch on every clock tick (eww!)
due to an implementation detail of callout_reset().  (Tick counts of
<= 0 are converted to 1).

MFC after:	3 days
This commit is contained in:
John Baldwin 2006-02-07 18:59:47 +00:00
parent 37a395c110
commit 222fdf4bff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=155438

View File

@ -122,8 +122,29 @@ SYSCTL_INT(_kern, OID_AUTO, acct_resume, CTLFLAG_RW,
&acctresume, 0, "percentage of free disk space above which accounting resumes");
static int acctchkfreq = 15; /* frequency (in seconds) to check space */
SYSCTL_INT(_kern, OID_AUTO, acct_chkfreq, CTLFLAG_RW,
&acctchkfreq, 0, "frequency for checking the free space");
static int
sysctl_acct_chkfreq(SYSCTL_HANDLER_ARGS)
{
int error, value;
/* Write out the old value. */
error = SYSCTL_OUT(req, &acctchkfreq, sizeof(int));
if (error || req->newptr == NULL)
return (error);
/* Read in and verify the new value. */
error = SYSCTL_IN(req, &value, sizeof(int));
if (error)
return (error);
if (value <= 0)
return (EINVAL);
acctchkfreq = value;
return (0);
}
SYSCTL_PROC(_kern, OID_AUTO, acct_chkfreq, CTLTYPE_INT|CTLFLAG_RW,
&acctchkfreq, 0, sysctl_acct_chkfreq, "I",
"frequency for checking the free space");
SYSCTL_INT(_kern, OID_AUTO, acct_suspended, CTLFLAG_RD, &acct_suspended, 0,
"Accounting suspended or not");