You are not logged in.

#1 2006-09-16 19:30:36

mips
Member
Registered: 2006-09-16
Posts: 11
Website

udev ignoring my rules [SOLVED]

hi, i'm new to the forum but i'm a long time arch user.
my question is about udev. i own a zen micro, a mp3 player i can upload to through usb and with the app gnomad2. gnomad2 is a bit buggy but usable. the problem is, when i plug my zen micro through usb the device permissions are set to root/root by udev and this means i also have to run gnomad2 as root to access my mp3 player.
i copied the files nomad.rules in /etc/udev/rules.d/ and udev seems to ignore it, it still sets the permissions to root/root, though in nomad.rules there's a MODE="666" in the zen micro line.

how can i know (at least) if udev is considering my rules? it doesn't find any errors in the loaded rules.

here's the contents of nomad.rules (hope it's not too long):

# ACTION=="add", SUBSYSTEM=="usb_device",
  PROGRAM="/bin/sh -c 'K=%k; K=$${K#usbdev};
  printf bus/usb/%%03i/%%03i $${K%%%%.*} $${K#*.}'",
  NAME="%c", MODE="0644"

# Old erroneous rule used for debug purposes.
# ACTION=="add", SUBSYSTEM=="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c", RUN="/home/linus/bin/boxplugin %c"

SUBSYSTEM!="usb_device", ACTION!="add", GOTO="nomad_rules_end"

# Creative Nomad Jukebox
SYSFS{idVendor}=="0471", SYSFS{idProduct}=="0222", MODE="666"
# Creative Nomad Jukebox 2
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4100", MODE="666"
# Creative Nomad Jukebox 3
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4101", MODE="666"
# Creative Nomad Jukebox Zen
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4108", MODE="666"
# Creative Nomad Jukebox Zen USB 2.0
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="410b", MODE="666"
# Creative Nomad Jukebox Zen NX
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4109", MODE="666"
# Creative Nomad Jukebox Zen Xtra
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4110", MODE="666"
# Dell Digital Jukebox
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4111", MODE="666"
# Creative Nomad Jukebox Zen Touch
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="411b", MODE="666"
# Creative Zen (Zen Micro variant)
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="411d", MODE="666"
# Creative Nomad Jukebox Zen Micro
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="411e", MODE="666"
# Second Generation Dell Digital Jukebox
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4126", MODE="666"
# Dell Pocket DJ
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4127", MODE="666"
# Creative Zen Sleek
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="4136", MODE="666"
# Third Generation Dell Digital Jukebox
SYSFS{idVendor}=="041e", SYSFS{idProduct}=="412f", MODE="666"

LABEL="nomad_rules_end"

Offline

#2 2006-09-16 20:36:01

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

Not sure if its a kernel or udev thing lately I cannot use my udev rules ... node is created ok ...

To mount my ipod I use pmount /dev/ipod ...

BUS=="usb", SYSFS{product}=="iPod", KERNEL=="sd?2", NAME="%k", SYMLINK+="ipod", MODE="0660", GROUP="users"
ACTION=="add", KERNEL=="sd?2", RUN+="/bin/mount /dev/ipod /media/ipod"  
ACTION=="remove", KERNEL=="sd?2", RUN+="/bin/umount /dev/ipod" 

here is mine if its any help.....


Mr Green

Offline

#3 2006-09-16 23:20:42

mips
Member
Registered: 2006-09-16
Posts: 11
Website

Re: udev ignoring my rules [SOLVED]

thanks for the reply, but i cannot use that 'cause the creative zen micro (and all other devices using the same protocol, like the nomad jukebox) don't work as usb mass storage devices, ie you can't mount them like usb pens. gnomad2 communicates through the usb cable and sends commands to upload media.

if it helps, i can manually cd to the directory where the node is created (under /dev/bus/usb) and chmod the node to 666, but i'd prefer not to. all in all it's simpler to run gnomad2 as root, but i'd prefer to run it as user like everything else.

Offline

#4 2006-09-16 23:44:17

mips
Member
Registered: 2006-09-16
Posts: 11
Website

Re: udev ignoring my rules [SOLVED]

i solved the problem adding

GROUP="users"

just before

MODE="666"

gnomad2 now has read/write access to the device. i don't know why, the parameter MODE="666" should allow anybody to read/write to the device. thanks anyway smile
maybe someone knows why, i'll check for replies.

Offline

#5 2006-09-16 23:45:56

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: udev ignoring my rules [SOLVED]

Mr Green wrote:

Not sure if its a kernel or udev thing lately I cannot use my udev rules ... node is created ok ...

To mount my ipod I use pmount /dev/ipod ...

BUS=="usb", SYSFS{product}=="iPod", KERNEL=="sd?2", NAME="%k", SYMLINK+="ipod", MODE="0660", GROUP="users"
ACTION=="add", KERNEL=="sd?2", RUN+="/bin/mount /dev/ipod /media/ipod"  
ACTION=="remove", KERNEL=="sd?2", RUN+="/bin/umount /dev/ipod" 

here is mine if its any help.....

pmount mounts the device for the user who issued the pmount command. so in this case, it'll be run as root, so only root will have access. you'd be best using sudo and your user.

James

Offline

#6 2006-09-17 09:57:31

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

yeah lol .. I found that out when I put pmount in me udev rule ... though I was being clever ....

Not into dbus hal hotplug rofl ... pmount is a safe way to mount stuff (does not touch fstab !)

Have had a rule (from wiki) that loads ok ... maybe I should check it out again

Not always upto date though

Thanks


Mr Green

Offline

#7 2006-09-17 10:05:30

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: udev ignoring my rules [SOLVED]

Mr Green wrote:

yeah lol .. I found that out when I put pmount in me udev rule ... though I was being clever ....

Not into dbus hal hotplug rofl ... pmount is a safe way to mount stuff (does not touch fstab !)

Have had a rule (from wiki) that loads ok ... maybe I should check it out again

Not always upto date though

Thanks

hal based things simply use hal to discover when something has been plugged in, whether they touch the fstab has nothing to do with the fact they use hal. ivman uses pmount to mount wink

James

Offline

#8 2006-09-17 10:22:13

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

Dude I have never had any luck with hal dbus hotplug autofs ivman  lol

I amy be wrong but automounting stuff in like in Gnome & KDE

But man I would flamed by Tomk if I did not mount stuff from cli rofl


Mr Green

Offline

#9 2006-09-17 12:02:19

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: udev ignoring my rules [SOLVED]

mips wrote:

i solved the problem adding

GROUP="users"

just before

MODE="666"

gnomad2 now has read/write access to the device. i don't know why, the parameter MODE="666" should allow anybody to read/write to the device. thanks anyway smile
maybe someone knows why, i'll check for replies.

When you're writing your own udev rules always remember that newest udev versions are processing rules one by one which means that the rule that is processed ealier can be overwritten by the next rule for the same device (for example a rule from udev.rules file can overwrite values from your nomad.udev.rules file). You can do several things to prevent it:

1. Name your file starting with for example x like x.nomad.rules.udev and it will be processed after udev.rules file.

2. Leave the name as it is and add OPTIONS="last_rule" to your custom rule. This will stop processing any other rules for this device. Use only when you know what you're doing because you can prevent some important rule to be processed.

3. Use newest udev syntax. Fro example change all "=" to ":=" (MODE:="666"). This will prevent udev to overwrite this field's value (and only this field) by some other udev rules processed after your custom rule. Standard rules usually use "=" (which overwrites values) or "+=" which aggregates values (if multiple values are allowed for a given field of course).

The best option to start with when writing custom udev rules is IMHO no 3. If this does not work then your custom rule is most probably not executed at all and you need to change fields values ("==").

Offline

#10 2006-09-17 12:30:52

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

Mr Lanrat ,,,, would you be so kind as to clean up me ipod rule....

Have used your wiki one .. from time to time would be nice to have my ipod plug & play ;-)

TIA


Mr Green

Offline

#11 2006-09-18 10:18:42

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: udev ignoring my rules [SOLVED]

Sure, but what's the problem? :-) What's wrong with your rule? Does it work at all or not ?
I don't have an ipod (I'm using mp3 player from my gsm phone or card reader). The only thing in the rule above that should be changed is this

MODE="0660", GROUP="users"

The new syntax would be:

MODE:="0660", GROUP:="users"

assuming that you always want to only mount partition no 2 (I guess partition no 1 is not for music files?). Also, since you're not using sync in mount options you need to run sync from cli before disconnecting ipod.

If you have other udev problems describe them in details and I'll try to help.

Offline

#12 2006-09-18 10:48:01

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

thats what confusing .... changed the rules ... why don't they use XML & be done with it lol

First it went '=' then '==' now ':='

bring back hotplug ....

Yeah my rule is above in this thread,.... node gets created but not mounted ...

as was said pmount in a rule is for root only .. so I changed it to mount ...

Not sure now if wiki rule is up to date ....

thoughts?


Mr Green

Offline

#13 2006-09-18 11:33:18

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: udev ignoring my rules [SOLVED]

Mr Green wrote:

thats what confusing .... changed the rules ... why don't they use XML & be done with it lol

oh god no ughhhhhhh. we dont need an xml parser invading early userspace too.

First it went '=' then '==' now ':='

bring back hotplug ....

Yeah my rule is above in this thread,.... node gets created but not mounted ...

as was said pmount in a rule is for root only .. so I changed it to mount ...

Not sure now if wiki rule is up to date ....

thoughts?

well im pretty sure you can still use hotplug. udev is maturing, but its already far better than the unmaintained mess hotplug was.

James

Offline

#14 2006-09-18 13:37:01

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

true never go back

Might be idea to update wiki page on udev....

Whats wrong with XML rofl


Mr Green

Offline

#15 2006-09-18 18:26:04

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: udev ignoring my rules [SOLVED]

Mr Green wrote:

Whats wrong with XML rofl

everything... seriously!

I'm not a fan of every app having it's own config file syntax but we can do better than XML.

Offline

#16 2006-09-18 20:44:29

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

No... I use in OB so I'm kinda used to it. .. not every config emmm rc.conf in XML ouch!!!


Mr Green

Offline

#17 2006-09-19 11:06:23

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: udev ignoring my rules [SOLVED]

Mr Green wrote:

thats what confusing .... changed the rules ... why don't they use XML & be done with it lol

I doesn't "solve" the problem (but there is no problem). It's only a file syntax.

Mr Green wrote:

First it went '=' then '==' now ':='

These are different things. "=" means that a value is assigned to a field and this value can be changed by another udev rule (processed after this rule). ":=" meas that the value of the field can't be changed by other rules (this is a new thing in udev). "==" is only for comparing values and this is completly different thing.

Mr Green wrote:

bring back hotplug ....

But it's still there. Only hotplug scripts were removed. Hotplug scipts did more or less same things that RUN filed does in udev but they had to be programmed for each device while udev rules are only "configured". It's better to have a standard syntax IMHO.

In the end it's not really that different.
It's like with regular expressions. They look scary at the begining but once you know them you'll love them :-)

Mr Green wrote:

Yeah my rule is above in this thread,.... node gets created but not mounted ...

The node or the symlink? (/dev/sd?2 and/or /dev/ipod)
Do you have /media/ipod directory already created ?
Can you mount /dev/sd?2 /media/ipod from the command line as root?
Does it work when you add SYSFS{product}=="iPod" (btw are you sure that's the correct value? No spaces before or after iPod? It's generally better to use idProduct and idVendor pair IMO - whats the output of lsusb when you plugin your ipod?) to both ACTION rules (currently they'll try to mount/umount any sd?2 device which might prevent ipod device to mount there too)?
What kind of partition type is this /dev/sd?2 for ipod? Is this vfat ?

Mr Green wrote:

as was said pmount in a rule is for root only .. so I changed it to mount ...

You can try to run it with sudo -u mrgreenusername and it should run as your user but I'm not sure if it works from udev. You just need to test it. Still, before unplugging ipod you need to run sync from cli to prevent data loss (unless pmount uses sync option for mounting but this will slow down the transfer of files to your ipod).

Mr Green wrote:

Not sure now if wiki rule is up to date ....

I've upgraded it not so long ago so it should work - it uses OPTION="last_rule" and it's still valid.

Offline

#18 2006-09-19 14:45:11

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

Hi,

thanks man for explaing it do me ..

O err yes /dev/ipod gets created have got a /media/ipod dir set up (but pmount will create it!)

just at the moment I use pmount to mount ipod rules does not do it yet ...

May try your rule again (edit it first lol) ...


Mr Green

Offline

#19 2006-10-06 18:40:35

kozaki
Member
From: London >. < Paris
Registered: 2005-06-13
Posts: 673
Website

Re: udev ignoring my rules [SOLVED]

Is it true that dbus + hal now have to be started at boot with no '@' in /etc/rc.conf ?

I've read 'readme-udev-arch.txt' 3-4 times now, but as it is naturally more general than the wiki, I just can't but get it mixed, and my former [Lanrat's wink] rules are unusable (*)
As an example the fact that "udev" and "Using udev to map multiple entries to a device" articles still show ==, =, += make editing custom rules very uncomfortable, and I'm just too confused to want to edit it myself :shock:

Would someone eventually edit the wiki with new udev syntax ?

(*) My former rules, now unusable

# DD USB Maxtor 160GB
# ATTRS{vendor}=="Maxtor 6" - ATTRS{serial}=="DEF1091BE9A1" - ATTRS{model}=="B160P0          "
SUBSYSTEMS=="usb", ATTRS{serial}=="DEF1091BE9A1", KERNEL=="sd?", NAME:="%k", SYMLINK+:="usbdd", GROUP:="storage"
SUBSYSTEMS=="usb", ATTRS{serial}=="DEF1091BE9A1", KERNEL=="sd?[1-9]", NAME:="%k", SYMLINK+:="usbdd%n", GROUP:="storage"

Seeded last month: Arch 50 gig, derivatives 1 gig
Desktop @3.3GHz 8 gig RAM, linux-ck
laptop #1 Atom 2 gig RAM, Arch linux stock i686 (6H w/ 6yrs old battery smile) #2: ARM Tegra K1, 4 gig RAM, ChrOS
Atom Z520 2 gig RAM, OMV (Debian 7) kernel 3.16 bpo on SDHC | PGP Key: 0xFF0157D9

Offline

#20 2006-10-06 18:51:53

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

BUS=="usb", SYSFS{product}=="iPod", KERNEL=="sd?2", NAME="%k", SYMLINK+="ipod", MODE="0660", GROUP="users"

creates /dev/ipod linked to /dev/sd?2

that works for me .... mind you I still mount using pmount ....


Mr Green

Offline

#21 2006-10-06 19:08:54

kozaki
Member
From: London >. < Paris
Registered: 2005-06-13
Posts: 673
Website

Re: udev ignoring my rules [SOLVED]

Mr Green what about the new udev syntax ? wink

You see the rule I quoted up here did create /etc/[usbdriveN], allowing me to manually (well --> gkrelm wink ) mount those partitions allways on the same devices.
For my own use I've never be a fan of auto(u)mounting devices (even if it's good to know to help other configure their stuff the way they like/need it)


Seeded last month: Arch 50 gig, derivatives 1 gig
Desktop @3.3GHz 8 gig RAM, linux-ck
laptop #1 Atom 2 gig RAM, Arch linux stock i686 (6H w/ 6yrs old battery smile) #2: ARM Tegra K1, 4 gig RAM, ChrOS
Atom Z520 2 gig RAM, OMV (Debian 7) kernel 3.16 bpo on SDHC | PGP Key: 0xFF0157D9

Offline

#22 2006-10-06 19:32:58

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

SUBSYSTEMS=="usb", ATTR{product}=="iPod", KERNEL=="sd?2", NAME="%k", SYMLINK+="ipod", MODE="0660", GROUP="users"

Surprise it does not work any more .... unless attr is wrong now ....

EDIT it is should be attrs  :oops:


Mr Green

Offline

#23 2006-10-07 11:34:07

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: udev ignoring my rules [SOLVED]

kozaki wrote:
SUBSYSTEMS=="usb", ATTRS{serial}=="DEF1091BE9A1", KERNEL=="sd?", NAME:="%k", SYMLINK+:="usbdd", GROUP:="storage"
SUBSYSTEMS=="usb", ATTRS{serial}=="DEF1091BE9A1", KERNEL=="sd?[1-9]", NAME:="%k", SYMLINK+:="usbdd%n", GROUP:="storage"

There is no such thing as "+:=" - these symlinks will not be created.

In SYMLINKS you can use "+=" or ":=".
I would suggest using "+=" unless you suspect there is somewhere another rule that overwrites your rule (for example uses "=" or ":=").

Offline

#24 2006-10-07 11:49:21

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,914
Website

Re: udev ignoring my rules [SOLVED]

Using_udev_to_map_multiple_entries_to_a_device has been updated

thanks again lanrat ;-)


Mr Green

Offline

Board footer

Powered by FluxBB