public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: John McCutchan <ttb@tentacle.dhs.org>
To: Robert Love <rml@novell.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [patch] inotify: add sysfs store support
Date: Wed, 17 Nov 2004 20:00:41 -0500	[thread overview]
Message-ID: <1100739641.8984.10.camel@vertex> (raw)
In-Reply-To: <1100722226.4981.46.camel@betsy.boston.ximian.com>

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 <ttb@tentacle.dhs.org>

  reply	other threads:[~2004-11-18  1:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=1100739641.8984.10.camel@vertex \
    --to=ttb@tentacle.dhs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@novell.com \
    /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