aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2008-07-25 04:47:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:37 -0400
commit7759fc9d10d3559f365cb122d81e0c0a185fe0fe (patch)
tree2674cb439f9d27b5c0ef9ef078f6c8f7dac3b758
parent4efd1a1b2f09a4b746dd9dc057986c6dadcb1317 (diff)
devcgroup: code cleanup
- clean up set_majmin() - use simple_strtoul() to parse major/minor [akpm@linux-foundation.org: fix simple_strtoul() usage] [kosaki.motohiro@jp.fujitsu.com: fix warnings] Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: Serge Hallyn <serue@us.ibm.com> Cc: Paul Menage <menage@google.com> Cc: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--security/device_cgroup.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 9da3532726ff..7bd296cca041 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -202,7 +202,7 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss,
202 } 202 }
203 wh->minor = wh->major = ~0; 203 wh->minor = wh->major = ~0;
204 wh->type = DEV_ALL; 204 wh->type = DEV_ALL;
205 wh->access = ACC_MKNOD | ACC_READ | ACC_WRITE; 205 wh->access = ACC_MASK;
206 list_add(&wh->list, &dev_cgroup->whitelist); 206 list_add(&wh->list, &dev_cgroup->whitelist);
207 } else { 207 } else {
208 parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup); 208 parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup);
@@ -264,11 +264,10 @@ static char type_to_char(short type)
264 264
265static void set_majmin(char *str, unsigned m) 265static void set_majmin(char *str, unsigned m)
266{ 266{
267 memset(str, 0, MAJMINLEN);
268 if (m == ~0) 267 if (m == ~0)
269 sprintf(str, "*"); 268 strcpy(str, "*");
270 else 269 else
271 snprintf(str, MAJMINLEN, "%u", m); 270 sprintf(str, "%u", m);
272} 271}
273 272
274static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft, 273static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
@@ -360,6 +359,7 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
360{ 359{
361 struct dev_cgroup *cur_devcgroup; 360 struct dev_cgroup *cur_devcgroup;
362 const char *b; 361 const char *b;
362 char *endp;
363 int retval = 0, count; 363 int retval = 0, count;
364 struct dev_whitelist_item wh; 364 struct dev_whitelist_item wh;
365 365
@@ -395,11 +395,8 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
395 wh.major = ~0; 395 wh.major = ~0;
396 b++; 396 b++;
397 } else if (isdigit(*b)) { 397 } else if (isdigit(*b)) {
398 wh.major = 0; 398 wh.major = simple_strtoul(b, &endp, 10);
399 while (isdigit(*b)) { 399 b = endp;
400 wh.major = wh.major*10+(*b-'0');
401 b++;
402 }
403 } else { 400 } else {
404 return -EINVAL; 401 return -EINVAL;
405 } 402 }
@@ -412,11 +409,8 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
412 wh.minor = ~0; 409 wh.minor = ~0;
413 b++; 410 b++;
414 } else if (isdigit(*b)) { 411 } else if (isdigit(*b)) {
415 wh.minor = 0; 412 wh.minor = simple_strtoul(b, &endp, 10);
416 while (isdigit(*b)) { 413 b = endp;
417 wh.minor = wh.minor*10+(*b-'0');
418 b++;
419 }
420 } else { 414 } else {
421 return -EINVAL; 415 return -EINVAL;
422 } 416 }