[PATCH 6/6] Container Freezer: Use cgroup write_string method

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the new cgroup write_string method rather than the raw write method
because it better matches the needs of the freezer cgroup subsystem.

Signed-off-by: Matt Helsley <matthltc@xxxxxxxxxx>
---
 kernel/cgroup_freezer.c |   21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

Index: linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
===================================================================
--- linux-2.6.27-rc1-mm1.orig/kernel/cgroup_freezer.c
+++ linux-2.6.27-rc1-mm1/kernel/cgroup_freezer.c
@@ -29,11 +29,10 @@
 static const char *freezer_state_strs[] = {
 	"RUNNING",
 	"FREEZING",
 	"FROZEN",
 };
-#define STATE_MAX_STRLEN 8
 
 /*
  * State diagram (transition labels in parenthesis):
  *
  *  RUNNING -(FROZEN)-> FREEZING -(FROZEN)-> FROZEN
@@ -278,27 +277,17 @@ out:
 	spin_unlock_irq(&freezer->lock);
 
 	return retval;
 }
 
-static ssize_t freezer_write(struct cgroup *cgroup,
-			     struct cftype *cft,
-			     struct file *file,
-			     const char __user *userbuf,
-			     size_t nbytes, loff_t *unused_ppos)
+static int freezer_write(struct cgroup *cgroup,
+			 struct cftype *cft,
+			 const char *buffer)
 {
-	char buffer[STATE_MAX_STRLEN + 1];
-	int retval = 0;
+	int retval;
 	enum freezer_state goal_state;
 
-	if (nbytes >= PATH_MAX)
-		return -E2BIG;
-	nbytes = min(sizeof(buffer) - 1, nbytes);
-	if (copy_from_user(buffer, userbuf, nbytes))
-		return -EFAULT;
-	buffer[nbytes + 1] = 0; /* nul-terminate */
-	strstrip(buffer); /* remove any trailing whitespace */
 	if (strcmp(buffer, freezer_state_strs[STATE_RUNNING]) == 0)
 		goal_state = STATE_RUNNING;
 	else if (strcmp(buffer, freezer_state_strs[STATE_FROZEN]) == 0)
 		goal_state = STATE_FROZEN;
 	else
@@ -313,11 +302,11 @@ static ssize_t freezer_write(struct cgro
 
 static struct cftype files[] = {
 	{
 		.name = "state",
 		.read_seq_string = freezer_read,
-		.write = freezer_write,
+		.write_string = freezer_write,
 	},
 };
 
 static int freezer_populate(struct cgroup_subsys *ss, struct cgroup *cgroup)
 {

-- 
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux