public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: "Mike D. Day" <ncmike@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>, xen-devel@lists.xensource.com
Subject: Re: [RFC] [PATCH] sysfs support for Xen attributes
Date: Thu, 12 Jan 2006 00:31:18 +0100	[thread overview]
Message-ID: <20060111233118.GA1534@elf.ucw.cz> (raw)
In-Reply-To: <43C53DA0.60704@us.ibm.com>


> The comments desired are (1) do the helper routines in xen_sysfs 
> duplicate code already present in linux (or under development somewhere 
> else). (2) Is it appropriate for a process to create sysfs attributes 
> without implementing a driver subsystem

Not sure, maybe proc is really better.

> or (3) are such attributes 
> better off living under /proc. (4) any other feedback is appreciated.

> --- a/linux-2.6-xen-sparse/arch/xen/kernel/Makefile     Tue Jan 10 
> 17:53:44 2006
> +++ b/linux-2.6-xen-sparse/arch/xen/kernel/Makefile     Tue Jan 10 
> 23:30:37 2006

Your mailer is evil and word-wraps patches.

> +#ifndef BOOL
> +#define BOOL    int
> +#endif
> +
> +#ifndef FALSE
> +#define FALSE   0
> +#endif
> +
> +#ifndef TRUE
> +#define TRUE    1
> +#endif
> +
> +#ifndef NULL
> +#define NULL    0
> +#endif

Evil!
								Pavel

> +{
> +       struct xen_sysfs_object * xen_obj = to_xen_obj_bin(kobj);
> +       if (xen_obj->attr.write)
> +               return xen_obj->attr.write(xen_obj->user_data, buf, 
> offset, size);
> +       if(size == 0 )

CodingStyle...
> +       .path = __stringify(/sys/xen),

Eh?

> +       .list = LIST_HEAD_INIT(xen_root.list),
> +       .children = LIST_HEAD_INIT(xen_root.children),
> +       .parent = NULL,
> +};
> +
> +/* xen sysfs path functions */
> +
> +static BOOL
> +valid_chars(const char *path)
> +{
> +       if( ! strstarts(path, "/sys/xen") )
> +               return FALSE;
> +       if(strstr(path, "//"))
> +               return FALSE;
> +       return (strspn(path,
> +                      "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
> +                      "abcdefghijklmnopqrstuvwxyz"
> +                      "0123456789-/_@~$") == strlen(path));
> +}
> +
> +
> +/* return value must be kfree'd */
> +static char *
> +dup_path(const char *path)
> +{
> +       char * ret;
> +       int len;
> +       BUG_ON( ! path );
> +
> +       if( FALSE == valid_chars(path) ) {
> +               return NULL;
> +       }
> +
> +       len = strlen(path) + 1;
> +       ret = kcalloc(len - 1, sizeof(char), GFP_KERNEL);
> +       memcpy(ret, path, len);
> +       return ret;
> +}
> +
> +
> +
> +static char *
> +basename(const char *name)
> +{
> +       return strrchr(name, '/') + 1;
> +}
> +
> +static char *
> +strip_trailing_slash(char * path)
> +{
> +       int len = strlen(path);
> +
> +       char * term = path + len - 1;
> +       if( *term == '/')
> +               *term = 0;
> +       return path;
> +}
> +
> +/* return value must be kfree'd */
> +static char * dirname(const char * name)
> +{
> +       char *ret;
> +       int len;
> +
> +       len = strlen(name) - strlen(basename(name)) + 1;
> +       ret = kcalloc(len, sizeof(char), GFP_KERNEL);
> +       memcpy(ret, name, len - 1);
> +       ret = strip_trailing_slash(ret);
> +
> +       return ret;
> +}
> +
> +
> +/* type must be char, bin, or dir */
> +static __sysfs_ref__ struct xen_sysfs_object *
> +new_sysfs_object(const char * path,
> +                int type,
> +                int mode,
> +                ssize_t (*show)(void *, char *),
> +                ssize_t (*store)(void *, const char *, size_t),
> +                ssize_t (*read)(void *, char *, loff_t, size_t),
> +                ssize_t (*write)(void *, char *, loff_t, size_t),
> +                void * user_data,
> +                void (* user_data_release)(void *))
> +{
> +       struct xen_sysfs_object * ret =
> +               (struct xen_sysfs_object *)kcalloc(sizeof(struct 
> xen_sysfs_object),
> +                                                  sizeof(char),
> +                                                  GFP_KERNEL);

Unneeded cast AFAICT.

> +       // if path is longer than obj-path, search children
> +       if ( strstarts(path, obj->path) &&

Mo C++ comments please.
						Pavel
-- 
Thanks, Sharp!

  parent reply	other threads:[~2006-01-12  9:47 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-11 17:17 [RFC] [PATCH] sysfs support for Xen attributes Mike D. Day
2006-01-11 17:19 ` Arjan van de Ven
2006-01-11 17:56 ` Stephen Hemminger
2006-01-11 18:45 ` Dave Hansen
2006-01-11 23:07 ` Greg KH
2006-01-12  0:23   ` Mike D. Day
2006-01-12  0:57     ` Greg KH
2006-01-12  1:49       ` Mike D. Day
2006-01-12  2:17         ` [Xen-devel] " Mark Williamson
2006-01-12  7:10         ` Greg KH
2006-01-12 14:44           ` [Xen-devel] " Mike D. Day
2006-01-12 14:53             ` Mark Williamson
2006-01-12 15:42               ` Anthony Liguori
2006-01-12 15:57             ` Anthony Liguori
2006-01-12 17:34               ` Greg KH
2006-01-12 18:44                 ` Anthony Liguori
2006-01-12 17:43             ` Greg KH
2006-01-12  9:10         ` Dave Hansen
2006-01-12 14:52           ` [Xen-devel] " Mike D. Day
2006-01-12 15:28             ` Dave Hansen
2006-01-12 15:50               ` Mike D. Day
2006-01-12 12:54         ` Gerd Hoffmann
2006-01-12 13:21           ` Arjan van de Ven
2006-01-12 14:42             ` Gerd Hoffmann
2006-01-12 17:39               ` Greg KH
2006-01-12 18:53                 ` Anthony Liguori
2006-01-12 18:55                   ` Arjan van de Ven
2006-01-12 18:59                     ` Anthony Liguori
2006-01-12 19:11                       ` Mike D. Day
2006-01-12 19:31                         ` Greg KH
2006-01-12 19:08                   ` Greg KH
2006-01-12 19:18                     ` Mike D. Day
2006-01-12 19:30                       ` Greg KH
2006-01-12 17:38           ` Greg KH
2006-01-12  1:32     ` Dave Hansen
2006-01-12 10:04       ` [Xen-devel] " Keir Fraser
2006-01-12 15:14         ` Dave Hansen
2006-01-12 15:06           ` Mark Williamson
2006-01-12 15:26           ` Keir Fraser
2006-01-12 15:37             ` Dave Hansen
2006-01-12 15:49               ` Anthony Liguori
2006-01-11 23:31 ` Pavel Machek [this message]
2006-01-12 19:01   ` Greg KH

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=20060111233118.GA1534@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncmike@us.ibm.com \
    --cc=xen-devel@lists.xensource.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