Re: Rules on how to use sysfs in userspace programs

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Kay Sievers
Date: Saturday, June 23, 2007 - 5:49 am

On 6/22/07, Rob Landley <rob@landley.net> wrote:

"It is planned to merge all three classification-directories into one
 place at /sys/subsystem/,  following the current layout of the
bus-directories."

Means that /sys/subsystem/ will have a devices/ directory, full of
symlinks to the devices, all in a flat list. Subsytem-global attribute
files/directories are not mixed with the devices in the same directory
like in /sys/class, it will also not contain any hierarchy like the
layout of /sys/block.


Yes, in this order (if you want to use it, but /sys/block will still be there):
  /sys/subsytem/block/devices/*
  /sys/class/block/*
  /sys/block/*/*


"one place at /sys/subsystem/"

Yes, it will be all pretty consistent, the event-environment contains
$SUBSYSTEM, we will  have /sys/subsystem/$SUBSYSTEM/devices/ directory
and at every device a symlink named "subsystem" pointing back to the
/sys/subsystem/$SUBSYSTEM/ directory.


If /sys/subsystem exists, just look at /sys/subsystem/*/devices/*, you
will find every kernel device here, with exactly the logic to access
it. Every device with a "dev" file, it is a char device, unless
$SUBYSTEM=="block".

If /sys/subsystem/ doesn't exist, you have to search all through
/sys/bus/, /sys/class/, /sys/block/, every directory with completely
different access pattern to find your device. You may want to look at
the udev code, it's all implemented there:
http://git.kernel.org/?p=linux/hotplug/udev.git;a=blob;f=udevtrigger.c;hb=HEAD#l498


Yeah, that's sysfs. It exports all the useless kernel implementation
details, so that _what_not_to_do_ is the biggest problem we have. :)
There is much too much internal stuff available here, that never can
be kept stable in the usual sense, as long as we allow to change
kernel/driver internals at the same time.


It was a first cut, I did months ago, and sure, it needs some work.

Thanks,
Kay
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Rules on how to use sysfs in userspace programs, Jan Engelhardt, (Sat Jun 9, 12:42 am)
Re: Rules on how to use sysfs in userspace programs, Alexander E. Patrakov, (Sat Jun 9, 5:32 am)
Re: Rules on how to use sysfs in userspace programs, Kay Sievers, (Sat Jun 9, 10:27 am)
Re: Rules on how to use sysfs in userspace programs, Jesper Juhl, (Sat Jun 9, 1:08 pm)
Re: Rules on how to use sysfs in userspace programs, Theodore Tso, (Sun Jun 10, 7:02 am)
Re: Rules on how to use sysfs in userspace programs, Randy Dunlap, (Sun Jun 10, 9:56 am)
Re: Rules on how to use sysfs in userspace programs, Kay Sievers, (Sun Jun 10, 1:55 pm)
Re: Rules on how to use sysfs in userspace programs, Rob Landley, (Fri Jun 22, 2:46 pm)
Re: Rules on how to use sysfs in userspace programs, Kay Sievers, (Sat Jun 23, 5:49 am)
Re: Rules on how to use sysfs in userspace programs, Rob Landley, (Sat Jun 23, 6:31 pm)
Re: Rules on how to use sysfs in userspace programs, Kay Sievers, (Sun Jun 24, 4:03 am)
Re: Rules on how to use sysfs in userspace programs, Rob Landley, (Sun Jun 24, 12:24 pm)
Re: Rules on how to use sysfs in userspace programs, Kay Sievers, (Mon Jun 25, 7:57 am)
Re: Rules on how to use sysfs in userspace programs, Rob Landley, (Mon Jun 25, 11:14 am)