summaryrefslogtreecommitdiffstats
path: root/sbin/bsdlabel
diff options
context:
space:
mode:
authorrse <rse@FreeBSD.org>2005-01-07 12:19:57 +0000
committerrse <rse@FreeBSD.org>2005-01-07 12:19:57 +0000
commitfad9806e7566b42e8625363cd7e5b85e8d8cdc8b (patch)
treea1cf53a656eff322eb6d1f58987769bccfcdd83d /sbin/bsdlabel
parent96e30a8273df07b26fe95baadf706d5af1e03dce (diff)
downloadFreeBSD-src-fad9806e7566b42e8625363cd7e5b85e8d8cdc8b.zip
FreeBSD-src-fad9806e7566b42e8625363cd7e5b85e8d8cdc8b.tar.gz
Fix the derivation of the GEOM name from the specified device name by
complementing the existing special case of a not existing /dev prefix with the recognition of an already existing /dev prefix. This implicitly solves the following two issues related to working on GEOM devices /dev/foo/bar (which have the GEOM provider name "foo/bar") with the expected commands like "bsdlabel /dev/foo/bar": 1. the error "Geom not found" when trying to write or edit the BSD label (because previously the incorrect GEOM name "bar" instead of "foo/bar" was derived from "/dev/foo/bar"). 2. the multiple times reported "magically introduced" partition offset of 63 blocks and the resulting errors like "partition extends past end of unit" and "partition c doesn't start at 0!". This implicitly resulted because bsdlabel(8) determines the "MBR offset" via GEOM and (intentionally) silently falls back to an offset of 0 if it could not be queried (which is the case if the name was incorrectly derived). Usually (at least on PCs) the offset for the first slice is 63 blocks and bsdlabel(8) automatically subtracts them from the absolute offsets in the read on-disk BSD label, resulting in the display of an effective offset of 0. If the GEOM query fails, the assumed offset of 0 is subtracted and an incorrect effective offset of 63 is displayed and tried to be worked upon. Reviewed by: pjd MFC after: 1 week
Diffstat (limited to 'sbin/bsdlabel')
-rw-r--r--sbin/bsdlabel/bsdlabel.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 8d44e68..3d12834 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -222,6 +222,9 @@ main(int argc, char *argv[])
} else if (argv[0][0] != '/') {
dkname = argv[0];
asprintf(&specname, "%s%s", _PATH_DEV, argv[0]);
+ } else if (strncmp(argv[0], _PATH_DEV, strlen(_PATH_DEV)) == 0) {
+ dkname = argv[0] + strlen(_PATH_DEV);
+ specname = argv[0];
} else {
dkname = strrchr(argv[0], '/');
dkname++;
OpenPOWER on IntegriCloud