08/12 - ckrm_configfs_rcfs_attr_support Adds the basic attribute store and show functions. --
Signed-Off-By: Chandra Seetharaman <[EMAIL PROTECTED]> Signed-Off-By: Shailabh Nagar <[EMAIL PROTECTED]> Signed-Off-By: Matt Helsley <[EMAIL PROTECTED]> kernel/ckrm/ckrm_rcfs.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 50 insertions(+), 1 deletion(-) Index: linux-2.6.16/kernel/ckrm/ckrm_rcfs.c =================================================================== --- linux-2.6.16.orig/kernel/ckrm/ckrm_rcfs.c +++ linux-2.6.16/kernel/ckrm/ckrm_rcfs.c @@ -14,13 +14,21 @@ * as published by the Free Software Foundation. * */ +#include <linux/ctype.h> #include <linux/module.h> #include <linux/configfs.h> +#include <linux/parser.h> #include "ckrm_local.h" static struct configfs_subsystem rcfs_subsys; static struct config_item_type rcfs_class_type; +struct class_attribute { + struct configfs_attribute configfs_attr; + ssize_t (*show)(struct ckrm_class *, char *); + int (*store)(struct ckrm_class *, const char *); +}; + struct rcfs_class { char *name; struct ckrm_class *core; @@ -56,6 +64,40 @@ static inline struct ckrm_class *item_to return group_to_ckrm_class(to_config_group(item)); } +static ssize_t rcfs_attr_show(struct config_item *item, + struct configfs_attribute *attr, char *buf) +{ + struct class_attribute *class_attr; + struct ckrm_class *class = item_to_ckrm_class(item); + + class_attr = container_of(attr, struct class_attribute, configfs_attr); + return class_attr->show(class, buf); +} + +static ssize_t rcfs_attr_store(struct config_item *item, + struct configfs_attribute *attr, const char *buf, + size_t count) +{ + char *filtered_buf, *p; + ssize_t rc; + struct class_attribute *class_attr; + struct ckrm_class *class = item_to_ckrm_class(item); + + class_attr = container_of(attr, struct class_attribute, configfs_attr); + filtered_buf = kzalloc(count + 1, GFP_KERNEL); + if (!filtered_buf) + return -ENOMEM; + strncpy(filtered_buf, buf, count); + for (p = filtered_buf; isprint(*p); ++p) + ; + *p = '\0'; + rc = class_attr->store(class, filtered_buf); + kfree(filtered_buf); + if (rc) + return rc; + return count; +} + /* * This is the function that is called when a 'mkdir' command * is issued under our filesystem @@ -117,17 +159,24 @@ static void rcfs_class_release_item(stru } static struct configfs_item_operations rcfs_class_item_ops = { - .release = rcfs_class_release_item, + .release = rcfs_class_release_item, + .show_attribute = rcfs_attr_show, + .store_attribute = rcfs_attr_store, }; static struct configfs_group_operations rcfs_class_group_ops = { .make_group = make_rcfs_class, }; +static struct configfs_attribute *class_attrs[] = { + NULL +}; + static struct config_item_type rcfs_class_type = { .ct_owner = THIS_MODULE, .ct_item_ops = &rcfs_class_item_ops, .ct_group_ops = &rcfs_class_group_ops, + .ct_attrs = class_attrs }; static struct configfs_subsystem rcfs_subsys = { -- ---------------------------------------------------------------------- Chandra Seetharaman | Be careful what you choose.... - [EMAIL PROTECTED] | .......you may get it. ---------------------------------------------------------------------- ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ ckrm-tech mailing list https://lists.sourceforge.net/lists/listinfo/ckrm-tech