Return ENODEV instead of EIO when we are trying to open a device without media
in the drive. restrict "opening of empty drive" to character devices only (reading a block device returns a short read instead of ENODEV, which can lead to confusion).
This commit is contained in:
parent
15afeeecca
commit
12868a7d80
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cd.c,v 1.119 1999/01/26 13:59:44 bouyer Exp $ */
|
||||
/* $NetBSD: cd.c,v 1.120 1999/01/29 11:17:58 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -257,7 +257,8 @@ cdopen(dev, flag, fmt, p)
|
||||
* If any partition is open, but the disk has been invalidated,
|
||||
* disallow further opens.
|
||||
*/
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0 &&
|
||||
(part != RAW_PART || fmt != S_IFCHR )) {
|
||||
error = EIO;
|
||||
goto bad3;
|
||||
}
|
||||
@ -282,7 +283,7 @@ cdopen(dev, flag, fmt, p)
|
||||
SC_DEBUG(sc_link, SDEV_DB1,
|
||||
("cdopen: scsipi_start, error=%d\n", error));
|
||||
if (error) {
|
||||
if (part != RAW_PART)
|
||||
if (part != RAW_PART || fmt != S_IFCHR)
|
||||
goto bad3;
|
||||
else
|
||||
goto out;
|
||||
@ -420,7 +421,10 @@ cdstrategy(bp)
|
||||
* maybe the media changed
|
||||
*/
|
||||
if ((cd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
bp->b_error = EIO;
|
||||
if (cd->sc_link->flags & SDEV_OPEN)
|
||||
bp->b_error = EIO;
|
||||
else
|
||||
bp->b_error = ENODEV;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
@ -529,7 +533,7 @@ cdstart(v)
|
||||
dp->b_actf = bp->b_actf;
|
||||
|
||||
/*
|
||||
* If the deivce has become invalid, abort all the
|
||||
* If the device has become invalid, abort all the
|
||||
* reads and writes until all files have been closed and
|
||||
* re-opened
|
||||
*/
|
||||
@ -730,6 +734,7 @@ cdioctl(dev, cmd, addr, flag, p)
|
||||
case CDIOCSETLEFT:
|
||||
case CDIOCSETRIGHT:
|
||||
case CDIOCCLOSE:
|
||||
case CDIOCEJECT:
|
||||
case CDIOCALLOW:
|
||||
case CDIOCPREVENT:
|
||||
case CDIOCSETDEBUG:
|
||||
@ -741,7 +746,10 @@ cdioctl(dev, cmd, addr, flag, p)
|
||||
break;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
return (EIO);
|
||||
if ((cd->sc_link->flags & SDEV_OPEN) == 0)
|
||||
return (ENODEV);
|
||||
else
|
||||
return (EIO);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: scsipi_base.c,v 1.18 1999/01/19 10:57:11 bouyer Exp $ */
|
||||
/* $NetBSD: scsipi_base.c,v 1.19 1999/01/29 11:17:59 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -287,9 +287,13 @@ scsipi_interpret_sense(xs)
|
||||
sc_link->flags &= ~SDEV_MEDIA_LOADED;
|
||||
if ((xs->flags & SCSI_IGNORE_NOT_READY) != 0)
|
||||
return (0);
|
||||
if (sense->add_sense_code == 0x3A &&
|
||||
sense->add_sense_code_qual == 0x00)
|
||||
error = ENODEV; /* Medium not present */
|
||||
else
|
||||
error = EIO;
|
||||
if ((xs->flags & SCSI_SILENT) != 0)
|
||||
return (EIO);
|
||||
error = EIO;
|
||||
return (error);
|
||||
break;
|
||||
case SKEY_ILLEGAL_REQUEST:
|
||||
if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sd.c,v 1.140 1999/01/26 13:59:44 bouyer Exp $ */
|
||||
/* $NetBSD: sd.c,v 1.141 1999/01/29 11:17:59 bouyer Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
@ -297,7 +297,7 @@ sdopen(dev, flag, fmt, p)
|
||||
* disallow further opens of non-raw partition
|
||||
*/
|
||||
if ((sc_link->flags & SDEV_MEDIA_LOADED) == 0 &&
|
||||
part != RAW_PART) {
|
||||
(part != RAW_PART || fmt != S_IFCHR)) {
|
||||
error = EIO;
|
||||
goto bad3;
|
||||
}
|
||||
@ -318,7 +318,7 @@ sdopen(dev, flag, fmt, p)
|
||||
SCSI_IGNORE_ILLEGAL_REQUEST |
|
||||
SCSI_IGNORE_MEDIA_CHANGE | SCSI_SILENT);
|
||||
if (error) {
|
||||
if (part != RAW_PART)
|
||||
if (part != RAW_PART || fmt != S_IFCHR)
|
||||
goto bad3;
|
||||
else
|
||||
goto out;
|
||||
@ -469,7 +469,10 @@ sdstrategy(bp)
|
||||
* If the device has been made invalid, error out
|
||||
*/
|
||||
if ((sd->sc_link->flags & SDEV_MEDIA_LOADED) == 0) {
|
||||
bp->b_error = EIO;
|
||||
if (sd->sc_link->flags & SDEV_OPEN)
|
||||
bp->b_error = EIO;
|
||||
else
|
||||
bp->b_error = ENODEV;
|
||||
goto bad;
|
||||
}
|
||||
/*
|
||||
@ -762,7 +765,10 @@ sdioctl(dev, cmd, addr, flag, p)
|
||||
break;
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
return (EIO);
|
||||
if ((sd->sc_link->flags & SDEV_OPEN) == 0)
|
||||
return (ENODEV);
|
||||
else
|
||||
return (EIO);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user