$attr substitution for parent devices

Cedric Jehasse <[email protected]>
Newsgroups gmane.linux.hotplug.devel
Message-ID <CABvLYuDXVepqrHuJxr0eUp7Ezr6VGWaYsec3h=5sPVFPrZn0Ag@mail.gmail.com>
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
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.