diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-01-25 14:29:30 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-01-25 14:29:30 +0000 |
commit | 0b79af2b86d86030af9f29255d167bdd5a136aae (patch) | |
tree | 81c7f23b2573a6c03bf4639c3dbb734292dc7cfd | |
parent | b5e555d74e0afb8034aeadb0592d030b4860556a (diff) |
If hdattach() aborts early because the disk is not in good shape, always
fail hdopen().
-rw-r--r-- | sys/arch/hp300/dev/hd.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/arch/hp300/dev/hd.c b/sys/arch/hp300/dev/hd.c index e5e2e2f01ee..378270a69b9 100644 --- a/sys/arch/hp300/dev/hd.c +++ b/sys/arch/hp300/dev/hd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hd.c,v 1.54 2008/10/15 19:12:20 blambert Exp $ */ +/* $OpenBSD: hd.c,v 1.55 2009/01/25 14:29:29 miod Exp $ */ /* $NetBSD: rd.c,v 1.33 1997/07/10 18:14:08 kleink Exp $ */ /* @@ -292,7 +292,6 @@ hdattach(parent, self, aux) /* * Initialize and attach the disk structure. */ - bzero(&sc->sc_dkdev, sizeof(sc->sc_dkdev)); sc->sc_dkdev.dk_name = sc->sc_dev.dv_xname; disk_attach(&sc->sc_dkdev); @@ -546,6 +545,14 @@ hdopen(dev, flags, mode, p) if (rs == NULL) return (ENXIO); + /* + * Fail open if we tried to attach but the disk did not answer. + */ + if (!ISSET(rs->sc_dkdev.dk_flags, DKF_CONSTRUCTED)) { + device_unref(&rs->sc_dev); + return (error); + } + if ((error = hdlock(rs)) != 0) { device_unref(&rs->sc_dev); return (error); |