public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chandra Seetharaman <sekharan@us.ibm.com>
To: akpm@osdl.org, linux-kernel@vger.kernel.org,
	ckrm-tech@lists.sourceforge.net
Cc: Chandra Seetharaman <sekharan@us.ibm.com>
Subject: [PATCH 08/12] Add attribute support to RGCS
Date: Thu, 27 Apr 2006 18:34:54 -0700	[thread overview]
Message-ID: <20060428013454.27212.70077.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060428013410.27212.45968.sendpatchset@localhost.localdomain>

08/12 - user_interface_attr_support

Adds the basic attribute store and show functions.
--

Signed-Off-By: Chandra Seetharaman <sekharan@us.ibm.com>
Signed-Off-By: Shailabh Nagar <nagar@watson.ibm.com>
Signed-Off-By: Matt Helsley <matthltc@us.ibm.com>

 rgcs.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletion(-)

Index: linux-2617-rc3/kernel/res_group/rgcs.c
===================================================================
--- linux-2617-rc3.orig/kernel/res_group/rgcs.c	2006-04-27 10:18:39.000000000 -0700
+++ linux-2617-rc3/kernel/res_group/rgcs.c	2006-04-27 10:18:44.000000000 -0700
@@ -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 "local.h"
 
 static struct configfs_subsystem rgcs_subsys;
 static struct config_item_type rgcs_item_type;
 
+struct rgroup_attribute {
+	struct configfs_attribute configfs_attr;
+	ssize_t (*show)(struct resource_group *, char *);
+	int (*store)(struct resource_group *, const char *);
+};
+
 struct rgcs_rgroup {
 	char *name;
 	struct resource_group *core;
@@ -58,6 +66,42 @@ static inline struct resource_group *ite
 	return group_to_res_group(to_config_group(item));
 }
 
+static ssize_t rgcs_attr_show(struct config_item *item,
+	      		      struct configfs_attribute *attr, char *buf)
+{
+	struct rgroup_attribute *rgroup_attr;
+	struct resource_group *rgroup = item_to_res_group(item);
+
+	rgroup_attr = container_of(attr, struct rgroup_attribute,
+							configfs_attr);
+	return rgroup_attr->show(rgroup, buf);
+}
+
+static ssize_t rgcs_attr_store(struct config_item *item,
+		       struct configfs_attribute *attr, const char *buf,
+		       size_t count)
+{
+	char *filtered_buf, *p;
+	ssize_t rc;
+	struct rgroup_attribute *rgroup_attr;
+	struct resource_group *rgroup = item_to_res_group(item);
+
+	rgroup_attr = container_of(attr, struct rgroup_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 = rgroup_attr->store(rgroup, 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
@@ -119,17 +163,24 @@ static void rgcs_rgroup_release_item(str
 }
 
 static struct configfs_item_operations rgcs_rgroup_item_ops = {
-	.release	= rgcs_rgroup_release_item,
+	.release		= rgcs_rgroup_release_item,
+	.show_attribute		= rgcs_attr_show,
+	.store_attribute	= rgcs_attr_store,
 };
 
 static struct configfs_group_operations rgcs_rgroup_group_ops = {
 	.make_group     = make_rgcs_rgroup,
 };
 
+static struct configfs_attribute *rgroup_attrs[] = {
+	NULL
+};
+
 static struct config_item_type rgcs_item_type = {
 	.ct_owner	= THIS_MODULE,
 	.ct_item_ops    = &rgcs_rgroup_item_ops,
 	.ct_group_ops	= &rgcs_rgroup_group_ops,
+	.ct_attrs       = rgroup_attrs
 };
 
 static struct configfs_subsystem rgcs_subsys = {

-- 

----------------------------------------------------------------------
    Chandra Seetharaman               | Be careful what you choose....
              - sekharan@us.ibm.com   |      .......you may get it.
----------------------------------------------------------------------

  parent reply	other threads:[~2006-04-28  1:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-28  1:34 [PATCH 00/12] Resource Groups... formerly CKRM Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 01/12] Register/Unregister interface for Controllers Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 02/12] Resource group creation/deletion Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 03/12] Share Handling Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 04/12] Add task logic to resource groups Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 05/12] Init and clear resource group info in task Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 06/12] Add proc interface to get resource group info of task Chandra Seetharaman
2006-04-28  1:34 ` [PATCH 07/12] Resource Groups Configfs Subsystem (RGCS) Chandra Seetharaman
2006-04-28  1:34 ` Chandra Seetharaman [this message]
2006-04-28  1:35 ` [PATCH 09/12] Add stats file support to RGCS Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 10/12] Add shares " Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 11/12] Add members " Chandra Seetharaman
2006-04-28  1:35 ` [PATCH 12/12] Documentation for Resource Groups Chandra Seetharaman

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=20060428013454.27212.70077.sendpatchset@localhost.localdomain \
    --to=sekharan@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ckrm-tech@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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