All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Quentin Glidic <sardemff7+linux@sardemff7.net>,
	linux-fsdevel@vger.kernel.org
Cc: Jan Kara <jack@suse.cz>
Subject: Re: inotify/sysfs
Date: Fri, 28 Mar 2014 23:25:49 -0700	[thread overview]
Message-ID: <20140329062549.GA27723@kroah.com> (raw)
In-Reply-To: <20140328170713.GA11990@quack.suse.cz>

On Fri, Mar 28, 2014 at 06:07:13PM +0100, Jan Kara wrote:
>   Hello,
> 
> On Thu 27-03-14 14:50:24, Quentin Glidic wrote:
> > In GIO (GLib), the GFileMonitor[1] mechanism is using inotify for
> > local files. To detect file creation and some other weird cases,
> > they monitor the directory of the file and not the file directly
> > (see get_basename/get_dirname[2] usage).
> > 
> > With sysfs, it does not work as expected for some reason.
>   Well, I'm rather surprised inotify works with sysfs at all ;) Why do you
> need to watch sysfs? Udev is the tool with which you should generally look
> for e.g. new devices... Anyway, if you'd like to add fsnotify() support
> into sysfs, sysfs maintainer (Greg - added to CC) is the one to ask.

You forgot to cc: me :)

No, inotify doesn't work on sysfs, or if it does, that's by "accident",
and any data you are getting for this is probably totally wrong.

This is because the system would have to be constantly "opening" the
files to check for a value change in the kernel that represents the file
information.  That would be hell on memory and overhead and just doesn't
make any sense at all.

For specific sysfs files that are ment to tell userspace that their
values changed, you can poll() on them, as they are set up to do this
properly.

If there are some specific sysfs files that you want to watch in this
manner, that don't support poll(), please let us know.

Also, if you are digging through sysfs files in the system, I'd
recommend using libudev, as that provides a much easier interface to
getting the data you need about the device you want.

thanks,

greg k-h

  reply	other threads:[~2014-03-29 16:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27 13:50 inotify/sysfs Quentin Glidic
2014-03-28 17:07 ` inotify/sysfs Jan Kara
2014-03-29  6:25   ` Greg KH [this message]
2014-03-31 18:52 ` inotify/sysfs Al Viro
2014-03-31 19:13   ` inotify/sysfs Linus Torvalds
2014-03-31 20:00     ` inotify/sysfs Al Viro
2014-03-31 20:10       ` inotify/sysfs Linus Torvalds

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=20140329062549.GA27723@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sardemff7+linux@sardemff7.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.