11/12 - user_interface_members

Adds attr_store and attr_show support for members file.
--

Signed-Off-By: Chandra Seetharaman <[EMAIL PROTECTED]>
Signed-Off-By: Shailabh Nagar <[EMAIL PROTECTED]>
Signed-Off-By: Matt Helsley <[EMAIL PROTECTED]>

 rgcs.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+)

Index: linux-2617-rc3/kernel/res_group/rgcs.c
===================================================================
--- linux-2617-rc3.orig/kernel/res_group/rgcs.c 2006-04-27 10:18:47.000000000 
-0700
+++ linux-2617-rc3/kernel/res_group/rgcs.c      2006-04-27 10:18:47.000000000 
-0700
@@ -242,6 +242,43 @@ static ssize_t show_shares(struct resour
        return rc;
 }
 
+/*
+ * Given a buffer with a pid in it, add the task with that pid to the
+ * resource group. Ignores entire buffer after the first pid is parsed.
+ */
+static int add_member(struct resource_group *rgroup, const char *str)
+{
+       pid_t pid;
+
+       pid = (pid_t) simple_strtol(str, NULL, 0);
+       if (pid <= 0)
+               return -EINVAL; /* Not a valid pid */
+       return set_res_group(pid, rgroup);
+}
+
+/*
+ * Lists pids of tasks that belong to the given rgroup.
+ */
+static ssize_t show_members(struct resource_group *rgroup, char *buf)
+{
+       ssize_t i, rc = 0, bufsize = PAGE_SIZE;
+       struct task_struct *tsk;
+
+       spin_lock(&rgroup->group_lock);
+       list_for_each_entry(tsk, &rgroup->task_list, member_list) {
+               if (bufsize <= 0) {
+                       rc = -ENOSPC;
+                       break;
+               }
+               if (!tsk->pid)  /* Ignore swappers */
+                       continue;
+               i = snprintf(buf, bufsize, "%ld\n", (long)tsk->pid);
+               buf += i; rc += i; bufsize -= i;
+       }
+       spin_unlock(&rgroup->group_lock);
+       return rc;
+}
+
 struct rgroup_attribute {
        struct configfs_attribute configfs_attr;
        ssize_t (*show)(struct resource_group *, char *);
@@ -268,6 +305,17 @@ struct rgroup_attribute shares_attr = {
        .store = set_shares
 };
 
+struct rgroup_attribute members_attr = {
+       .configfs_attr = {
+               .ca_name = "members",
+               .ca_owner = THIS_MODULE,
+               .ca_mode = S_IRUGO | S_IWUSR
+       },
+       .show = show_members,
+       .store = add_member
+};
+
+
 static struct configfs_subsystem rgcs_subsys;
 static struct config_item_type rgcs_item_type;
 
@@ -417,6 +465,7 @@ static struct configfs_group_operations 
 static struct configfs_attribute *rgroup_attrs[] = {
        &stats_attr.configfs_attr,
        &shares_attr.configfs_attr,
+       &members_attr.configfs_attr,
        NULL
 };
 

-- 

----------------------------------------------------------------------
    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

Reply via email to