From owner-svn-src-head@FreeBSD.ORG Mon Sep 6 04:15:50 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B72410656B2; Mon, 6 Sep 2010 04:15:50 +0000 (UTC) (envelope-from brian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A66F8FC1D; Mon, 6 Sep 2010 04:15:49 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o864Fnw3011180; Mon, 6 Sep 2010 04:15:49 GMT (envelope-from brian@svn.freebsd.org) Received: (from brian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o864Fntq011178; Mon, 6 Sep 2010 04:15:49 GMT (envelope-from brian@svn.freebsd.org) Message-Id: <201009060415.o864Fntq011178@svn.freebsd.org> From: Brian Somers Date: Mon, 6 Sep 2010 04:15:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212247 - head/sbin/fdisk X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Sep 2010 04:15:50 -0000 Author: brian Date: Mon Sep 6 04:15:49 2010 New Revision: 212247 URL: http://svn.freebsd.org/changeset/base/212247 Log: Handle geli-encrypted root disk devices. MFC after: 2 weeks Modified: head/sbin/fdisk/fdisk.c Modified: head/sbin/fdisk/fdisk.c ============================================================================== --- head/sbin/fdisk/fdisk.c Mon Sep 6 04:14:59 2010 (r212246) +++ head/sbin/fdisk/fdisk.c Mon Sep 6 04:15:49 2010 (r212247) @@ -1461,6 +1461,7 @@ 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)). */ static char * get_rootdisk(void) @@ -1469,7 +1470,7 @@ 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) @@ -1478,7 +1479,11 @@ get_rootdisk(void) if ((rv = regcomp(&re, "^(/dev/[a-z/]+[0-9]+)([sp][0-9]+)?[a-h]?$", 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);