Re: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace

Jon Smirl
2005-07-28T03:59:15Z

New patch with fixed whitespace.

--
Jon Smirl
jonsmirl@gmail.com

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,6 +208,28 @@ 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, *y, *z;
+
+ /* locate leading white space */
+ x = buffer->page;
+ while (isspace(*x) && (x - buffer->page < count))
+ x++;
+
+ /* locate trailng white space */
+ z = y = x;
+ while (y - buffer->page < count) {
+ y++;
+ z = y;
+ while (isspace(*y) && (y - buffer->page < count)) {
+ y++;
+ }
+ }
+ count = z - x;
+
+ /* strip the white space */
+ if (buffer->page != x)
+ memmove(buffer->page, x, count);
+ buffer->page[count] = '\0';

return ops->store(kobj,attr,buffer->page,count);
}