diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2006-08-04 21:35:52 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2006-08-04 21:35:52 +0000 |
commit | ea82f6c5f6d4bb51c9e3a60e414082c516d798a7 (patch) | |
tree | 21dc95511589dc61ad7b3f8e04e953c190ff6887 /sys/scsi/scsi_base.c | |
parent | d0e695f041fa5614782cde825209fe672aea4826 (diff) |
Add ENOMEDIUM and EMEDIUMTYPE to report medium errors to userland programs
when using removable media devices, along with changes to scsi_base to
detect such cases in tapes other devices. This makes tar, dd, and friends
report a semi useful error message instead of nonsense when there is nothing
in the device.
Includes libc minor bump, and will require the corresponding sets change.
ok krw@ deraadt@
Diffstat (limited to 'sys/scsi/scsi_base.c')
-rw-r--r-- | sys/scsi/scsi_base.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index aa5a360926c..730216ebd11 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.111 2006/07/29 02:40:45 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.112 2006/08/04 21:35:51 beck Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -1023,11 +1023,35 @@ scsi_interpret_sense(struct scsi_xfer *xs) break; case 0x3a: /* Medium not present */ sc_link->flags &= ~SDEV_MEDIA_LOADED; - error = ENODEV; + error = ENOMEDIUM; break; } } break; + case SKEY_MEDIUM_ERROR: + switch (sense->add_sense_code) { + case 0x3a: /* Medium not present */ + sc_link->flags &= ~SDEV_MEDIA_LOADED; + error = ENOMEDIUM; + break; + case 0x30: /* Medium issues */ + switch (sense->add_sense_code_qual) { + case 0x01: /* (Read) Unknown Format */ + case 0x02: /* (Read) Incompatible Medium */ + case 0x04: /* (Write) Unknown Format */ + case 0x05: /* (Write) Incompatible Medium */ + case 0x06: /* (Format) Incompatible Medium */ + case 0x08: /* (Write/CD) Can't Write Media */ + error = EMEDIUMTYPE; + default: + error = EIO; + } + break; + default: + error = EIO; + break; + } + break; case SKEY_ILLEGAL_REQUEST: if ((xs->flags & SCSI_IGNORE_ILLEGAL_REQUEST) != 0) return (0); @@ -1057,6 +1081,12 @@ scsi_interpret_sense(struct scsi_xfer *xs) case SKEY_VOLUME_OVERFLOW: error = ENOSPC; break; + case SKEY_HARDWARE_ERROR: + if (sense->add_sense_code == 0x52 && + sense->add_sense_code_qual == 0x00) + return(EMEDIUMTYPE); /* Cartridge Fault */ + error = EIO; + break; default: error = EIO; break; |