All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Watson <cjwatson@ubuntu.com>
To: grub-devel@gnu.org
Subject: Re: RFC: Plan for new "hwmatch" command
Date: Thu, 18 Nov 2010 18:20:48 +0000	[thread overview]
Message-ID: <20101118182048.GP21862@riva.ucam.org> (raw)
In-Reply-To: <4CE50EC4.3020705@gmail.com>

On Thu, Nov 18, 2010 at 12:32:20PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 11/18/2010 05:58 AM, Evan Broder wrote:
> > As a strawman, I propose adding the "hwmatch" command:
> >
> >   Usage: hwmatch MATCHLIST [BASECLASS]
> >
> > MATCHLIST is a file containing a list of hardware identifiers.
> > BASECLASS is a PCI base class code. If specified, only PCI devices
> > with that base class will be checked. hwmatch returns 0 if any PCI
> > device in the system is listed in MATCHLIST, and 1 otherwise.
> >
> > MATCHLIST has one device per line with the following space-separated
> > fields: base class, subclass, vendor ID, device ID, subsystem vendor
> > ID, subsystem device ID. The first two fields are 2 hex digits; the
> > other fields are 4 hex digits. Any field can be replaced by a single
> > '*' to indicate a wildcard.
> 
> This has a problem of multiple matches in both white and black list. To
> disambigute such thing you would need some logic.

I hadn't been expecting to have both a whitelist and blacklist in
existence at once.  That said, thinking about it, I can imagine that we
might want to say something like "all Intel cards, except for these
particular devices".

> Also having a command dedicated to this seems ad-hoc. I think
> something more along the lines of extending scripting is better. So
> you'd have something like:
> iterate_pci {
>    classid=$1
>    vendorid=$2
>    deviceid=$3
>    if [ x$classid != x<CLASS> ]; then
>        continue
>    fi
>    case x$vendorid
>       <VEN1>) .... ;;
>       <VEN2>) .... ;;
>    esac
> }
> I'd recommend to have this code in a separate hwconfig.cfg for convenience.
> We already have the necessary infrastructure to implement iterate_pci
> without touching the scripting code. "continue" though will need a bit
> of extension to work in iterate_pci. "case" isn't implemented yet but we
> already have pattern matching, the main issue is the arrival of new
> terminal ";;" and proper handling of it. Some logic with && and || would
> come in handy too.

I agree with you to some extent that a new command seems rather ad-hoc.
On the other hand, I suspect that the configuration might grow rather
large, and I'm concerned about performance; it doesn't seem to me that
implementing this entirely in code would be likely to be very fast.  If
I were doing this in a POSIX shell script, I wouldn't use a giant case
statement.

Maybe it would be worth having a 'grep' command?  You could probably
implement this as a fairly large regex assuming that you didn't mind the
wildcards being a little inflexible (you'd only be able to use a
wildcard for an entire field, not for substrings).  Then you'd have a
logic file plus a data file that it searches, and you wouldn't have to
put lengthy strings of data in the logic file.

It might be worth prototyping this in POSIX shell with fairly minimal
utilities, to see which utilities we would need to add to GRUB to make
this possible.

(Of course, there's still the option of carrying this as an Ubuntu
patch, and advertising it as having an unstable interface.  I'd rather
avoid that if we can figure out a good upstream design for this,
though.)

-- 
Colin Watson                                       [cjwatson@ubuntu.com]


  reply	other threads:[~2010-11-18 18:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18  4:58 RFC: Plan for new "hwmatch" command Evan Broder
2010-11-18 11:32 ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-11-18 18:20   ` Colin Watson [this message]
2010-11-19  3:52 ` Brendan Trotter
2010-11-19  4:12   ` Evan Broder
2011-03-29 20:40 ` Colin Watson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101118182048.GP21862@riva.ucam.org \
    --to=cjwatson@ubuntu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.