summaryrefslogtreecommitdiffstats
path: root/sbin/geom
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2009-02-08 20:19:19 +0000
committermarcel <marcel@FreeBSD.org>2009-02-08 20:19:19 +0000
commit088f6e21bd6866d8f4d6a09473e60e137e63babe (patch)
treec9024bd837d2e99b5ce2010c20707476b12ee222 /sbin/geom
parentf3c03c908a7f4a89d8bac3429aa4e29e36d4d43d (diff)
downloadFreeBSD-src-088f6e21bd6866d8f4d6a09473e60e137e63babe.zip
FreeBSD-src-088f6e21bd6866d8f4d6a09473e60e137e63babe.tar.gz
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.
Diffstat (limited to 'sbin/geom')
-rw-r--r--sbin/geom/class/part/geom_part.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/sbin/geom/class/part/geom_part.c b/sbin/geom/class/part/geom_part.c
index 94b67da..357db3f 100644
--- a/sbin/geom/class/part/geom_part.c
+++ b/sbin/geom/class/part/geom_part.c
@@ -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");
}
OpenPOWER on IntegriCloud