public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: "Kay Sievers" <kay.sievers@vrfy.org>
Cc: "Greg KH" <gregkh@suse.de>, "Tejun Heo" <htejun@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: sysfs root link count broken in 2.6.22-git5
Date: Thu, 19 Jul 2007 10:41:50 +0200	[thread overview]
Message-ID: <20070719104150.6c5c5165@hyperion.delvare> (raw)
In-Reply-To: <3ae72650707181744l47d6cbc6m75b7d9292959a245@mail.gmail.com>

Hi Kay,

On Thu, 19 Jul 2007 02:44:54 +0200, Kay Sievers wrote:
> On 7/18/07, Jean Delvare <khali@linux-fr.org> wrote:
> > On Tue, 17 Jul 2007 20:38:28 -0700, Greg KH wrote:
> > > On Tue, Jul 17, 2007 at 11:05:30PM +0200, Jean Delvare wrote:
> > > > The code looks like:
> > > >
> > > >        if (sysfs_get_mnt_path(sensors_sysfs_mount, NAME_MAX)
> > > >          || stat(sensors_sysfs_mount, &statbuf) < 0
> > > >          || statbuf.st_nlink <= 2)      /* Empty directory */
> > > >                 return 0;           /* Failure */
> > > >
> > > > This works OK with 2.6.22.1, but the last test fails with the current
> > > > git kernel even when sysfs is mounted.
> > >
> > > Yeah, but is checking the number of hard links in the directory a safe
> > > way to always verify that it isn't empty?
> >
> > I think so, yes. To the best of my knowledge, it has worked on all
> > Unix-like systems for decades. There are other ways, but this is by far
> > the less expensive.
> 
> Well, just check if /sys/devices/ exists, that should be cheap enough. :)

Yes, this is a possibility, and one I had considered at first. But I
wasn't sure which subdirectory to check. sysfs isn't well known for its
stability, and I didn't know which directories exist since the
early days of sysfs, and which do not. For example, fs, kernel and
module were not present in 2.6.5. I am also not sure if directories
which exist today are guaranteed to exist forever. This is the reason
why I decided to check the link count instead, basically checking that
at least one subdirectory exists, without having to name it.

-- 
Jean Delvare

  reply	other threads:[~2007-07-19  8:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-15 10:42 sysfs root link count broken in 2.6.22-git5 Jean Delvare
2007-07-17  3:48 ` Greg KH
2007-07-17 11:12   ` Jean Delvare
2007-07-17 18:36     ` Greg KH
2007-07-17 21:05       ` Jean Delvare
2007-07-18  3:05         ` Tejun Heo
2007-07-18  3:38         ` Greg KH
2007-07-18 20:06           ` Jean Delvare
2007-07-18 20:12             ` Andreas Schwab
2007-07-19  7:42               ` Jean Delvare
2007-07-18 21:21             ` Oliver Pinter
2007-07-19  0:44             ` Kay Sievers
2007-07-19  8:41               ` Jean Delvare [this message]
2007-07-19 16:02                 ` Jan Engelhardt
2007-07-18  5:29         ` [PATCH] sysfs: fix sysfs root inode nlink accounting Tejun Heo
2007-07-18  5:30           ` [PATCH] sysfs: make sysfs_init_inode() static Tejun Heo
2007-07-18 14:04             ` Jean Delvare
2007-07-18 14:02           ` [PATCH] sysfs: fix sysfs root inode nlink accounting Jean Delvare

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=20070719104150.6c5c5165@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=gregkh@suse.de \
    --cc=htejun@gmail.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