Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej-devvp]: src/sys/dev/wscons Use VOP_OPEN in a few cases where it'...



details:   https://anonhg.NetBSD.org/src/rev/49069f7ccc6c
branches:  thorpej-devvp
changeset: 514612:49069f7ccc6c
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Thu Sep 20 11:15:04 2001 +0000

description:
Use VOP_OPEN in a few cases where it's more appropriate to do so (to
gracefully handle dead vnodes).

diffstat:

 sys/dev/wscons/wsmux.c |  35 ++++++++++++++++++++++++++---------
 1 files changed, 26 insertions(+), 9 deletions(-)

diffs (80 lines):

diff -r 0fa61d1b0631 -r 49069f7ccc6c sys/dev/wscons/wsmux.c
--- a/sys/dev/wscons/wsmux.c    Wed Sep 19 16:50:34 2001 +0000
+++ b/sys/dev/wscons/wsmux.c    Thu Sep 20 11:15:04 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wsmux.c,v 1.9.8.2 2001/09/18 19:13:52 fvdl Exp $       */
+/*     $NetBSD: wsmux.c,v 1.9.8.3 2001/09/20 11:15:04 fvdl Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -218,6 +218,7 @@
 {
        struct wsmux_softc *sc;
        struct wsplink *m;
+       struct vnode *vp2;
        int unit, error, nopen, lasterror;
 
        unit = minor(devvp->v_rdev);
@@ -252,9 +253,15 @@
                        KASSERT(m->sc_pdevvp == NULL);
                        error = cdevvp(makedev(m->pmajor, m->sc->dv_unit),
                            &m->sc_pdevvp);
-                       if (error == 0)
-                               error = m->sc_ops->dopen(m->sc_pdevvp, flags,
-                                   mode, p);
+                       if (error == 0) {
+                               vp2 = NULL;
+                               error = VOP_OPEN(m->sc_pdevvp, flags,
+                                   p->p_ucred, p, &vp2);
+                               if (error == 0 && vp2 != NULL) {
+                                       vput(m->sc_pdevvp);
+                                       m->sc_pdevvp = vp2;
+                               }
+                       }
                        if (error) {
                                /* Ignore opens that fail */
                                lasterror = error;
@@ -263,6 +270,7 @@
                                DPRINTF(("wsmuxopen: open failed %d\n", 
                                         error));
                        } else {
+                               VOP_UNLOCK(m->sc_pdevvp, 0);
                                nopen++;
                                *m->sc_muxp = sc;
                        }
@@ -399,6 +407,7 @@
        int pmajor;
 {
        struct wsplink *m;
+       struct vnode *vp2;
        int error;
 
        DPRINTF(("wsmux_attach_sc: %s: type=%d dsc=%p, *psp=%p\n",
@@ -446,14 +455,22 @@
                /* mux already open, join in */
                error = cdevvp(makedev(m->pmajor, m->sc->dv_unit),
                    &m->sc_pdevvp);
-               if (error == 0)
-                       error = m->sc_ops->dopen(m->sc_pdevvp, sc->sc_flags,
-                           sc->sc_mode, sc->sc_p);
+               if (error == 0) {
+                       vp2 = NULL;
+                       error = VOP_OPEN(m->sc_pdevvp, sc->sc_flags,
+                           sc->sc_p->p_ucred, sc->sc_p, &vp2);
+                       if (error == 0 && vp2 != NULL) {
+                               vput(m->sc_pdevvp);
+                               m->sc_pdevvp = vp2;
+                       }
+               }
                if (error) {
-                       vrele(m->sc_pdevvp);
+                       vput(m->sc_pdevvp);
                        m->sc_pdevvp = NULL;
-               } else
+               } else {
+                       VOP_UNLOCK(m->sc_pdevvp, 0);
                        *m->sc_muxp = sc;
+               }
        } else {
                DPRINTF(("wsmux_attach_sc: %s not open\n",
                         sc->sc_dv.dv_xname));



Home | Main Index | Thread Index | Old Index