Commit 0e83397d authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

cgroup: only write one device entry at a time

We seem to have some reports of:

Error (cgroup.c:1193): cg: Failed writing c *:* m
b *:* m
c 1:3 rwm
c 1:5 rwm
c 1:7 rwm
c 5:0 rwm
c 5:2 rwm
c 1:8 rwm
c 1:9 rwm
c 136:* rwm
c 10:229 rwm to devices//lxc/c7/devices.allow: Argument list too long

so let's try and write these lines one by one, instead of simply advancing
the pointer along in the string. It's probably cleaner this way anyway :)
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
CC: Adrian Reber <adrian@lisas.de>
Tested-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 499f926f
......@@ -1246,12 +1246,13 @@ static void add_freezer_state_for_restore(CgroupPropEntry *entry, char *path, si
freezer_path[path_len] = 0;
}
static void advance_device_entry(char **buf)
static int next_device_entry(char *buf)
{
char *pos = *buf;
char *pos = buf;
while (1) {
if (*pos == '\n') {
*pos = '\0';
pos++;
break;
} else if (*pos == '\0') {
......@@ -1261,7 +1262,7 @@ static void advance_device_entry(char **buf)
pos++;
}
*buf = pos;
return pos - buf;
}
static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **ents,
......@@ -1346,13 +1347,16 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
}
xfree(old_name);
for (pos = pe->value; *pos; advance_device_entry(&pos)) {
pos = pe->value;
while (*pos) {
int offset = next_device_entry(pos);
pe->value = pos;
ret = restore_cgroup_prop(pe, path, off2);
if (ret < 0) {
pe->value = old_val;
return -1;
}
pos += offset;
}
pe->value = old_val;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment