Re: udev rule, continue to next rule only if preb failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Greetings,

> Sent: Friday, May 26, 2023 at 12:02 PM
> From: "daggs" <daggs@xxxxxxx>
> To: "Lennart Poettering" <lennart@xxxxxxxxxxxxxx>
> Cc: systemd-devel@xxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  udev rule, continue to next rule only if preb failed
>
> Greetings Lennart,
>
> > Sent: Friday, May 26, 2023 at 11:23 AM
> > From: "Lennart Poettering" <lennart@xxxxxxxxxxxxxx>
> > To: "daggs" <daggs@xxxxxxx>
> > Cc: systemd-devel@xxxxxxxxxxxxxxxxxxxxx
> > Subject: Re:  udev rule, continue to next rule only if preb failed
> >
> > On Do, 25.05.23 20:25, daggs (daggs@xxxxxxx) wrote:
> >
> > > Greetings,
> > >
> > > I'm trying to implement the following behavior:
> > > if a usb is added ot removed, run a script before all other existing rules but continue to existing iff the script failed
> > > I've added the following rule to /etc/udev/rules.d/5-usb_vm.rules:
> > > ACTION=="add", SUBSYSTEM=="usb", RUN="/usr/local/bin/handle_udev_action"
> > > ACTION=="remove", SUBSYSTEM=="usb", RUN="/usr/local/bin/handle_udev_action"
> > >
> > > /usr/local/bin/handle_udev_action runs exit 1 iff the device is a specific one (for testing)
> > > but the code continues to the next rule.
> > > is there any way to stop it if the script returned 9?
> >
> > Please see documentation. RUN= is invoked *after* the rules have
> > finished execution.
> >
> > There's IMPORT{program}=, which is run as part of rule processing, but it can only be used for very quickly
> > running programs, and you have to communicate results of your script
> > via properties you write to stdout rather than exit status.
> >
> > Lennart
> >
> > --
> > Lennart Poettering, Berlin
> >
>
> thank you for the information, I'll into it
>
> Dagg
>

I was able to implement the first part (the detection and action) using import without any issues.
but I'm wondering if I can prevent execution of the rest of the rules without changing the default usb rule files.
I think it might be done with the goto directive, however I'm nor sure I understand how a goto in file one at /etc/udev/rules.d affects another rule which gets executed later at /lib/udev/rules.d/
maybe udev knows it by noticing the rules are using shared subsystem and action?

Thanks,

Dagg




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux