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