[ltp] Re: Generic battery interface

Shem Multinymous linux-thinkpad@linux-thinkpad.org
Sun, 30 Jul 2006 12:52:52 +0300


On 7/30/06, Greg KH <greg@kroah.com> wrote:
> > >Forgive my ignorance, but how do I conncet a sysfs directory with a /dev
> > >device?

> Just look at the "dev" file in sysfs, which shows the major:minor
> number.

Then to find the match for a given device node you need to enumerate /sys.
And to find a match for a given /sys device you need to enumerate
/dev, or some its subdirectories (/dev/{snd,input,...), or whatever
other random places people have decided to place their device nodes.


> Or just look at the directory that you are in, and that's almost always
> the /dev node name.
>
> For example, /sys/block/sda/sda1/ is /dev/sda1.
> /sys/class/tty/ttyS1 is /dev/ttyS1.

Yeah, and /sys/block/sr0 is /dev/scd0 (FC5 default udev rules).


> It's usually not that difficult to do the mapping :)

Hmm, "usually"...


Coming to think of it, to solve the dev->sys direction, maybe we
should have symlinks like the following?
/sys/dev/8/0 -> /sys/block/sda
/sys/dev/11/0 -> /sys/block/sr0
/sys/dev/116/24 -> /sys/class/sound/pcmC0D0c


Put otherwise:
Q:Quick, which io scheduler is used by /dev/scd0?
A: cat /sys/dev/$((0x`stat -c%t /dev/scd0`))/\
                $((0x`stat -c%T /dev/scd0`))/queue/scheduler

(Please excuse the ugly hex to dec conversion.)


  Shem