Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S262619AbUKRBDw (ORCPT ); Wed, 17 Nov 2004 20:03:52 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262503AbUKRBB5 (ORCPT ); Wed, 17 Nov 2004 20:01:57 -0500 Received: from coriana6.CIS.McMaster.CA ([130.113.128.17]:27018 "EHLO coriana6.cis.mcmaster.ca") by vger.kernel.org with ESMTP id S262631AbUKRBAr (ORCPT ); Wed, 17 Nov 2004 20:00:47 -0500 Subject: Re: [patch] inotify: add sysfs store support From: John McCutchan To: Robert Love Cc: linux-kernel@vger.kernel.org In-Reply-To: <1100722226.4981.46.camel@betsy.boston.ximian.com> References: <1100710677.6280.2.camel@betsy.boston.ximian.com> <1100714560.6280.7.camel@betsy.boston.ximian.com> <1100722226.4981.46.camel@betsy.boston.ximian.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Wed, 17 Nov 2004 20:00:41 -0500 Message-Id: <1100739641.8984.10.camel@vertex> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 X-PMX-Version-Mac: 4.7.0.111621, Antispam-Engine: 2.0.2.0, Antispam-Data: 2004.11.17.1 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_VERSION 0, __SANE_MSGID 0' X-Spam-Flag: NO Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3804 Lines: 115 Awesome work! But I am going to hold off applying this, until the mainline kernel gets the misc device changes. John On Wed, 2004-11-17 at 15:10 -0500, Robert Love wrote: > Attached patch implements the final chunk of our sysfs solution: store > support. I added basic write support with some simple checking (do not > allow zero) to the existing sysfs attributes. > > I made a few other changes. I added a newline after the values in the > show function. The other sysfs attributes do this and it makes > sense--do a "cat *" in our sysfs directory before and after. I also > just return sprintf() directly instead of the strlen(). I also made > max_queued_events unsigned, since dev->max_events is unsigned. If we > don't do this we need to add checking in store_max_queued_events to > ensure that the given value is less than or equal to INT_MAX so this > seems easier and more optimal anyhow. The other values I kept at int > since that is the range of atomic_t's. > > I am running it now. I can read and write the values fine. Works > great. > > Robert Love > > > Add store support to our sysfs attributes and a few other changes. > > inotify.c | 35 +++++++++++++++++++++++++---------- > 1 files changed, 25 insertions(+), 10 deletions(-) > > diff -u linux/drivers/char/inotify.c linux/drivers/char/inotify.c > --- linux/drivers/char/inotify.c 2004-11-16 14:42:11.929575168 -0500 > +++ linux/drivers/char/inotify.c 2004-11-17 12:28:27.921136656 -0500 > @@ -40,7 +40,7 @@ > > static int sysfs_attrib_max_user_devices; > static int sysfs_attrib_max_user_watches; > -static int sysfs_attrib_max_queued_events; > +static unsigned int sysfs_attrib_max_queued_events; > > /* > * struct inotify_device - represents an open instance of an inotify device > @@ -82,38 +82,53 @@ > > 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; > + return sprintf(buf, "%d\n", sysfs_attrib_max_queued_events); > } > > static ssize_t store_max_queued_events(struct class_device *class, > const char *buf, size_t count) > { > - return 0; > + unsigned int max; > + > + if (sscanf(buf, "%u", &max) > 0 && max > 0) { > + sysfs_attrib_max_queued_events = max; > + return strlen(buf); > + } > + return -EINVAL; > } > > 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; > + return sprintf(buf, "%d\n", sysfs_attrib_max_user_devices); > } > > static ssize_t store_max_user_devices(struct class_device *class, > const char *buf, size_t count) > { > - return 0; > + int max; > + > + if (sscanf(buf, "%d", &max) > 0 && max > 0) { > + sysfs_attrib_max_user_devices = max; > + return strlen(buf); > + } > + return -EINVAL; > } > > 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; > + return sprintf(buf, "%d\n", sysfs_attrib_max_user_watches); > } > > static ssize_t store_max_user_watches(struct class_device *class, > const char *buf, size_t count) > { > - return 0; > + int max; > + > + if (sscanf(buf, "%d", &max) > 0 && max > 0) { > + sysfs_attrib_max_user_watches = max; > + return strlen(buf); > + } > + return -EINVAL; > } > > static CLASS_DEVICE_ATTR(max_queued_events, S_IRUGO | S_IWUSR, > > -- John McCutchan - 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/