summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_acct.c
diff options
context:
space:
mode:
authorgrehan <grehan@FreeBSD.org>2013-07-05 05:47:10 +0000
committergrehan <grehan@FreeBSD.org>2013-07-05 05:47:10 +0000
commit6a7baaf83640e0eaa135d2f7a3c1d4401f1683bf (patch)
tree83ae82cf8f72af4b819f49aa52acdd97f74c6328 /sys/kern/kern_acct.c
parent2cb5a953f0a60811764ccaca7c37b51ff007c711 (diff)
parent8e6b84b998690dcfc1a4957dc7a483ac5b600db8 (diff)
downloadFreeBSD-src-6a7baaf83640e0eaa135d2f7a3c1d4401f1683bf.zip
FreeBSD-src-6a7baaf83640e0eaa135d2f7a3c1d4401f1683bf.tar.gz
IFC @ r252763
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r--sys/kern/kern_acct.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index 3362112..ef3fd2e 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -133,6 +133,7 @@ static int acct_configured;
static int acct_suspended;
static struct vnode *acct_vp;
static struct ucred *acct_cred;
+static struct plimit *acct_limit;
static int acct_flags;
static struct sx acct_sx;
@@ -196,7 +197,7 @@ int
sys_acct(struct thread *td, struct acct_args *uap)
{
struct nameidata nd;
- int error, flags, replacing;
+ int error, flags, i, replacing;
error = priv_check(td, PRIV_ACCT);
if (error)
@@ -267,6 +268,15 @@ sys_acct(struct thread *td, struct acct_args *uap)
}
/*
+ * Create our own plimit object without limits. It will be assigned
+ * to exiting processes.
+ */
+ acct_limit = lim_alloc();
+ for (i = 0; i < RLIM_NLIMITS; i++)
+ acct_limit->pl_rlimit[i].rlim_cur =
+ acct_limit->pl_rlimit[i].rlim_max = RLIM_INFINITY;
+
+ /*
* Save the new accounting file vnode, and schedule the new
* free space watcher.
*/
@@ -284,12 +294,7 @@ sys_acct(struct thread *td, struct acct_args *uap)
error = kproc_create(acct_thread, NULL, NULL, 0, 0,
"accounting");
if (error) {
- (void) vn_close(acct_vp, acct_flags, acct_cred, td);
- crfree(acct_cred);
- acct_configured = 0;
- acct_vp = NULL;
- acct_cred = NULL;
- acct_flags = 0;
+ (void) acct_disable(td, 0);
sx_xunlock(&acct_sx);
log(LOG_NOTICE, "Unable to start accounting thread\n");
return (error);
@@ -314,6 +319,7 @@ acct_disable(struct thread *td, int logging)
sx_assert(&acct_sx, SX_XLOCKED);
error = vn_close(acct_vp, acct_flags, acct_cred, td);
crfree(acct_cred);
+ lim_free(acct_limit);
acct_configured = 0;
acct_vp = NULL;
acct_cred = NULL;
@@ -334,7 +340,7 @@ acct_process(struct thread *td)
{
struct acctv2 acct;
struct timeval ut, st, tmp;
- struct plimit *newlim, *oldlim;
+ struct plimit *oldlim;
struct proc *p;
struct rusage ru;
int t, ret;
@@ -410,7 +416,6 @@ acct_process(struct thread *td)
/* (8) The boolean flags that tell how the process terminated, etc. */
acct.ac_flagx = p->p_acflag;
- PROC_UNLOCK(p);
/* Setup ancillary structure fields. */
acct.ac_flagx |= ANVER;
@@ -419,14 +424,10 @@ acct_process(struct thread *td)
acct.ac_len = acct.ac_len2 = sizeof(acct);
/*
- * Eliminate any file size rlimit.
+ * Eliminate rlimits (file size limit in particular).
*/
- newlim = lim_alloc();
- PROC_LOCK(p);
oldlim = p->p_limit;
- lim_copy(newlim, oldlim);
- newlim->pl_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
- p->p_limit = newlim;
+ p->p_limit = lim_hold(acct_limit);
PROC_UNLOCK(p);
lim_free(oldlim);
OpenPOWER on IntegriCloud