linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cedric Jehasse <cedric.jehasse@gmail.com>
To: linux-hotplug@vger.kernel.org
Subject: $attr substitution for parent devices
Date: Mon, 27 Aug 2012 08:16:41 +0000	[thread overview]
Message-ID: <CABvLYuDXVepqrHuJxr0eUp7Ezr6VGWaYsec3h=5sPVFPrZn0Ag@mail.gmail.com> (raw)

Hi,

I have the following rules file:
#######################################################################################
ACTION!="add", GOTO="modeswitch_rules_end"
SUBSYSTEM!="usb", GOTO="modeswitch_rules_end"

ATTRS{bDeviceClass}="08", GOTO="modeswitch_rules_begin"
ATTRS{bInterfaceClass}="08", GOTO="modeswitch_rules_begin"
GOTO="modeswitch_rules_end"

LABEL="modeswitch_rules_begin"

ATTRS{idVendor}="12d1", ATTRS{idProduct}="1003",
RUN+="/usr/sbin/usb_modeswitch -c
/etc/usb_modeswitch.d/$attr{idVendor}:$attr{idProduct}"
ATTRS{idVendor}="12d1", ATTRS{idProduct}="1414",
RUN+="/usr/sbin/usb_modeswitch -c
/etc/usb_modeswitch.d/$attr{idVendor}:$attr{idProduct}"
ATTRS{idVendor}="12d1", ATTRS{idProduct}="1446",
RUN+="/usr/sbin/usb_modeswitch -c
/etc/usb_modeswitch.d/$attr{idVendor}:$attr{idProduct}"

LABEL="modeswitch_rules_end"
########################################################################################

When the matching rule is not the last rule in the file, $attr is
substituted by an empty string.
I've found out that by the time the RUN format gets applied
event->dev_parent is NULL, so it doesn't find the attributes for
substitution.
In udev_rules_apply_to_event event->dev_parent is used to loop over
the parent devices. If there are multiple rules trying to match parent
properties, event->dev_parent will be reset to NULL when there's a
non-matching rule following a matching rule.

Is this the expected behavior or not?
In this case the logical thing to do would be to substitute the format
while processing the rules. But the man-page says there are reasons to
 apply the RUN format after all rules have been processed.

thanks,
Cedric

                 reply	other threads:[~2012-08-27  8:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CABvLYuDXVepqrHuJxr0eUp7Ezr6VGWaYsec3h=5sPVFPrZn0Ag@mail.gmail.com' \
    --to=cedric.jehasse@gmail.com \
    --cc=linux-hotplug@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).