public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Theodore Tso <tytso@mit.edu>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org, Kay Sievers <kay.sievers@vrfy.org>
Subject: Re: Rules on how to use sysfs in userspace programs
Date: Sun, 10 Jun 2007 10:02:00 -0400	[thread overview]
Message-ID: <20070610140200.GD9726@thunk.org> (raw)
In-Reply-To: <20070608203637.GA9259@kroah.com>

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?

If the answer is "no one", then maybe modulo backwards compatibility
issues, we should only export via sysfs those things that are
guaranteed to be a stable interface.  Or maybe there should be a mount
option that filters out anything which isn't guaranteed to be stable,
so that user programs can easily determine if they are using anything
"bad" --- and then a year or two from now, we make that mount option
the default, and require a mount option if people want to see the
unstable bits of sysfs.

Way back in 2003, Rusty's OLS keynote talked at great length about
kernel design and interface similicity as a hallmark of good design:

    1. Compiler/linker won't let you get it wrong.
    2. Compiler will warn if you get it wrong.
    3. The simplest use is the correct one.
    4. The name tells you how to use it.
    5. Do it right or it will break at runtime.
    6. Follow common convention and you'll get it right.
    7. Read the documentation and you'll get it right.
    8. Read the implementation and you'll get it right.
    9. Read the correct mailing list thread and you'll get it right.
    10. Read the documentation and you'll get it wrong.
    11. Follow common convention and you'll get it wrong.
    12. Do it right and it will break at runtime.
    13. The name tells you how not to use it.
    14. The obvious use is wrong.
    15. Compiler will warn if you get it right.
    16. Compiler won't let you get it right.
    17. It's impossible to get right. 

The documentation is a good step, but wouldn't it be better if we can
prohibit (or warn) applications who are getting it wrong in the first
place?  Providing interfaces that aren't stable, and then requiring
people to read documentation so they know not to use them, seems to be
providing an attractive nuisance.

						- Ted

  parent reply	other threads:[~2007-06-10 14:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-08 20:36 Rules on how to use sysfs in userspace programs 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 [this message]
2007-06-10 16:56   ` Randy Dunlap
2007-06-10 20:55     ` Kay Sievers
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=20070610140200.GD9726@thunk.org \
    --to=tytso@mit.edu \
    --cc=greg@kroah.com \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    /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