From owner-p4-projects@FreeBSD.ORG Thu Aug 21 17:43:02 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0021F1065716; Thu, 21 Aug 2008 17:43:01 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B79F31065705 for ; Thu, 21 Aug 2008 17:43:01 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A41AA8FC26 for ; Thu, 21 Aug 2008 17:43:01 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7LHh1b2072783 for ; Thu, 21 Aug 2008 17:43:01 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7LHgu0Z072770 for perforce@freebsd.org; Thu, 21 Aug 2008 17:42:56 GMT (envelope-from ed@FreeBSD.org) Date: Thu, 21 Aug 2008 17:42:56 GMT Message-Id: <200808211742.m7LHgu0Z072770@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 148018 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 17:43:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=148018 Change 148018 by ed@ed_flippo on 2008/08/21 17:42:30 Reintroduce the 's' state in pstat(8) to indicate a TTY is being snooped. While there, change the mutex used to lock down hook registration to a sx(9). Because TTY's can be locked down by Giant, it is not possible to lock registration down with a non-sleepable lock. Affected files ... .. //depot/projects/mpsafetty/sys/dev/snp/snp.c#4 edit .. //depot/projects/mpsafetty/sys/kern/tty.c#25 edit .. //depot/projects/mpsafetty/usr.sbin/pstat/pstat.8#5 edit .. //depot/projects/mpsafetty/usr.sbin/pstat/pstat.c#7 edit Differences ... ==== //depot/projects/mpsafetty/sys/dev/snp/snp.c#4 (text+ko) ==== @@ -33,13 +33,15 @@ #include #include #include +#include #include #include static struct cdev *snp_dev; -static struct mtx snp_register_mtx; -MTX_SYSINIT(snp_register_mtx, &snp_register_mtx, - "tty snoop registration", MTX_DEF); +static struct sx snp_register_lock; +/* XXX: should be mtx, but TTY can be locked by Giant */ +SX_SYSINIT(snp_register_lock, &snp_register_lock, + "tty snoop registration"); static MALLOC_DEFINE(M_SNP, "snp", "tty snoop device"); static d_open_t snp_open; @@ -111,14 +113,14 @@ switch (cmd) { case SNPSTTY: /* Bind TTY to snoop instance */ - mtx_lock(&snp_register_mtx); + sx_xlock(&snp_register_lock); if (ss->snp_tty != NULL) { - mtx_unlock(&snp_register_mtx); + sx_xunlock(&snp_register_lock); return (EBUSY); } error = ttyhook_register(&ss->snp_tty, td, *(int *)data, &snp_hook, ss); - mtx_unlock(&snp_register_mtx); + sx_xunlock(&snp_register_lock); return (error); case SNPGTTY: /* Obtain device number of associated TTY */ ==== //depot/projects/mpsafetty/sys/kern/tty.c#25 (text+ko) ==== @@ -1758,6 +1758,7 @@ { TF_EXCLUDE, 'X' }, { TF_BYPASS, 'l' }, { TF_ZOMBIE, 'Z' }, + { TF_HOOK, 's' }, { 0, '\0' }, }; ==== //depot/projects/mpsafetty/usr.sbin/pstat/pstat.8#5 (text+ko) ==== @@ -202,6 +202,8 @@ block mode input routine in use .It Z connection lost +.It s +i/o being snooped .El .Pp The ==== //depot/projects/mpsafetty/usr.sbin/pstat/pstat.c#7 (text+ko) ==== @@ -312,6 +312,7 @@ { TF_EXCLUDE, 'X' }, { TF_BYPASS, 'l' }, { TF_ZOMBIE, 'Z' }, + { TF_HOOK, 's' }, { 0, '\0' }, };