diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2000-07-18 06:09:01 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2000-07-18 06:09:01 +0000 |
commit | 895c22a8fe2ee086caf62577eb81848fd7fbed9b (patch) | |
tree | 38d2b0c0246462f0aba32fe44226d092c876b32e /sys | |
parent | de18fb31c847b5dd4d58fd2793dbb5fbe8aa508f (diff) |
Update cd_size to handle failure of READ_CD_CAPACITY by returning
some default values
Diffstat (limited to 'sys')
-rw-r--r-- | sys/scsi/cd.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/sys/scsi/cd.c b/sys/scsi/cd.c index 0694d997ad3..6ca2d2abaa2 100644 --- a/sys/scsi/cd.c +++ b/sys/scsi/cd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd.c,v 1.54 2000/04/18 06:34:18 csapuntz Exp $ */ +/* $OpenBSD: cd.c,v 1.55 2000/07/18 06:09:00 csapuntz Exp $ */ /* $NetBSD: cd.c,v 1.100 1997/04/02 02:29:30 mycroft Exp $ */ /* @@ -1320,16 +1320,14 @@ cd_size(cd, flags) struct scsi_read_cd_capacity scsi_cmd; int blksize; u_long size; + + /* Reasonable defaults for drives that don't support + READ_CD_CAPCITY */ + cd->params.blksize = 2048; + cd->params.disksize = 400000; - if (cd->sc_link->quirks & ADEV_NOCAPACITY) { - /* - * the drive doesn't support the READ_CD_CAPACITY command - * use a fake size - */ - cd->params.blksize = 2048; - cd->params.disksize = 400000; - return (400000); - } + if (cd->sc_link->quirks & ADEV_NOCAPACITY) + goto exit; /* * make up a scsi command and ask the scsi driver to do @@ -1346,7 +1344,7 @@ cd_size(cd, flags) (struct scsi_generic *)&scsi_cmd, sizeof(scsi_cmd), (u_char *)&rdcap, sizeof(rdcap), CDRETRIES, 20000, NULL, flags | SCSI_DATA_IN) != 0) - return (0); + goto exit; blksize = _4btol(rdcap.length); if ((blksize < 512) || ((blksize & 511) != 0)) @@ -1358,8 +1356,9 @@ cd_size(cd, flags) size = 400000; /* ditto */ cd->params.disksize = size; + exit: SC_DEBUG(cd->sc_link, SDEV_DB2, ("cd_size: %d %ld\n", blksize, size)); - return (size); + return (cd->params.disksize); } |