svn commit: r215668 - stable/7/sbin/fdisk

Brian Somers brian at FreeBSD.org
Mon Nov 22 09:34:38 UTC 2010


Author: brian
Date: Mon Nov 22 09:34:38 2010
New Revision: 215668
URL: http://svn.freebsd.org/changeset/base/215668

Log:
  MFC r212247 & r212724 from head:
      Handle geli-encrypted root disk devices.
      Add support for identifying a journaled root filesystem.
      Fix support for identifying the given /dev/vinum/root example.

Modified:
  stable/7/sbin/fdisk/fdisk.c
Directory Properties:
  stable/7/sbin/fdisk/   (props changed)

Modified: stable/7/sbin/fdisk/fdisk.c
==============================================================================
--- stable/7/sbin/fdisk/fdisk.c	Mon Nov 22 09:32:54 2010	(r215667)
+++ stable/7/sbin/fdisk/fdisk.c	Mon Nov 22 09:34:38 2010	(r215668)
@@ -1492,6 +1492,8 @@ sanitize_partition(struct dos_partition 
  *   /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)
@@ -1500,16 +1502,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);


More information about the svn-src-stable-7 mailing list