Date: Sun, 8 Feb 2009 20:19:19 +0000 (UTC) From: Marcel Moolenaar <marcel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r188330 - head/sbin/geom/class/part Message-ID: <200902082019.n18KJJFk033280@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marcel Date: Sun Feb 8 20:19:19 2009 New Revision: 188330 URL: http://svn.freebsd.org/changeset/base/188330 Log: 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. Modified: head/sbin/geom/class/part/geom_part.c Modified: head/sbin/geom/class/part/geom_part.c ============================================================================== --- head/sbin/geom/class/part/geom_part.c Sun Feb 8 20:15:08 2009 (r188329) +++ head/sbin/geom/class/part/geom_part.c Sun Feb 8 20:19:19 2009 (r188330) @@ -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 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 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 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"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902082019.n18KJJFk033280>