Date: Thu, 21 Aug 2008 17:42:56 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 148018 for review Message-ID: <200808211742.m7LHgu0Z072770@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <sys/malloc.h> #include <sys/module.h> #include <sys/snoop.h> +#include <sys/sx.h> #include <sys/systm.h> #include <sys/tty.h> 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' }, };
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808211742.m7LHgu0Z072770>