mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Love <rml@novell.com>
To: ttb@tentacle.dhs.org
Cc: linux-kernel@vger.kernel.org
Subject: [patch] inotify: make our sysfs files show up
Date: Wed, 17 Nov 2004 11:57:57 -0500	[thread overview]
Message-ID: <1100710677.6280.2.camel@betsy.boston.ximian.com> (raw)

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);
 
 



             reply	other threads:[~2004-11-17 17:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-17 16:57 Robert Love [this message]
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

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=1100710677.6280.2.camel@betsy.boston.ximian.com \
    --to=rml@novell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ttb@tentacle.dhs.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®