Re: Rules on how to use sysfs in userspace programs

Rob Landley
2007-06-22T21:46:12Z

On Friday 08 June 2007 16:36:37 Greg KH wrote:
> Over time there have been a number of problems when sysfs has changed in
> "unexpected" ways. Here's a document that Kay wrote a while ago that
> I'd like to add to the kernel Documentation directory to help userspace
> programmers out.
>
> Any comments or critique of this is greatly appreciated.

Still catching up from my laptop dying.

I find the explanation of /sys/subsystem almost unintelligible. What will the
new one actually look like?

If I want to find all block devices in the system, it looks like I should now
look at /sys/subsystem/block. (And "subsystem" is not a variable here but
the actual directory name? I presume it moved for Feng Shui reasons.)

If I want to find char devices, where do I look? /sys/subsystem... char?
class? Is a char device now anything under /sys/subsystem that is _not_
in /sys/subsystem/block? (Minus bus devices?) Is there a specific directory
for these?

This document is highly polluted with what NOT to do. I'm looking for a
clear "what SHOULD I do", and it takes some wading to find it. (Historical
cruft about what not to do is potentially a separate document, it's not
useful for people learning this stuff now who weren't playing with the legacy
mechanisms.) The description of /sys/subsystem spends so much time talking
about old legacy issues it never gives a clear description of the new way of
doing things, which is theoretically what this document is about...

Rob
--
"One of my most productive days was throwing away 1000 lines of code."
- Ken Thompson.