Even simpler version.... -- Jon Smirl [email protected] Remove leading and trailing whitespace when text sysfs attribute is set signed-off-by: Jon Smirl <[email protected]> diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c @@ -6,6 +6,7 @@ #include <linux/fsnotify.h> #include <linux/kobject.h> #include <linux/namei.h> +#include <linux/ctype.h> #include <asm/uaccess.h> #include <asm/semaphore.h> @@ -207,8 +208,23 @@ flush_write_buffer(struct dentry * dentr struct attribute * attr = to_attr(dentry); struct kobject * kobj = to_kobj(dentry->d_parent); struct sysfs_ops * ops = buffer->ops; + char *x; - return ops->store(kobj,attr,buffer->page,count); + /* locate trailing white space */ + while ((count > 0) && isspace(buffer->page[count - 1])) + count--; + + /* locate leading white space */ + x = buffer->page; + if (count > 0) { + while (isspace(*x)) + x++; + count -= (x - buffer->page); + } + /* terminate the string */ + x[count] = '\0'; + + return ops->store(kobj, attr, x, count); } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- References:
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Jon Smirl <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Jon Smirl <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Greg KH <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Jon Smirl <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Greg KH <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Mitchell Blank Jr <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Jon Smirl <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Greg KH <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Jon Smirl <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- From: Mitchell Blank Jr <[email protected]>
- Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- Prev by Date: Re: [Linux-fbdev-devel] Re: [PATCH] fbdev: colormap fixes
- Next by Date: Re: 2.6.13-rc3-mm3
- Previous by thread: Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- Next by thread: Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
- Index(es):