From owner-svn-src-all@FreeBSD.ORG Sat Apr 2 15:02:43 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5CAAE106566B; Sat, 2 Apr 2011 15:02:43 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 32F648FC18; Sat, 2 Apr 2011 15:02:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p32F2htK085659; Sat, 2 Apr 2011 15:02:43 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p32F2h3n085657; Sat, 2 Apr 2011 15:02:43 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201104021502.p32F2h3n085657@svn.freebsd.org> From: Edward Tomasz Napierala Date: Sat, 2 Apr 2011 15:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220279 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Apr 2011 15:02:43 -0000 Author: trasz Date: Sat Apr 2 15:02:42 2011 New Revision: 220279 URL: http://svn.freebsd.org/changeset/base/220279 Log: Add accounting for RACCT_NPTS. Modified: head/sys/kern/tty_pts.c Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sat Apr 2 11:10:36 2011 (r220278) +++ head/sys/kern/tty_pts.c Sat Apr 2 15:02:42 2011 (r220279) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -682,6 +683,7 @@ ptsdrv_free(void *softc) free_unr(pts_pool, psc->pts_unit); chgptscnt(psc->pts_cred->cr_ruidinfo, -1, 0); + racct_sub_cred(psc->pts_cred, RACCT_NPTS, 1); crfree(psc->pts_cred); knlist_destroy(&psc->pts_inpoll.si_note); @@ -712,7 +714,7 @@ static int pts_alloc(int fflags, struct thread *td, struct file *fp) { - int unit, ok; + int unit, ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; @@ -720,14 +722,23 @@ pts_alloc(int fflags, struct thread *td, /* Resource limiting. */ PROC_LOCK(p); + error = racct_add(p, RACCT_NPTS, 1); + if (error != 0) { + PROC_UNLOCK(p); + return (EAGAIN); + } ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(p, RLIMIT_NPTS)); - PROC_UNLOCK(p); - if (!ok) + if (!ok) { + racct_sub(p, RACCT_NPTS, 1); + PROC_UNLOCK(p); return (EAGAIN); + } + PROC_UNLOCK(p); /* Try to allocate a new pts unit number. */ unit = alloc_unr(pts_pool); if (unit < 0) { + racct_sub(p, RACCT_NPTS, 1); chgptscnt(cred->cr_ruidinfo, -1, 0); return (EAGAIN); } @@ -757,7 +768,7 @@ int pts_alloc_external(int fflags, struct thread *td, struct file *fp, struct cdev *dev, const char *name) { - int ok; + int ok, error; struct tty *tp; struct pts_softc *psc; struct proc *p = td->td_proc; @@ -765,10 +776,18 @@ pts_alloc_external(int fflags, struct th /* Resource limiting. */ PROC_LOCK(p); + error = racct_add(p, RACCT_NPTS, 1); + if (error != 0) { + PROC_UNLOCK(p); + return (EAGAIN); + } ok = chgptscnt(cred->cr_ruidinfo, 1, lim_cur(p, RLIMIT_NPTS)); - PROC_UNLOCK(p); - if (!ok) + if (!ok) { + racct_sub(p, RACCT_NPTS, 1); + PROC_UNLOCK(p); return (EAGAIN); + } + PROC_UNLOCK(p); /* Allocate TTY and softc. */ psc = malloc(sizeof(struct pts_softc), M_PTS, M_WAITOK|M_ZERO);