From a2c68c62dba7acc1de5dd6a6141484d9c12844fe Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 25 Sep 1999 16:21:39 +0000 Subject: This patch clears the way for removing a number of tty related fields in struct cdevsw: d_stop moved to struct tty. d_reset already unused. d_devtotty linkage now provided by dev_t->si_tty. These fields will be removed from struct cdevsw together with d_params and d_maxio Real Soon Now. The changes in this patch consist of: initialize dev->si_tty in *_open() initialize tty->t_stop remove devtotty functions rename ttpoll to ttypoll a few adjustments to these changes in the generic code a bump of __FreeBSD_version add a couple of FreeBSD tags --- sys/miscfs/specfs/spec_vnops.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'sys/miscfs/specfs/spec_vnops.c') diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index e8a2163..5c003f9 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -167,15 +168,16 @@ spec_open(ap) if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV)) return (ENXIO); + dsw = devsw(dev); + if ( (dsw == NULL) || (dsw->d_open == NULL)) + return ENXIO; + /* Make this field valid before any I/O in ->d_open */ if (!dev->si_iosize_max) dev->si_iosize_max = DFLTPHYS; switch (vp->v_type) { case VCHR: - dsw = devsw(dev); - if ( (dsw == NULL) || (dsw->d_open == NULL)) - return ENXIO; if (ap->a_cred != FSCRED && (ap->a_mode & FWRITE)) { /* * When running in very secure mode, do not allow @@ -208,9 +210,6 @@ spec_open(ap) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p); break; case VBLK: - dsw = devsw(dev); - if ( (dsw == NULL) || (dsw->d_open == NULL)) - return ENXIO; /* * When running in very secure mode, do not allow * opens for writing of any disk block devices. @@ -230,10 +229,26 @@ spec_open(ap) error = (*dsw->d_open)(dev, ap->a_mode, S_IFBLK, p); break; default: - error = 0; + error = ENXIO; break; } + if (error) + return (error); + + if (dsw->d_flags & D_TTY) { + if (!dev->si_tty) { + printf("Warning:%s: no si_tty\n", devtoname(dev)); + } else { + struct tty *tp; + tp = dev->si_tty; + if (!tp->t_stop) { + printf("Warning:%s: no t_stop, using nostop\n", devtoname(dev)); + tp->t_stop = nostop; + } + } + } + if (vn_isdisk(vp)) { if (!dev->si_bsize_phys) dev->si_bsize_phys = DEV_BSIZE; -- cgit v1.1