mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Theodore Tso <tytso@mit.edu>, Greg KH <greg@kroah.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Rules on how to use sysfs in userspace programs
Date: Sun, 10 Jun 2007 22:55:47 +0200	[thread overview]
Message-ID: <1181508947.4566.62.camel@lov.localdomain> (raw)
In-Reply-To: <20070610095643.c1435a74.randy.dunlap@oracle.com>

On Sun, 2007-06-10 at 09:56 -0700, Randy Dunlap wrote:
> On Sun, 10 Jun 2007 10:02:00 -0400 Theodore Tso wrote:
> 
> > On Fri, Jun 08, 2007 at 01:36:37PM -0700, Greg KH wrote:
> > > The kernel exported sysfs exports internal kernel implementation-details
> > > and depends on internal kernel-structures and layout. It is agreed upon
> > > kernel developers, that the Linux kernel does not provide a stable
> > > internal API.  As sysfs is a direct export of kernel internal
> > > structures, the sysfs interface can't provide a stable interface too, it
> > > may always change along with internal kernel changes.
> > 
> > I want to step back and ask a very fundamental philosophical question
> > --- who are the intended users of sysfs?  If it exports an interface,
> > part of which is known not be stable, except for backwards
> > compatibility issues, why and to whom are we exporting them?
> 
> I agree that stepping back and asking questions is the right thing
> to do here.
> 
> /proc also reports lots of kernel internals, yet it is required
> to maintain compatibility.
> 
> ISTM that sysfs should allow additions, but only in ways that don't
> break backwards compatibility.  I.e., it should maintain backwards
> compatible interfaces when new ones are added.  Yeah, that means
> leave some crud around.  Yes, it may be as bad as /proc, but I've
> said that for quite awhile.

We try hard to keep the properties of the exported devices and the
classification directories stable, but sysfs is an one-to-one export of
the kernels object-model and unfortunately not a list of artificially
flat files like /proc. I don't see how a tree of directories, directly
created by a kernel that change that insanely fast, can be kept stable.

There is also a big difference to /proc: the /sys layout itself can even
change at runtime, some devices can be renamed, and others move around
and change their devpath in the tree while they are active. In /sys, the
_location_ of the information itself is not stable, only if you follow
some rules how to extract information from the tree, you will be able to
find it reliably.

Users need to follow some rules how to access information in the /sys
tree, and sure, it is far more complicated than reading /proc. That's
what this document tries to explain. It tries to document the rules,
kind of similar to the (simple and intuitive) rule for /proc, that files
need to be parsed for keys, instead of just assuming that the order of
information is always the same, or the content of the files always
contain the same keys.

Sysfs today exports all the completely useless implementation details of
the kernel. The recent changes, and the work-in-progress to move
everything into _one_ single device tree (/sys/devices) and _one_
symlinks-only based classification (/sys/subsystem) should make it much
easier to keep the same information around, even when things in the
kernel object-tree keep changing at the current rate. 

This document just tries to describe the real world today. If you have
any better idea, on how to export an internal device-tree from a kernel
that changes every hour and subsystems come and go, get replaced and get
changed all the time, we are more that happy to improve things here. :)

Thanks,
Kay


  reply	other threads:[~2007-06-10 20:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-08 20:36 Greg KH
2007-06-09  7:42 ` Jan Engelhardt
2007-06-09 12:32 ` Alexander E. Patrakov
2007-06-09 17:27   ` Kay Sievers
2007-06-09 20:08 ` Jesper Juhl
2007-06-10 14:02 ` Theodore Tso
2007-06-10 16:56   ` Randy Dunlap
2007-06-10 20:55     ` Kay Sievers [this message]
2007-06-22 21:46 ` Rob Landley
2007-06-23 12:49   ` Kay Sievers
2007-06-24  1:31     ` Rob Landley
2007-06-24 11:03       ` Kay Sievers
2007-06-24 19:24         ` Rob Landley
2007-06-25 14:57           ` Kay Sievers
2007-06-25 18:14             ` Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1181508947.4566.62.camel@lov.localdomain \
    --to=kay.sievers@vrfy.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=randy.dunlap@oracle.com \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®