public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] inotify: make our sysfs files show up
@ 2004-11-17 16:57 Robert Love
  2004-11-17 18:02 ` [patch] inotify: vfs_permission was replaced Robert Love
  2004-11-18 19:05 ` [patch] inotify: grab right lock Robert Love
  0 siblings, 2 replies; 16+ messages in thread
From: Robert Love @ 2004-11-17 16:57 UTC (permalink / raw)
  To: ttb; +Cc: linux-kernel

Hey, John.

On top of the patch I just posted (see "[patch] add class_device to
miscdevice") this patch uses the newly attainable class_device value to
correctly add our sysfs attributes.

The problem with the current solution is that we were adding attributes
to the device.  But we did not have a device entry, only the fake
inotify entry in class/misc.  So we need to attach the attributes to the
class device and not the nonexistent physical device.

In order to attach attributes to the class_device, I needed to make the
changes I sent to Greg.  I would suggest merging that patch and this and
hopefully the miscdevice bits will find their way into mainline and we
can then drop them from inotify.

Thanks,

	Robert Love


Make our /sys/class/misc/inotify entries show up and work.

Signed-Off-By: Robert Love <rml@novell.com>

 inotify.c |   57 +++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff -u linux/drivers/char/inotify.c linux/drivers/char/inotify.c
--- linux/drivers/char/inotify.c	2004-11-15 15:28:34.951248696 -0500
+++ linux/drivers/char/inotify.c	2004-11-16 14:42:11.929575168 -0500
@@ -80,60 +80,48 @@
 #define inotify_watch_i_list(pos) list_entry((pos), struct inotify_watch, i_list)
 #define inotify_watch_u_list(pos) list_entry((pos), struct inotify_watch, u_list)
 
-static ssize_t show_max_queued_events(struct device *dev, char *buf)
+static ssize_t show_max_queued_events(struct class_device *class, char *buf)
 {
 	sprintf(buf, "%d", sysfs_attrib_max_queued_events);
-
 	return strlen(buf) + 1;
 }
 
-static ssize_t store_max_queued_events(struct device *dev, const char *buf,
-				      size_t count)
+static ssize_t store_max_queued_events(struct class_device *class,
+				       const char *buf, size_t count)
 {
 	return 0;
 }
 
-static ssize_t show_max_user_devices(struct device *dev, char *buf)
+static ssize_t show_max_user_devices(struct class_device *class, char *buf)
 {
 	sprintf(buf, "%d", sysfs_attrib_max_user_devices);
-
 	return strlen(buf) + 1;
 }
 
-static ssize_t store_max_user_devices(struct device *dev, const char *buf,
-				      size_t count)
+static ssize_t store_max_user_devices(struct class_device *class,
+				      const char *buf, size_t count)
 {
 	return 0;
 }
 
-static ssize_t show_max_user_watches(struct device *dev, char *buf)
+static ssize_t show_max_user_watches(struct class_device *class, char *buf)
 {
 	sprintf(buf, "%d", sysfs_attrib_max_user_watches);
-
 	return strlen(buf) + 1;
 }
 
-static ssize_t store_max_user_watches(struct device *dev, const char *buf,
-				      size_t count)
+static ssize_t store_max_user_watches(struct class_device *class,
+				      const char *buf, size_t count)
 {
 	return 0;
 }
 
-
-static DEVICE_ATTR(max_queued_events, S_IRUGO | S_IWUSR, show_max_queued_events,
- store_max_queued_events);
-static DEVICE_ATTR(max_user_devices, S_IRUGO | S_IWUSR, show_max_user_devices,
- store_max_user_devices);
-static DEVICE_ATTR(max_user_watches, S_IRUGO | S_IWUSR, show_max_user_watches,
- store_max_user_watches);
-
-static struct device_attribute *inotify_device_attrs[] = {
-	&dev_attr_max_queued_events,
-	&dev_attr_max_user_devices,
-	&dev_attr_max_user_watches,
-	NULL
-};
-
+static CLASS_DEVICE_ATTR(max_queued_events, S_IRUGO | S_IWUSR,
+	show_max_queued_events, store_max_queued_events);
+static CLASS_DEVICE_ATTR(max_user_devices, S_IRUGO | S_IWUSR,
+	show_max_user_devices, store_max_user_devices);
+static CLASS_DEVICE_ATTR(max_user_watches, S_IRUGO | S_IWUSR,
+	show_max_user_watches, store_max_user_watches);
 
 /*
  * A list of these is attached to each instance of the driver
@@ -307,7 +295,8 @@
 {
 	int ret;
 
-	if (atomic_read(&dev->user->inotify_watches) >= sysfs_attrib_max_user_watches)
+	if (atomic_read(&dev->user->inotify_watches) >=
+			sysfs_attrib_max_user_watches)
 		return -ENOSPC;
 
 repeat:
@@ -968,7 +957,8 @@
 
 static int __init inotify_init(void)
 {
-	int ret,i;
+	struct class_device *class;
+	int ret;
 
 	ret = misc_register(&inotify_device);
 	if (ret)
@@ -978,11 +968,10 @@
 	sysfs_attrib_max_user_devices = 64;
 	sysfs_attrib_max_user_watches = 16384;
 
-	for (i = 0; inotify_device_attrs[i]; i++) {
-		int res;
-		res = device_create_file (inotify_device.dev, inotify_device_attrs[i]);
-		printk(KERN_INFO "Inotify sysfs create file = %d\n", res);
-	}
+	class = inotify_device.class;
+	class_device_create_file(class, &class_device_attr_max_queued_events);
+	class_device_create_file(class, &class_device_attr_max_user_devices);
+	class_device_create_file(class, &class_device_attr_max_user_watches);
 
 	atomic_set(&inotify_cookie, 0);
 
 



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2004-11-19  0:44 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-17 16:57 [patch] inotify: make our sysfs files show up Robert Love
2004-11-17 18:02 ` [patch] inotify: vfs_permission was replaced Robert Love
2004-11-17 19:08   ` Christoph Hellwig
2004-11-17 19:10     ` Robert Love
2004-11-17 19:18       ` Christoph Hellwig
2004-11-17 19:17         ` Robert Love
2004-11-17 20:09           ` Mike Waychison
2004-11-17 20:17             ` [patch] inotify: use permission not vfs_permission Robert Love
2004-11-17 20:25               ` Mike Waychison
2004-11-17 20:28                 ` Robert Love
2004-11-18  0:59                   ` John McCutchan
2004-11-17 20:19           ` [patch] inotify: vfs_permission was replaced Al Viro
2004-11-17 20:10   ` [patch] inotify: add sysfs store support Robert Love
2004-11-18  1:00     ` John McCutchan
2004-11-18  1:24       ` Robert Love
2004-11-18 19:05 ` [patch] inotify: grab right lock Robert Love

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox