mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
Make the atapi device return sensible errno's back to userland.
Dont panic if a nonexistant device is opened.
This commit is contained in:
parent
71cb548de4
commit
6e82e8be6d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53078
@ -263,36 +263,7 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, void *data,
|
||||
#ifdef ATAPI_DEBUG
|
||||
printf("atapi: phew, got back from tsleep\n");
|
||||
#endif
|
||||
|
||||
error = request->result;
|
||||
switch ((error & ATAPI_SK_MASK)) {
|
||||
case ATAPI_SK_RESERVED:
|
||||
printf("atapi_error: %s - timeout error = %02x\n",
|
||||
atapi_cmd2str(atp->cmd), error & ATAPI_E_MASK);
|
||||
error = EIO;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_NO_SENSE:
|
||||
error = 0;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_RECOVERED_ERROR:
|
||||
printf("atapi_error: %s - recovered error\n", atapi_cmd2str(atp->cmd));
|
||||
error = 0;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_NOT_READY:
|
||||
atp->flags |= ATAPI_F_MEDIA_CHANGED;
|
||||
error = EBUSY;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_UNIT_ATTENTION:
|
||||
atp->flags |= ATAPI_F_MEDIA_CHANGED;
|
||||
error = EIO;
|
||||
break;
|
||||
|
||||
default: error = EIO;
|
||||
}
|
||||
error = request->error;
|
||||
free(request, M_ATAPI);
|
||||
return error;
|
||||
}
|
||||
@ -497,23 +468,52 @@ atapi_interrupt(struct atapi_request *request)
|
||||
request->flags = A_READ;
|
||||
TAILQ_INSERT_HEAD(&atp->controller->atapi_queue, request, chain);
|
||||
}
|
||||
else if (request->callback) {
|
||||
if (request->result)
|
||||
printf("atapi: %s - %s skey=%01x asc=%02x ascq=%02x error=%02x\n",
|
||||
atapi_cmd2str(atp->cmd), atapi_skey2str(request->sense.sense_key),
|
||||
request->sense.sense_key, request->sense.asc, request->sense.ascq,
|
||||
request->result & ATAPI_E_MASK);
|
||||
|
||||
if (!((request->callback)(request)))
|
||||
free(request, M_ATAPI);
|
||||
}
|
||||
else {
|
||||
if (request->result)
|
||||
request->error = 0;
|
||||
if (request->result) {
|
||||
printf("atapi: %s - %s skey=%01x asc=%02x ascq=%02x error=%02x\n",
|
||||
atapi_cmd2str(atp->cmd), atapi_skey2str(request->sense.sense_key),
|
||||
request->sense.sense_key, request->sense.asc, request->sense.ascq,
|
||||
request->result & ATAPI_E_MASK);
|
||||
wakeup((caddr_t)request);
|
||||
atapi_cmd2str(atp->cmd),
|
||||
atapi_skey2str(request->sense.sense_key),
|
||||
request->sense.sense_key, request->sense.asc,
|
||||
request->sense.ascq, request->result & ATAPI_E_MASK);
|
||||
|
||||
switch ((request->result & ATAPI_SK_MASK)) {
|
||||
case ATAPI_SK_RESERVED:
|
||||
printf("atapi_error: %s - timeout error = %02x\n",
|
||||
atapi_cmd2str(atp->cmd), request->result & ATAPI_E_MASK);
|
||||
request->error = EIO;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_NO_SENSE:
|
||||
request->error = 0;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_RECOVERED_ERROR:
|
||||
printf("atapi_error: %s - recovered error\n",
|
||||
atapi_cmd2str(atp->cmd));
|
||||
request->error = 0;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_NOT_READY:
|
||||
atp->flags |= ATAPI_F_MEDIA_CHANGED;
|
||||
request->error = EBUSY;
|
||||
break;
|
||||
|
||||
case ATAPI_SK_UNIT_ATTENTION:
|
||||
atp->flags |= ATAPI_F_MEDIA_CHANGED;
|
||||
request->error = EIO;
|
||||
break;
|
||||
|
||||
default:
|
||||
request->error = EIO;
|
||||
}
|
||||
}
|
||||
if (request->callback) {
|
||||
if (!((request->callback)(request)))
|
||||
free(request, M_ATAPI);
|
||||
}
|
||||
else
|
||||
wakeup((caddr_t)request);
|
||||
}
|
||||
#ifdef ATAPI_DEBUG
|
||||
printf("atapi_interrupt: error=0x%02x\n", request->result);
|
||||
|
@ -253,6 +253,7 @@ struct atapi_request {
|
||||
struct callout_handle timeout_handle; /* handle for untimeout */
|
||||
int32_t retries; /* retry count */
|
||||
int32_t result; /* result of this cmd */
|
||||
int32_t error; /* result translated to errno */
|
||||
struct atapi_reqsense sense; /* sense data if error */
|
||||
int32_t flags;
|
||||
#define A_READ 0x0001
|
||||
|
@ -416,6 +416,9 @@ acdopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
|
||||
{
|
||||
struct acd_softc *cdp = dev->si_drv1;
|
||||
|
||||
if (!cdp)
|
||||
return ENXIO;
|
||||
|
||||
if (cdp->flags & F_WRITING)
|
||||
return EBUSY;
|
||||
|
||||
@ -1091,10 +1094,9 @@ acd_done(struct atapi_request *request)
|
||||
{
|
||||
struct buf *bp = request->bp;
|
||||
struct acd_softc *cdp = request->driver;
|
||||
int32_t error = request->result;
|
||||
|
||||
if (error) {
|
||||
bp->b_error = error;
|
||||
if (request->error) {
|
||||
bp->b_error = request->error;
|
||||
bp->b_flags |= B_ERROR;
|
||||
}
|
||||
else {
|
||||
|
@ -331,8 +331,8 @@ afd_partial_done(struct atapi_request *request)
|
||||
{
|
||||
struct buf *bp = request->bp;
|
||||
|
||||
if (request->result) {
|
||||
bp->b_error = request->result;
|
||||
if (request->error) {
|
||||
bp->b_error = request->error;
|
||||
bp->b_flags |= B_ERROR;
|
||||
}
|
||||
bp->b_resid += request->bytecount;
|
||||
@ -345,8 +345,8 @@ afd_done(struct atapi_request *request)
|
||||
struct buf *bp = request->bp;
|
||||
struct afd_softc *fdp = request->driver;
|
||||
|
||||
if (request->result || (bp->b_flags & B_ERROR)) {
|
||||
bp->b_error = request->result;
|
||||
if (request->error || (bp->b_flags & B_ERROR)) {
|
||||
bp->b_error = request->error;
|
||||
bp->b_flags |= B_ERROR;
|
||||
}
|
||||
else
|
||||
|
@ -227,6 +227,9 @@ astopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
|
||||
{
|
||||
struct ast_softc *stp = dev->si_drv1;
|
||||
|
||||
if (!stp)
|
||||
return ENXIO;
|
||||
|
||||
if (stp->flags == F_OPEN)
|
||||
return EBUSY;
|
||||
|
||||
@ -469,10 +472,9 @@ ast_done(struct atapi_request *request)
|
||||
{
|
||||
struct buf *bp = request->bp;
|
||||
struct ast_softc *stp = request->driver;
|
||||
int32_t error = request->result;
|
||||
|
||||
if (error) {
|
||||
bp->b_error = error;
|
||||
if (request->error) {
|
||||
bp->b_error = request->error;
|
||||
bp->b_flags |= B_ERROR;
|
||||
}
|
||||
else {
|
||||
|
Loading…
Reference in New Issue
Block a user