for read capacity (10 (0x25) if we have more than 4 billion sectors, we must not return nsectors % (1<<32), we must return 0xffffffff. Reference: /n/atom/patch/applied2013/sd0x25overflow Date: Tue Nov 12 16:45:06 CET 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/port/devsd.c Tue Nov 12 16:42:38 2013 +++ /sys/src/9/port/devsd.c Tue Nov 12 16:42:38 2013 @@ -1068,7 +1068,9 @@ * Read capacity returns the LBA of the last sector. */ len = unit->sectors; - if(len > 0) + if(len >= 0xffffffff) + len = 0xffffffff; + else if(len > 0) len--; p = r->data; *p++ = len>>24; @@ -1624,10 +1626,12 @@ for(i = 0; sdifc[i] != nil; i++) if(strcmp(sdifc[i]->name, cf->type) == 0) break; - if(sdifc[i] == nil) - error("sd type not found"); - if(p) - *(p-1) = '/'; + if(sdifc[i] == nil){ + snprint(buf, sizeof buf, "sd: type %s: not found", cf->type); + error(buf); + } + if(p != nil) + p[-1] = '/'; if(sdifc[i]->probe == nil) error("sd type cannot probe"); --- /sys/src/nix/port/devsd.c Tue Nov 12 16:42:38 2013 +++ /sys/src/nix/port/devsd.c Tue Nov 12 16:42:38 2013 @@ -784,13 +784,13 @@ uvlong bno; sdev = sdgetdev(DEV(c->qid)); + if(sdev == nil) + error(Enonexist); + unit = sdev->unit[UNIT(c->qid)]; if(sdev == nil){ decref(&sdev->r); error(Enonexist); } - unit = sdev->unit[UNIT(c->qid)]; - if(unit == nil) - error(Enonexist); nchange = 0; qlock(&unit->ctl); @@ -1068,7 +1068,9 @@ * Read capacity returns the LBA of the last sector. */ len = unit->sectors; - if(len > 0) + if(len >= 0xffffffff) + len = 0xffffffff; + else if(len > 0) len--; p = r->data; *p++ = len>>24;