Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Sep 2010 01:13:18 -0700
From:      Brian Somers <brian@FreeBSD.org>
To:        Pawel Jakub Dawidek <pjd@FreeBSD.org>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r212247 - head/sbin/fdisk
Message-ID:  <20100906011318.3d5c0bb6@dev.lan.Awfulhak.org>
In-Reply-To: <20100906064142.GF1900@garage.freebsd.pl>
References:  <201009060415.o864Fntq011178@svn.freebsd.org> <20100906064142.GF1900@garage.freebsd.pl>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Mon, 6 Sep 2010 08:41:42 +0200 Pawel Jakub Dawidek <pjd@FreeBSD.org> wrote:
> 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)?$"

You've lost me here.  I remove .eli from the device name specifically so that we
handle it being *anywhere* in the string.  Your suggestion only handles it being
at the end of the string.

The memmove doesn't cut the first four characters, it cuts the ".eli" string....
doesn't it?

-- 
Brian Somers                                          <brian@Awfulhak.org>
Don't _EVER_ lose your sense of humour !               <brian@FreeBSD.org>

[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iQCVAwUBTISipQ7tvOdmanQhAQJd2QP/fWXS6diqEolCAG9LCj7D5JjN07i9RUpO
jAl+aMan8wY1iFhJxt+DBuR5s1y7NC7OTldZRkWzG4CKC/d3RhkPOVrsq5X191JZ
O4LFxfJpg++VEGqJM1ciUQQMYRKxYoM5az5ANoOhkvnucUWXLLPnupc0wtuhDTRf
vmnC4yPhYCw=
=wrh8
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100906011318.3d5c0bb6>