#include <unistd.h>
#include <string.h>
+#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
} memory;
struct { /* cpuacct-specific controls */
int usage_percpu; /* usage_percpu */
+ int stat; /* stat */
} cpuacct;
struct { /* cpu-specific controls */
int shares; /* shares */
RWCTRL(_a, cpuacct._path, cpuacct, _fld, _fmt)
static control_descr_t cpuacct_controls[] = {
- RO("Usage", usage_percpu, usage_percpu, NONE),
+ RO("Usage", usage_percpu, usage_percpu, INTARR),
+ RO("Stat" , stat , stat , INTTBL),
{ NULL, NULL, -1, 0, 0 }
};
if ((fd = get_cgroup_fd(cgrp->cg, name, NULL)) < 0)
return 0;
+ mrp_debug("control fd for field '%s' is %d", name, fd);
+
switch (lua_type(L, -1)) {
case LUA_TSTRING:
val = lua_tostring(L, -1);
return luaL_error(L, "expecting string or integer value");
}
+ mrp_debug("writing value '%s' for field '%s'", val, name);
+
if (write(fd, val, len) == len)
return 1;
else
}
else {
buf[len] = '\0';
+ while (len >= 1 && buf[len-1] == '\n')
+ buf[--len] = '\0';
+
+ mrp_debug("value for field '%s': '%s'", name, buf);
+
return push_formatted(L, fmt, buf);
}
}
lua_rawseti(L, -2, i);
i++;
- p = (e && *e) ? e + 1 : NULL;
+ if (e && *e) {
+ p = e + 1;
+ while (isspace(*p))
+ p++;
+ }
+ else
+ p = NULL;
}
return 1;
lua_rawseti(L, -2, i);
i++;
- p = e ? e + 1 : NULL;
+ if (e && *e) {
+ p = e + 1;
+ while (isspace(*p))
+ p++;
+ }
+ else
+ p = NULL;
}
return 1;