Prefer the start and end attributes over the offset and size

attributes. The start and end more accurately describe the
space taken by a partition. The offset and size are used to
describe the effective (usable) storage of that partition.
This commit is contained in:
Marcel Moolenaar 2009-02-08 20:19:19 +00:00
parent 165651a553
commit 0dd9f21c23
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=188330

View File

@ -187,17 +187,23 @@ static struct gprovider *
find_provider(struct ggeom *gp, unsigned long long minsector)
{
struct gprovider *pp, *bestpp;
unsigned long long offset;
const char *s;
unsigned long long sector, bestsector;
bestpp = NULL;
LIST_FOREACH(pp, &gp->lg_provider, lg_provider) {
offset = atoll(find_provcfg(pp, "offset"));
sector = offset / pp->lg_sectorsize;
s = find_provcfg(pp, "start");
if (s == NULL) {
s = find_provcfg(pp, "offset");
sector = atoll(s) / pp->lg_sectorsize;
} else
sector = atoll(s);
if (sector < minsector)
continue;
if (bestpp != NULL && sector >= bestsector)
continue;
bestpp = pp;
bestsector = sector;
}
@ -240,7 +246,7 @@ gpart_show_geom(struct ggeom *gp, const char *element)
struct gprovider *pp;
const char *s, *scheme;
unsigned long long first, last, sector, end;
unsigned long long offset, length, secsz;
unsigned long long length, secsz;
int idx, wblocks, wname;
scheme = find_geomcfg(gp, "scheme");
@ -258,14 +264,24 @@ gpart_show_geom(struct ggeom *gp, const char *element)
scheme, fmtsize(pp->lg_mediasize));
while ((pp = find_provider(gp, first)) != NULL) {
s = find_provcfg(pp, "offset");
offset = atoll(s);
sector = offset / secsz;
s = find_provcfg(pp, "length");
length = atoll(s);
s = find_provcfg(pp, "start");
if (s == NULL) {
s = find_provcfg(pp, "offset");
sector = atoll(s) / secsz;
} else
sector = atoll(s);
s = find_provcfg(pp, "end");
if (s == NULL) {
s = find_provcfg(pp, "length");
length = atoll(s) / secsz;
end = sector + length - 1;
} else {
end = atoll(s);
length = end - sector + 1;
}
s = find_provcfg(pp, "index");
idx = atoi(s);
end = sector + length / secsz;
if (first < sector) {
printf(" %*llu %*llu %*s - free - (%s)\n",
wblocks, first, wblocks, sector - first,
@ -273,16 +289,17 @@ gpart_show_geom(struct ggeom *gp, const char *element)
fmtsize((sector - first) * secsz));
}
printf(" %*llu %*llu %*d %s %s (%s)\n",
wblocks, sector, wblocks, end - sector,
wblocks, sector, wblocks, length,
wname, idx, find_provcfg(pp, element),
fmtattrib(pp), fmtsize(pp->lg_mediasize));
first = end;
first = end + 1;
}
if (first <= last) {
length = last - first + 1;
printf(" %*llu %*llu %*s - free - (%s)\n",
wblocks, first, wblocks, last - first + 1,
wblocks, first, wblocks, length,
wname, "",
fmtsize((last - first + 1) * secsz));
fmtsize(length * secsz));
}
printf("\n");
}