Where/when is /dev populated?
I have an openwrt dist with kernel 2.6.21 and busybox 1.4.2. I don't
get the permissions I want on some device nodes in /dev. Although I
can change those in an rc script, it would be nice to get the
permissions right from the start.
However, I cannot figure out where the device nodes are created... How
can I find that out?
Re: Where/when is /dev populated?
Le 10/04/08 16:51, dans
<e21f0c0a-4582-4d83-9da8-471e8554bcf4@1g2000prf.googlegroups.com>, «*John*»
<janzon@gmail.com> a écrit*:
[color=blue]
> However, I cannot figure out where the device nodes are created... How
> can I find that out?[/color]
A driver can use devfs_mk_cdev() function to create the dev entry and set
initial mode permissions.
--
Éric Lévénez -- <http://www.levenez.com/>
Unix is not only an OS, it's a way of life.
Re: Where/when is /dev populated?
John wrote:[color=blue]
> I have an openwrt dist with kernel 2.6.21 and busybox 1.4.2. I don't
> get the permissions I want on some device nodes in /dev. Although I
> can change those in an rc script, it would be nice to get the
> permissions right from the start.
>
> However, I cannot figure out where the device nodes are created... How
> can I find that out?[/color]
I'm only figuring this out myself, but I do know, the configurable
part of it, in 2.6 kernels, is run by udev, and configured by rule
files in /etc/udev/rules.d/*.rules
Good luck, Mel.
Re: Where/when is /dev populated?
Mel wrote:[color=blue]
> John wrote:[color=green]
>> I have an openwrt dist with kernel 2.6.21 and busybox 1.4.2. I don't
>> get the permissions I want on some device nodes in /dev. Although I
>> can change those in an rc script, it would be nice to get the
>> permissions right from the start.
>>
>> However, I cannot figure out where the device nodes are created... How
>> can I find that out?[/color]
>
> I'm only figuring this out myself, but I do know, the configurable
> part of it, in 2.6 kernels, is run by udev, and configured by rule
> files in /etc/udev/rules.d/*.rules[/color]
Its very simple. For tty the udev rule could look like this:
KERNEL=="tty", MODE="0666", GROUP="users"
Do you need special things for the serial devices? Add:
KERNEL=="ttyS0*", MODE="0640", GROUP="special"
KERNEL=="ttyS[1-9]*", MODE="0666", GROUP="users"
(first match wins. So ttyS0 gets other settings than all other ttyS devices)
And it works for all kind of devices.
JB
Re: Where/when is /dev populated?
In further news, we're trying to nail a particular device down to a
particular USB socket. For whatever reason, udev was coming up with
different KERNEL names on different boots. After a productive day
yesterday, we have a rule like
SUBSYSTEM=="usb", KERNELS=="2-1:1.0", DRIVERS=="ftdi_sio",
NAME="ourown/tty"
The application opens a connection to /dev/ourown/tty , and gets the
device consistently.
We had been dealing with the permissions thing by putting our user
into the dialout group which is automatically assigned. It's
inflexible, but it works as long as we don't need actual ttys on the
system. Good to know about GROUP= .
Also the commands udevinfo, which provides the magic names and values
to use in rules, and udevtest which lets you test rule files without
booting.
Mel.
Re: Where/when is /dev populated?
Mel wrote:
[color=blue]
> In further news, we're trying to nail a particular device down to a
> particular USB socket. For whatever reason, udev was coming up with
> different KERNEL names on different boots. After a productive day
> yesterday, we have a rule like
>
> SUBSYSTEM=="usb", KERNELS=="2-1:1.0", DRIVERS=="ftdi_sio",
> NAME="ourown/tty"[/color]
Why not using this?
KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", SYMLINK+="ourown/tty"
$ ls -la /dev/ourown/tty
lrwxrwxrwx 1 root root 10 Apr 11 14:00 /dev/ourown/tty -> ../ttyUSB0
$ ls -la /dev/ttyUSB0
crw-rw---- 1 root root 188, 0 Apr 11 14:00 /dev/ttyUSB0
Its my FTDI245 based device.
JB
Re: Where/when is /dev populated?
On Apr 11, 3:00*am, Mel <mwil...@the-wire.com> wrote:[color=blue]
> John wrote:[color=green]
> > However, I cannot figure out where the device nodes are created... How
> > can I find that out?[/color]
>
> I'm only figuring this out myself, but I do know, the configurable
> part of it, in 2.6 kernels, is run by udev, and configured by rule
> files in /etc/udev/rules.d/*.rules[/color]
I don't have /etc/udev... However, I found out that the permissions
can be specified in /etc/hotplug2-init.rules. Moreover, something
happens in /sbin/mount_root (a file with OpenWrt copyright): It is
concluded I have no devfs entry in /proc/filesystems, a tmpfs
filesystem is mounted and the hotplug2 daemon is started.
Don't know it that will ever help anyone :)