NetBSD-Bugs archive

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

Re: kern/48550: panic when accessing CDs



The following reply was made to PR kern/48550; it has been noted by GNATS.

From: Martin Husemann <martin%duskware.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/48550: panic when accessing CDs
Date: Tue, 4 Feb 2014 12:32:18 +0100

 The following patch fixes the issue (seems to be a strange medium/drive
 interaction) for me.
 
 While there it makes sure blksize/last_lba is always initialized before
 calling cd_read_capacity(), as that may leave "the defaults" untouched
 and still return 0.
 
 The limit to 16k is arbitrary and could be selected smaller.
 
 With the change I actually get the proper disklabel:
 
 # /dev/rcd0d:
 type: ATAPI
 disk: iso partition
 label: fictitious
 flags: removable
 bytes/sector: 2048
 sectors/track: 100
 tracks/cylinder: 1
 sectors/cylinder: 100
 cylinders: 255355
 total sectors: 25535489
 rpm: 300
 interleave: 1
 trackskew: 0
 cylinderskew: 0
 headswitch: 0           # microseconds
 track-to-track seek: 0  # microseconds
 drivedata: 0 
 
 4 partitions:
 #        size    offset     fstype [fsize bsize cpg/sgs]
  a:  25535489         0    ISO9660       0             # (Cyl.      0 - 
255354*)
  d:  25535489         0        UDF                     # (Cyl.      0 - 
255354*)
 
 
 Martin
 
 Index: cd.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/scsipi/cd.c,v
 retrieving revision 1.316
 diff -u -p -r1.316 cd.c
 --- cd.c       25 Oct 2013 11:35:55 -0000      1.316
 +++ cd.c       4 Feb 2014 11:25:40 -0000
 @@ -1822,7 +1822,8 @@ read_cd_capacity(struct scsipi_periph *p
        *last_lba = _4btol(cap.addr);
  
        /* blksize is 2048 for CD, but some drives give gibberish */
 -      if ((*blksize < 512) || ((*blksize & 511) != 0))
 +      if ((*blksize < 512) || ((*blksize & 511) != 0)
 +          || (*blksize > 16*1024))
                *blksize = 2048;        /* some drives lie ! */
  
        /* recordables have READ_DISCINFO implemented */
 @@ -1874,8 +1875,8 @@ read_cd_capacity(struct scsipi_periph *p
  static u_long
  cd_size(struct cd_softc *cd, int flags)
  {
 -      u_int blksize;
 -      u_long last_lba, size;
 +      u_int blksize = 2048;
 +      u_long last_lba = 0, size;
        int error;
  
        error = read_cd_capacity(cd->sc_periph, &blksize, &last_lba);
 @@ -2978,7 +2979,7 @@ mmc_getdiscinfo(struct scsipi_periph *pe
        struct scsipi_read_discinfo_data  di;
        const uint32_t buffer_size = 1024;
        uint32_t feat_tbl_len, pos;
 -      u_long   last_lba;
 +      u_long   last_lba = 0;
        uint8_t  *buffer, *fpos;
        int feature, last_feature, features_len, feature_cur, feature_len;
        int lsb, msb, error, flags;
 


Home | Main Index | Thread Index | Old Index