aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sysfs.h
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2006-03-20 01:53:53 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-14 14:41:24 -0400
commit4508a7a734b111b8b7e39986237d84acb1168dd0 (patch)
tree8fe535fbb97d619c9069da26367ead03d1a294aa /include/linux/sysfs.h
parentf043ca43c1ae354346f72dc5826d820d5619f0b2 (diff)
[PATCH] sysfs: Allow sysfs attribute files to be pollable
It works like this: Open the file Read all the contents. Call poll requesting POLLERR or POLLPRI (so select/exceptfds works) When poll returns, close the file and go to top of loop. or lseek to start of file and go back to the 'read'. Events are signaled by an object manager calling sysfs_notify(kobj, dir, attr); If the dir is non-NULL, it is used to find a subdirectory which contains the attribute (presumably created by sysfs_create_group). This has a cost of one int per attribute, one wait_queuehead per kobject, one int per open file. The name "sysfs_notify" may be confused with the inotify functionality. Maybe it would be nice to support inotify for sysfs attributes as well? This patch also uses sysfs_notify to allow /sys/block/md*/md/sync_action to be pollable Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/sysfs.h')
-rw-r--r--include/linux/sysfs.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 392da5a6dacb..1ea5d3cda6ae 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -74,6 +74,7 @@ struct sysfs_dirent {
74 umode_t s_mode; 74 umode_t s_mode;
75 struct dentry * s_dentry; 75 struct dentry * s_dentry;
76 struct iattr * s_iattr; 76 struct iattr * s_iattr;
77 atomic_t s_event;
77}; 78};
78 79
79#define SYSFS_ROOT 0x0001 80#define SYSFS_ROOT 0x0001
@@ -117,6 +118,7 @@ int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
117 118
118int sysfs_create_group(struct kobject *, const struct attribute_group *); 119int sysfs_create_group(struct kobject *, const struct attribute_group *);
119void sysfs_remove_group(struct kobject *, const struct attribute_group *); 120void sysfs_remove_group(struct kobject *, const struct attribute_group *);
121void sysfs_notify(struct kobject * k, char *dir, char *attr);
120 122
121#else /* CONFIG_SYSFS */ 123#else /* CONFIG_SYSFS */
122 124
@@ -185,6 +187,10 @@ static inline void sysfs_remove_group(struct kobject * k, const struct attribute
185 ; 187 ;
186} 188}
187 189
190static inline void sysfs_notify(struct kobject * k, char *dir, char *attr)
191{
192}
193
188#endif /* CONFIG_SYSFS */ 194#endif /* CONFIG_SYSFS */
189 195
190#endif /* _SYSFS_H_ */ 196#endif /* _SYSFS_H_ */