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 | |
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@
-rw-r--r-- | lib/libc/gen/errlist.c | 4 | ||||
-rw-r--r-- | lib/libc/shlib_version | 2 | ||||
-rw-r--r-- | lib/libc/sys/intro.2 | 7 | ||||
-rw-r--r-- | sys/scsi/scsi_base.c | 34 | ||||
-rw-r--r-- | sys/sys/errno.h | 6 |
5 files changed, 46 insertions, 7 deletions
diff --git a/lib/libc/gen/errlist.c b/lib/libc/gen/errlist.c index 59117fff59b..092608c9dba 100644 --- a/lib/libc/gen/errlist.c +++ b/lib/libc/gen/errlist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: errlist.c,v 1.9 2005/08/08 08:05:33 espie Exp $ */ +/* $OpenBSD: errlist.c,v 1.10 2006/08/04 21:35:51 beck Exp $ */ /* * Copyright (c) 1982, 1985, 1993 * The Regents of the University of California. All rights reserved. @@ -137,5 +137,7 @@ const char *const "IPsec processing failure", /* 82 - EIPSEC */ "Attribute not found", /* 83 - ENOATTR */ "Illegal byte sequence", /* 84 - EILSEQ */ + "No medium found", /* 85 - ENOMEDIUM */ + "Wrong medium type", /* 86 - EMEDIUMTYPE */ }; int _sys_nerr = { sizeof _sys_errlist/sizeof _sys_errlist[0] }; diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index 48b7a8da18c..34130d6b6cb 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ major=39 -minor=2 +minor=3 # note: If changes were made to include/thread_private.h or if system # calls were added/changed then libpthread must also be updated. diff --git a/lib/libc/sys/intro.2 b/lib/libc/sys/intro.2 index 36f312177d8..20a08afa780 100644 --- a/lib/libc/sys/intro.2 +++ b/lib/libc/sys/intro.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: intro.2,v 1.36 2006/08/03 23:20:32 jmc Exp $ +.\" $OpenBSD: intro.2,v 1.37 2006/08/04 21:35:51 beck Exp $ .\" $NetBSD: intro.2,v 1.6 1995/02/27 12:33:41 cgd Exp $ .\" .\" Copyright (c) 1980, 1983, 1986, 1991, 1993 @@ -417,6 +417,11 @@ Not used in A UFS Extended Attribute is not found for the specified pathname. .It Er 84 EILSEQ Em "Illegal byte sequence" . An illegal sequence of bytes was used when using wide characters. +.It Er 85 ENOMEDIUM Em "No medium found" . +Attempted to use a removable media device with no medium present. +.It Er 86 EMEDIUMTYPE Em "Wrong medium type" . +Attempted to use a removable media device with incorrect or incompatible +medium. .El .Sh DEFINITIONS .Bl -tag -width Ds 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; diff --git a/sys/sys/errno.h b/sys/sys/errno.h index 9537dbc8a7d..3b29a00703f 100644 --- a/sys/sys/errno.h +++ b/sys/sys/errno.h @@ -1,4 +1,4 @@ -/* $OpenBSD: errno.h,v 1.16 2005/12/28 16:33:57 millert Exp $ */ +/* $OpenBSD: errno.h,v 1.17 2006/08/04 21:35:51 beck Exp $ */ /* $NetBSD: errno.h,v 1.10 1996/01/20 01:33:53 jtc Exp $ */ /* @@ -157,7 +157,9 @@ #define EIPSEC 82 /* IPsec processing failure */ #define ENOATTR 83 /* Attribute not found */ #define EILSEQ 84 /* Illegal byte sequence */ -#define ELAST 84 /* Must be equal largest errno */ +#define ENOMEDIUM 85 /* No medium found */ +#define EMEDIUMTYPE 86 /* Wrong Medium Type */ +#define ELAST 86 /* Must be equal largest errno */ #endif /* __BSD_VISIBLE */ #ifdef _KERNEL |