<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From jonsmirl@gmail.com Thu Jul 28 13:27:51 2005
Message-ID: &lt;9e473391050728132757a75d5f@mail.gmail.com&gt;
Date: Thu, 28 Jul 2005 16:27:32 -0400
From: Jon Smirl &lt;jonsmirl@gmail.com&gt;
To: Mitchell Blank Jr &lt;mitch@sfgoth.com&gt;
Subject: sysfs: strip leading and trailing whitespace from sysfs buffer
Cc: Greg KH &lt;greg@kroah.com&gt;, &lt;dtor_core@ameritech.net&gt;,


Remove leading and trailing whitespace when text sysfs attribute is set

Signed-off-by: Jon Smirl &lt;jonsmirl@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

---
 fs/sysfs/file.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletion(-)

--- gregkh-2.6.orig/fs/sysfs/file.c	2005-08-02 13:41:31.000000000 -0700
+++ gregkh-2.6/fs/sysfs/file.c	2005-08-08 14:21:35.000000000 -0700
@@ -6,6 +6,7 @@
 #include &lt;linux/fsnotify.h&gt;
 #include &lt;linux/kobject.h&gt;
 #include &lt;linux/namei.h&gt;
+#include &lt;linux/ctype.h&gt;
 #include &lt;asm/uaccess.h&gt;
 #include &lt;asm/semaphore.h&gt;
 
@@ -207,8 +208,23 @@
 	struct attribute * attr = to_attr(dentry);
 	struct kobject * kobj = to_kobj(dentry-&gt;d_parent);
 	struct sysfs_ops * ops = buffer-&gt;ops;
+	char *x;
 
-	return ops-&gt;store(kobj,attr,buffer-&gt;page,count);
+	/* locate trailing white space */
+	while ((count &gt; 0) &amp;&amp; isspace(buffer-&gt;page[count - 1]))
+		count--;
+
+	/* locate leading white space */
+	x = buffer-&gt;page;
+	if (count &gt; 0) {
+		while (isspace(*x))
+			x++;
+		count -= (x - buffer-&gt;page);
+	}
+	/* terminate the string */
+	x[count] = '\0';
+
+	return ops-&gt;store(kobj, attr, x, count);
 }
 
 
</pre></body></html>