From owner-svn-src-head@FreeBSD.ORG Sat Apr 25 10:05:55 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A0ACB106564A; Sat, 25 Apr 2009 10:05:55 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 85AB48FC14; Sat, 25 Apr 2009 10:05:55 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n3PA5t6K048495; Sat, 25 Apr 2009 10:05:55 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n3PA5t3M048493; Sat, 25 Apr 2009 10:05:55 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200904251005.n3PA5t3M048493@svn.freebsd.org> From: Ed Schouten Date: Sat, 25 Apr 2009 10:05:55 +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: r191484 - in head: share/man/man4 sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Apr 2009 10:05:56 -0000 Author: ed Date: Sat Apr 25 10:05:55 2009 New Revision: 191484 URL: http://svn.freebsd.org/changeset/base/191484 Log: Turn MAXPTSDEVS into a sysctl tunable. This allows users to increase the maximum amount of pseudo-terminals without changing any source code. Users must increase UT_LINESIZE before attempting to increase kern.pts_maxdev. Modified: head/share/man/man4/pts.4 head/sys/kern/tty_pts.c Modified: head/share/man/man4/pts.4 ============================================================================== --- head/share/man/man4/pts.4 Sat Apr 25 06:20:34 2009 (r191483) +++ head/share/man/man4/pts.4 Sat Apr 25 10:05:55 2009 (r191484) @@ -156,6 +156,26 @@ though .It Pa /dev/pts/[num] Pseudo-terminal slave devices. .El +.Sh SYSCTL VARIABLES +The following +.Xr sysctl 8 +variables can be used to modify or monitor +.Nm +behavior. +.Bl -tag -width indent +.It Va kern.pts_maxdev +Highest pseudo-terminal unit number to be allocated. +Because +.Xr utmp 5 +is restricted to an 8-byte line name size, +.Nm +will not create any pseudo-terminals with a unit number above 999 by +default. +After increasing +.Dv UT_LINESIZE , +this variable can be changed to allow more than 1000 pseudo-terminals to +be allocated simultaneously. +.El .Sh DIAGNOSTICS None. .Sh SEE ALSO Modified: head/sys/kern/tty_pts.c ============================================================================== --- head/sys/kern/tty_pts.c Sat Apr 25 06:20:34 2009 (r191483) +++ head/sys/kern/tty_pts.c Sat Apr 25 10:05:55 2009 (r191484) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -58,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -66,8 +68,16 @@ __FBSDID("$FreeBSD$"); #include +/* + * Our utmp(5) format is limited to 8-byte TTY line names. This means + * we can at most allocate 1000 pseudo-terminals ("pts/999"). Allow + * users to increase this number, assuming they have manually increased + * UT_LINESIZE. + */ static struct unrhdr *pts_pool; -#define MAXPTSDEVS 999 +static unsigned int pts_maxdev = 999; +SYSCTL_UINT(_kern, OID_AUTO, pts_maxdev, CTLFLAG_RW, &pts_maxdev, 0, + "Maximum amount of pts(4) pseudo-terminals"); static MALLOC_DEFINE(M_PTS, "pts", "pseudo tty device"); @@ -716,6 +726,11 @@ pts_alloc(int fflags, struct thread *td, chgptscnt(uid, -1, 0); return (EAGAIN); } + if (unit > pts_maxdev) { + free_unr(pts_pool, unit); + chgptscnt(uid, -1, 0); + return (EAGAIN); + } /* Allocate TTY and softc. */ psc = malloc(sizeof(struct pts_softc), M_PTS, M_WAITOK|M_ZERO); @@ -829,7 +844,7 @@ static void pts_init(void *unused) { - pts_pool = new_unrhdr(0, MAXPTSDEVS, NULL); + pts_pool = new_unrhdr(0, INT_MAX, NULL); #if defined(PTS_COMPAT) || defined(PTS_LINUX) make_dev(&ptmx_cdevsw, 0, UID_ROOT, GID_WHEEL, 0666, "ptmx"); #endif /* PTS_COMPAT || PTS_LINUX */