lkml.org 
[lkml]   [2005]   [Jul]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] driver core: Add the ability to unbind drivers to devices from userspace
    Any comments on this? I'll fix up the whitespace issues if everyone
    agrees that the code works.

    This patch will break all of the fbdev attributes since I was making
    wrong assumptions. I have another patch ready to fix them after this
    one goes in.

    On 7/25/05, Jon Smirl <jonsmirl@gmail.com> wrote:
    > On 7/25/05, Greg KH <greg@kroah.com> wrote:
    > > > I'll put one together to trim leading/trailing white space from the
    > > > buffer before it is passed into the attribute functions. Now that I
    > > > think about this I believe the attributes should have always had the
    > > > leading/trailing white space removed. If we don't do it in the sysfs
    > > > code then every driver has to do it.
    > >
    > > Ok, sounds good.
    >
    > How does this look? This is a count based interface but a lot of
    > attributes don't work unless I add the terminating zero. This
    > interface should be documented: count or zero terminated, white space
    > stripped or not, etc. Are these strings ASCII, UTF8, Unicode?
    >
    > 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);
    > }
    >
    >
    > --
    > Jon Smirl
    > jonsmirl@gmail.com
    >


    --
    Jon Smirl
    jonsmirl@gmail.com
    -
    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/

    \
     
     \ /
      Last update: 2005-07-28 04:10    [W:2.749 / U:0.424 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site