Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/scsipi cd_size: if we fake a size (and I realy have ...



details:   https://anonhg.NetBSD.org/src/rev/15beebe9a07c
branches:  trunk
changeset: 753627:15beebe9a07c
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Apr 04 21:36:22 2010 +0000

description:
cd_size: if we fake a size (and I realy have no idea why this would be a
good idea), at least set up all values to the fake values, as the caller
expects.
Should fix PR kern/39904, though if noone can find out why the fake value
would be needed, we should change it to just return 0 as suggested in the PR.

diffstat:

 sys/dev/scsipi/cd.c |  29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)

diffs (66 lines):

diff -r b44b4c5c02e6 -r 15beebe9a07c sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Sun Apr 04 17:55:52 2010 +0000
+++ b/sys/dev/scsipi/cd.c       Sun Apr 04 21:36:22 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.301 2010/03/23 18:56:18 martin Exp $  */
+/*     $NetBSD: cd.c,v 1.302 2010/04/04 21:36:22 martin Exp $  */
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.301 2010/03/23 18:56:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.302 2010/04/04 21:36:22 martin Exp $");
 
 #include "rnd.h"
 
@@ -1871,14 +1871,9 @@
        u_long size;
        int error;
 
-       /* set up fake values */
-       blksize = 2048;
-       size    = 400000;
-
-       /* if this function bounces with an error return fake value */
        error = read_cd_capacity(cd->sc_periph, &blksize, &size);
        if (error)
-               return size;
+               goto error;
 
        if (blksize != 2048) {
                if (cd_setblksize(cd) == 0) {
@@ -1886,7 +1881,7 @@
                        error = read_cd_capacity(cd->sc_periph,
                            &blksize, &size);
                        if (error)
-                               return size;
+                               goto error;
                }
        }
        cd->params.blksize     = blksize;
@@ -1897,6 +1892,22 @@
            ("cd_size: %u %lu\n", blksize, size));
 
        return size;
+
+error:
+       /*
+        * Something went wrong - return fake values
+        *
+        * XXX - what is this good for? Should return 0 and let the caller deal
+        */
+       cd->params.blksize     = 2048;
+       cd->params.disksize    = 400000;
+       cd->params.disksize512 = ((u_int64_t)cd->params.disksize
+                                 * cd->params.blksize) / DEV_BSIZE;
+
+       SC_DEBUG(cd->sc_periph, SCSIPI_DB2,
+           ("cd_size: failed, fake values %u %lu\n", blksize, size));
+
+       return size;
 }
 
 /*



Home | Main Index | Thread Index | Old Index