From 0b79af2b86d86030af9f29255d167bdd5a136aae Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Sun, 25 Jan 2009 14:29:30 +0000 Subject: If hdattach() aborts early because the disk is not in good shape, always fail hdopen(). --- sys/arch/hp300/dev/hd.c | 11 +++++++++-- 1 file 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); -- cgit v1.2.3