Re: Generic battery interface

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

 



On 7/30/06, Greg KH <[email protected]> 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux