Re: inotify/sysfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux