From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VrRqU-0005De-Aa for mharc-grub-devel@gnu.org; Fri, 13 Dec 2013 07:27:54 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33899) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrRqM-0005DY-Sk for grub-devel@gnu.org; Fri, 13 Dec 2013 07:27:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrRqH-0001eb-8m for grub-devel@gnu.org; Fri, 13 Dec 2013 07:27:46 -0500 Received: from mail-ee0-x22d.google.com ([2a00:1450:4013:c00::22d]:57451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrRqG-0001eT-UF for grub-devel@gnu.org; Fri, 13 Dec 2013 07:27:41 -0500 Received: by mail-ee0-f45.google.com with SMTP id d49so822827eek.18 for ; Fri, 13 Dec 2013 04:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=GQlwf9U+WYWa5gReucXgeLSrt3vMfOjBchhySzv+ioY=; b=bBK+UyyMFMZpYmiXfW0gbRQJ4NfoFydSi2gi1PhgY9TTPH5lZpjj5dOwWqej5iCVdV 3xCPpAQWsQF8WmL7KPwnDCmi0UGgUK/69n+p8kuMmdnagJRL+/wNJL+wt4jdBNmWTusQ XYjuNTM35L/g6cNtCk4C41LsGJJIWczCcsGjiY+UytwRtddjwN0f+cCY60HRtWjKLQLO B419S3OqlXvgNco6cfsD/otmQGSIY13yjEfSf+0H/4mLH8lNOEKOQaM4B4MXKOkTh73w Gvwwn0mwQpSATZg66uSimPM2jTixh5MlSQnKQ0iiATaEZUSvNe6JnBoAE66/45afZc1L RhMw== X-Received: by 10.14.211.130 with SMTP id w2mr2526789eeo.111.1386937660057; Fri, 13 Dec 2013 04:27:40 -0800 (PST) Received: from [192.168.1.16] (85-188.196-178.cust.bluewin.ch. [178.196.188.85]) by mx.google.com with ESMTPSA id e43sm6270881eep.7.2013.12.13.04.27.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 04:27:38 -0800 (PST) Message-ID: <52AAFD39.6000501@gmail.com> Date: Fri, 13 Dec 2013 13:27:37 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Colin Watson , The development of GRUB 2 Subject: Re: [Xen-devel] [PATCH 1/4] Add an option to exclude devices from search results. References: <20131212153643.GA1431@riva.ucam.org> <20131212153706.GB1431@riva.ucam.org> In-Reply-To: <20131212153706.GB1431@riva.ucam.org> X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="F71G2UsHA6wEGGtADwfiboaWCoSMHjSRP" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c00::22d X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Dec 2013 12:27:52 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --F71G2UsHA6wEGGtADwfiboaWCoSMHjSRP Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12.12.2013 16:37, Colin Watson wrote: > * grub-core/commands/search.c (struct search_ctx): Add excludes and > nexcludes. > (iterate_device): Ignore devices listed in ctx->excludes. > (FUNC_NAME): Accept excludes and nexcludes parameters. > (grub_cmd_do_search): Pass empty excludes. > * grub-core/commands/search_wrap.c (options): Add --exclude option. > (grub_cmd_search): Handle --exclude. > * include/grub/search.h (grub_search_fs_file): Update prototype. > (grub_search_fs_uuid): Likewise. > (grub_search_label): Likewise. > * docs/grub.texi (search): Document --exclude. > --- > ChangeLog | 16 ++++++++++++++++ > docs/grub.texi | 7 ++++++- > grub-core/commands/search.c | 15 +++++++++++++-- > grub-core/commands/search_wrap.c | 27 ++++++++++++++++++++++----- > include/grub/search.h | 9 ++++++--- > 5 files changed, 63 insertions(+), 11 deletions(-) >=20 > diff --git a/ChangeLog b/ChangeLog > index 9cec63f..766fe4b 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,19 @@ > +2013-12-12 Colin Watson > + > + Add an option to exclude devices from search results. > + > + * grub-core/commands/search.c (struct search_ctx): Add excludes and > + nexcludes. > + (iterate_device): Ignore devices listed in ctx->excludes. > + (FUNC_NAME): Accept excludes and nexcludes parameters. > + (grub_cmd_do_search): Pass empty excludes. > + * grub-core/commands/search_wrap.c (options): Add --exclude option. > + (grub_cmd_search): Handle --exclude. > + * include/grub/search.h (grub_search_fs_file): Update prototype. > + (grub_search_fs_uuid): Likewise. > + (grub_search_label): Likewise. > + * docs/grub.texi (search): Document --exclude. > + > 2013-12-11 Vladimir Serbinenko > =20 > * grub-core/normal/charset.c: Fix premature line wrap and crash. > diff --git a/docs/grub.texi b/docs/grub.texi > index 91fa1de..4c53665 100644 > --- a/docs/grub.texi > +++ b/docs/grub.texi > @@ -4731,7 +4731,8 @@ unbootable. @xref{Using digital signatures}, for = more information. > =20 > @deffn Command search @ > [@option{--file}|@option{--label}|@option{--fs-uuid}] @ > - [@option{--set} [var]] [@option{--no-floppy}] name > + [@option{--set} [var]] [@option{--no-floppy}] @ > + [@option{--exclude} @var{name} ...] name > Search devices by file (@option{-f}, @option{--file}), filesystem labe= l > (@option{-l}, @option{--label}), or filesystem UUID (@option{-u}, > @option{--fs-uuid}). > @@ -4743,6 +4744,10 @@ value of environment variable @var{var}. The de= fault variable is > The @option{--no-floppy} option prevents searching floppy devices, whi= ch can > be slow. > =20 > +The @option{--exclude} option excludes any matches of the given GRUB d= evice > +name. For example, this may be used to search for any file named > +@file{/boot/grub/grub.cfg} other than the one in a memdisk. > + > The @samp{search.file}, @samp{search.fs_label}, and @samp{search.fs_uu= id} > commands are aliases for @samp{search --file}, @samp{search --label}, = and > @samp{search --fs-uuid} respectively. > diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c > index 16143a3..03cfea1 100644 > --- a/grub-core/commands/search.c > +++ b/grub-core/commands/search.c > @@ -50,6 +50,8 @@ struct search_ctx > int no_floppy; > char **hints; > unsigned nhints; > + char **excludes; > + unsigned nexcludes; > int count; > int is_cache; > }; > @@ -59,8 +61,15 @@ static int > iterate_device (const char *name, void *data) > { > struct search_ctx *ctx =3D data; > + unsigned i; > int found =3D 0; > =20 > + for (i =3D 0; i < ctx->nexcludes; i++) > + { > + if (grub_strcmp (name, ctx->excludes[i]) =3D=3D 0) > + return 0; > + } > + This makes behaviour strongly dependent on the unstable names. In case of memdisk it's not a problem because its name is stable but outside this specific use it's easily misusable command. E.g. search --exclude=3Dhd0,1 would be heavily dependent on disk naming and won't work because this check considers hd0,1 and hd0,msdos1 as distict. The only way to sanely use this interface is to do sth like search --exclude $boot to find next configfile, a bit like include_next directive but it creates a problem that the same disk may have several names. E.g. LVM have names base on name and UUID. This doesn't handle some configs like 2 autodetecting scripts including each other. This is complex problem and I'm unsure how to solve it. --F71G2UsHA6wEGGtADwfiboaWCoSMHjSRP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iF4EAREKAAYFAlKq/TkACgkQmBXlbbo5nOuDeAD+KTHmiANe4bLXkKRRDG1VtzBF afJnogImJCJkPCTV01EBAJBxn5rUkQsEyqIMhK8kfmSHrtTIaMz2pnN+ZfLMuLpb =Mcq6 -----END PGP SIGNATURE----- --F71G2UsHA6wEGGtADwfiboaWCoSMHjSRP--