summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>2010-11-22 09:32:54 +0000
committerBrian Somers <brian@FreeBSD.org>2010-11-22 09:32:54 +0000
commit7d5864695f7a77840841963fcaf8a8e508deda39 (patch)
tree1632716ecf54ff2433925ddfde533b70b5c0f1ee /sbin
parentd18979442f76f4b28e8c5b0033d77f1f737987ed (diff)
Notes
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fdisk/fdisk.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 1e121bb6450da..0495a690ea85d 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -1461,6 +1461,8 @@ sanitize_partition(struct dos_partition *partp)
* /dev/ad0s1a => /dev/ad0
* /dev/da0a => /dev/da0
* /dev/vinum/root => /dev/vinum/root
+ * A ".eli" part is removed if it exists (see geli(8)).
+ * A ".journal" ending is removed if it exists (see gjournal(8)).
*/
static char *
get_rootdisk(void)
@@ -1469,16 +1471,20 @@ get_rootdisk(void)
regex_t re;
#define NMATCHES 2
regmatch_t rm[NMATCHES];
- char *s;
+ char dev[PATH_MAX], *s;
int rv;
if (statfs("/", &rootfs) == -1)
err(1, "statfs(\"/\")");
- if ((rv = regcomp(&re, "^(/dev/[a-z/]+[0-9]+)([sp][0-9]+)?[a-h]?$",
+ if ((rv = regcomp(&re, "^(/dev/[a-z/]+[0-9]*)([sp][0-9]+)?[a-h]?(\\.journal)?$",
REG_EXTENDED)) != 0)
errx(1, "regcomp() failed (%d)", rv);
- if ((rv = regexec(&re, rootfs.f_mntfromname, NMATCHES, rm, 0)) != 0)
+ strlcpy(dev, rootfs.f_mntfromname, sizeof (dev));
+ if ((s = strstr(dev, ".eli")) != NULL)
+ memmove(s, s+4, strlen(s + 4) + 1);
+
+ if ((rv = regexec(&re, dev, NMATCHES, rm, 0)) != 0)
errx(1,
"mounted root fs resource doesn't match expectations (regexec returned %d)",
rv);