You are not logged in.

#1 2013-05-28 23:23:27

stefanhartman
Member
Registered: 2013-05-26
Posts: 14

[SOLVED] Udev rule shows up in "udevadm test" but doesn't work

Hi,

So I've created a udev rule:

/etc/udev/rules.d/00_local.rules

# Verander alsa default na 1 nadat usb ingeprop is, en terug na 0 nadat uitgeprop is
KERNEL=="pcmC[D0-9cp]*",  ACTION=="add", RUN="/bin/ln -s /etc/usb.asound.conf /etc/asound.conf"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", RUN="/bin/ln -s /etc/intel.asound.conf /etc/asound.conf"

I test the rule:

[stefan@stefan-laptop ~]$ udevadm test --action=add `udevadm info -q path -n /dev/snd/pcmC1D0p` | xsel

This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

ACTION=add
DEVNAME=/dev/snd/pcmC1D0p
DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb6/6-2/6-2:1.1/sound/card1/pcmC1D0p
MAJOR=116
MINOR=9
SUBSYSTEM=sound
TAGS=:uaccess:
USEC_INITIALIZED=1057906860
run: '/bin/ln -s /etc/usb.asound.conf /etc/asound.conf'
run: 'uaccess'

When I plug in the device though, the link (defined in RUN) is not created. I am pretty certain that the device that I'm actually plugging in and out is the one that I'm testing. I see the same DEVNAME when plugging in and out while monitoring with udevadm.

Any ideas why the '/bin/ln -s /etc/usb.asound.conf /etc/asound.conf' wont work? The files definitely exist by the way.

Also, atm my KERNEL== match is a bit ambiguous since the card has 2 devices, but that should not stop the rule from working I assume.

Last edited by stefanhartman (2013-05-30 13:02:48)

Offline

#2 2013-05-29 00:32:22

stefanhartman
Member
Registered: 2013-05-26
Posts: 14

Re: [SOLVED] Udev rule shows up in "udevadm test" but doesn't work

Ok so I managed to get some things working.
I followed advice on the internet and renamed the rule file, prepending a larger number (81). Doing that worked and I noticed in the test that the order of the two run commands were reversed (as expected). I have no idea what

run: 'uaccess'

does but I assume it overrode my run. To check that renaming was what solved the problem, I renamed it with lower numbers and back to 00_local.rules. The command ran every time so I thought renaming had no effect after all.
Anyway, while testing the previous I noticed that I forgot to add the force option to the ln command. I added it, plugged in and out to find that it had no effect. The link was still created if destination does not exist, but force not working. It was as though the old rule was still in effect. I tried changing the name again and "voila!"

Now I'm curious why changing the name works in the first place, but changing back to the old name doesn't break it.

Thanks if anyone cares to explain.

Offline

#3 2013-05-29 05:14:30

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Udev rule shows up in "udevadm test" but doesn't work

Should be RUN+= rather than just RUN.

Offline

#4 2013-05-29 13:21:40

stefanhartman
Member
Registered: 2013-05-26
Posts: 14

Re: [SOLVED] Udev rule shows up in "udevadm test" but doesn't work

brebs wrote:

Should be RUN+= rather than just RUN.

thanks. I forgot to mention I changed that also before my second post. ~I left it as '=' initially because I assumed nothing else needs to RUN. Changing it made no difference though as far as I remember.

Offline

#5 2013-05-29 15:48:05

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Udev rule shows up in "udevadm test" but doesn't work

Is /bin/ls still valid in Arch? I hear it's all moving to /usr/bin.

Anyway, to debug this, change to e.g. RUN+="/root/bin/myls", then put your ls command in /root/bin/myls instead (don't forget to chmod 700 it).

Then you can add a line to myls, such as "touch /tmp/lsran" to prove that your script did run. Which is good debugging info.

Edit: Also, should be ln -sf, to force.

Last edited by brebs (2013-05-29 15:51:16)

Offline

#6 2013-05-30 13:01:46

stefanhartman
Member
Registered: 2013-05-26
Posts: 14

Re: [SOLVED] Udev rule shows up in "udevadm test" but doesn't work

Well, after my second post I didn't find any new information and haven't made any progress. Since I managed to get the rule working (albeit without understanding why) I will mark the thread solved.

Thanks

Offline

Board footer

Powered by FluxBB