aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorPaul Jackson <pj@sgi.com>2008-02-07 03:13:44 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 11:42:18 -0500
commit622d42cac9ed42098aa50c53994f625abfa3d473 (patch)
tree9bb8e2b5e84406609f2bcf04f45c60321511ca1a /kernel
parente18f6318e5dab189efd4cb0bbfcbd923cc373e3c (diff)
cgroup simplify space stripping
Simplify the space stripping code in cgroup file write. [akpm@linux-foundation.org: s/BUG_ON/BUILD_BUG_ON/] Signed-off-by: Paul Jackson <pj@sgi.com> Acked-by: Paul Menage <menage@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 54760d5b651e..7d207414f2c7 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1326,6 +1326,7 @@ static ssize_t cgroup_common_file_write(struct cgroup *cgrp,
1326 goto out1; 1326 goto out1;
1327 } 1327 }
1328 buffer[nbytes] = 0; /* nul-terminate */ 1328 buffer[nbytes] = 0; /* nul-terminate */
1329 strstrip(buffer); /* strip -just- trailing whitespace */
1329 1330
1330 mutex_lock(&cgroup_mutex); 1331 mutex_lock(&cgroup_mutex);
1331 1332
@@ -1346,21 +1347,9 @@ static ssize_t cgroup_common_file_write(struct cgroup *cgrp,
1346 clear_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags); 1347 clear_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
1347 break; 1348 break;
1348 case FILE_RELEASE_AGENT: 1349 case FILE_RELEASE_AGENT:
1349 { 1350 BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
1350 struct cgroupfs_root *root = cgrp->root; 1351 strcpy(cgrp->root->release_agent_path, buffer);
1351 /* Strip trailing newline */
1352 if (nbytes && (buffer[nbytes-1] == '\n'))
1353 buffer[nbytes-1] = 0;
1354
1355 /* We never write anything other than '\0'
1356 * into the last char of release_agent_path,
1357 * so it always remains a NUL-terminated
1358 * string */
1359 strncpy(root->release_agent_path, buffer, nbytes);
1360 root->release_agent_path[nbytes] = 0;
1361
1362 break; 1352 break;
1363 }
1364 default: 1353 default:
1365 retval = -EINVAL; 1354 retval = -EINVAL;
1366 goto out2; 1355 goto out2;