void partition(SDunit *unit) { int type; char *p; if(unit->part == 0) return; if(part9660(unit) == 0) return; p = getconf("partition"); if(p == nil) p = defaultpartition; if(p != nil && strncmp(p, "new", 3) == 0) type = NEW; else if(p != nil && strncmp(p, "old", 3) == 0) type = OLD; else type = NEW|OLD; if(nbuf < unit->secsize) { free(mbrbuf); free(partbuf); mbrbuf = malloc(unit->secsize); partbuf = malloc(unit->secsize); if(mbrbuf==nil || partbuf==nil) { free(mbrbuf); free(partbuf); partbuf = mbrbuf = nil; nbuf = 0; return; } nbuf = unit->secsize; } if((type & NEW) && mbrpart(unit) >= 0){ /* nothing to do */; } else if(type & OLD) oldp9part(unit); }
/* * read unit->data to look for partition tables. * if found, stash partitions in environment and write them to ctl too. */ static void partition(PSDunit *unit) { int type; char *p; if(unit->part == 0) return; if(part9660(unit) == 0) return; p = getconf("partition"); if(p != nil && strncmp(p, "new", 3) == 0) type = NEW; else if(p != nil && strncmp(p, "old", 3) == 0) type = OLD; else type = NEW|OLD; if(mbrbuf == nil) { mbrbuf = malloc(Maxsec); partbuf = malloc(Maxsec); if(mbrbuf==nil || partbuf==nil) { free(mbrbuf); free(partbuf); partbuf = mbrbuf = nil; return; } } /* * there might be no mbr (e.g. on a very large device), so look for * a bare plan 9 partition table if mbrpart fails. */ if((type & NEW) && mbrpart(unit) >= 0){ /* nothing to do */ } else if (type & NEW) p9part(unit, "data"); else if(type & OLD) oldp9part(unit); }