svn commit: r212247 - head/sbin/fdisk

Pawel Jakub Dawidek pjd at FreeBSD.org
Mon Sep 6 06:42:15 UTC 2010


On Mon, Sep 06, 2010 at 04:15:49AM +0000, Brian Somers wrote:
> 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.
[...]
>  	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);

Your assumption that .eli can only be present at the end of provider name
is incorrect. It can be eg. /dev/ad0s1a.eli.journal.

Another problem is that in memmove you cut the first 4 characters, not
the last 4 characters.

I'm not sure, but can't you simply extend regular expression to:

	"^(/dev/[a-z/]+[0-9]+)([sp][0-9]+)?[a-h]?(\.eli)?$"

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20100906/51207e8b/attachment.pgp


More information about the svn-src-head mailing list