fsnotify & sysfs

December 12th, 2010 - 07:50 am ET by Rodolfo Giometti | Report spam
Hello,

I know that a sysfs file may be pollable but I'm asking to myself how
it could be difficult adding notifying support also.

Maybe adding a call to the fsnotify subsystem within the
sysfs_notify() function as follow can do the trick?

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index da3fefe..afee69f 100644
a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -484,8 +486,10 @@ void sysfs_notify(struct kobject *k, const char
*dir, const
sd = sysfs_find_dirent(sd, NULL, dir);
if (sd && attr)
sd = sysfs_find_dirent(sd, NULL, attr);
- if (sd)
+ if (sd) {
sysfs_notify_dirent(sd);
+ fsnotify_change(dentry, ATTR_SIZE);
+ }

mutex_unlock(&sysfs_mutex);
}

However my problem is how to get the struct dentry pointer needed by
fsnotify_change() related to the struct sysfs_dirent pointer passed to
sysfs_notify(). :(

Can you please give me any advice about to solve it?

Another question: in file linux/fs/sysfs/file.c I see:

#include <linux/fsnotify.h>

but none of its functions are called into file.c... maybe it's a
mistake?

Thanks in advance,

Rodolfo


GNU/Linux Solutions e-mail: giometti@enneenne.com
Linux Device Driver giometti@linux.it
Embedded Systems phone: +39 349 2432127
UNIX programming skype: rodolfo.giometti
Freelance ICT Italia - Consulente ICT Italia - www.consulenti-ict.it
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
email Follow the discussionReplies 1 replyReplies Make a reply

Replies

#1 Greg KH
December 12th, 2010 - 11:50 am ET | Report spam
On Sun, Dec 12, 2010 at 01:42:47PM +0100, Rodolfo Giometti wrote:
Hello,

I know that a sysfs file may be pollable but I'm asking to myself how
it could be difficult adding notifying support also.

Maybe adding a call to the fsnotify subsystem within the
sysfs_notify() function as follow can do the trick?



Perhaps, does that work?

However my problem is how to get the struct dentry pointer needed by
fsnotify_change() related to the struct sysfs_dirent pointer passed to
sysfs_notify(). :(



Yup, that's a problem :(

Can you please give me any advice about to solve it?

Another question: in file linux/fs/sysfs/file.c I see:

#include <linux/fsnotify.h>

but none of its functions are called into file.c... maybe it's a
mistake?



Possibly, but look at the patch that added that line, perhaps it was put
there for a reason.

thanks,

greg k-h
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Similar topics