static int sdinitpart(SDunit* unit) { int nf; uvlong start, end; char *f[4], *p, *q, buf[10]; if(unit->sectors > 0){ unit->sectors = unit->secsize = 0; sdincvers(unit); } /* device must be connected or not; other values are trouble */ if(unit->inquiry[0] & 0xC0) /* see SDinq0periphqual */ return 0; switch(unit->inquiry[0] & SDinq0periphtype){ case SDperdisk: case SDperworm: case SDpercd: case SDpermo: break; default: return 0; } if(unit->dev->ifc->online) unit->dev->ifc->online(unit); if(unit->sectors){ sdincvers(unit); sdaddpart(unit, "data", 0, unit->sectors); /* * Use partitions passed from boot program, * e.g. * sdC0part=dos 63 123123/plan9 123123 456456 * This happens before /boot sets hostname so the * partitions will have the null-string for user. * The gen functions patch it up. */ snprint(buf, sizeof buf, "%spart", unit->name); for(p = getconf(buf); p != nil; p = q){ if(q = strchr(p, '/')) *q++ = '\0'; nf = tokenize(p, f, nelem(f)); if(nf < 3) continue; start = strtoull(f[1], 0, 0); end = strtoull(f[2], 0, 0); if(!waserror()){ sdaddpart(unit, f[0], start, end); poperror(); } } } return 1; }
static int sdinitpart(SDunit* unit) { int nf; uvlong start, end; char *f[4], *p, *q, buf[10]; if(unit->sectors > 0){ unit->sectors = unit->secsize = 0; sdincvers(unit); } if(unit->inquiry[0] & 0xC0) return 0; switch(unit->inquiry[0] & 0x1F){ case 0x00: /* DA */ case 0x04: /* WORM */ case 0x05: /* CD-ROM */ case 0x07: /* MO */ break; default: return 0; } if(unit->dev->ifc->online) unit->dev->ifc->online(unit); if(unit->sectors){ sdincvers(unit); sdaddpart(unit, "data", 0, unit->sectors); /* * Use partitions passed from boot program, * e.g. * sdC0part=dos 63 123123/plan9 123123 456456 * This happens before /boot sets hostname so the * partitions will have the null-string for user. * The gen functions patch it up. */ snprint(buf, sizeof buf, "%spart", unit->name); for(p = getconf(buf); p != nil; p = q){ if(q = strchr(p, '/')) *q++ = '\0'; nf = tokenize(p, f, nelem(f)); if(nf < 3) continue; start = strtoull(f[1], 0, 0); end = strtoull(f[2], 0, 0); if(!waserror()){ sdaddpart(unit, f[0], start, end); poperror(); } } } return 1; }