chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8fc6691
)
nspawn: always use cg_get_path() to determine fs path for a cgroup
author
Lennart Poettering
<lennart@poettering.net>
Mon, 22 Apr 2013 20:11:05 +0000
(17:11 -0300)
committer
Lennart Poettering
<lennart@poettering.net>
Tue, 23 Apr 2013 02:14:12 +0000
(23:14 -0300)
src/nspawn/nspawn.c
patch
|
blob
|
history
diff --git
a/src/nspawn/nspawn.c
b/src/nspawn/nspawn.c
index b59b2673cd63545116509e9bd5f4fe3cdc7878c3..0a5a151202f0a7c652b6464ff93aed82b826ab7c 100644
(file)
--- a/
src/nspawn/nspawn.c
+++ b/
src/nspawn/nspawn.c
@@
-923,7
+923,8
@@
static int setup_cgroup(const char *path) {
}
static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, const char *directory) {
}
static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, const char *directory) {
- char buf[DECIMAL_STR_MAX(pid_t)], path[PATH_MAX];
+ _cleanup_free_ char *path = NULL;
+ char buf[DECIMAL_STR_MAX(pid_t)];
int r = 0, k;
assert(cgroup);
int r = 0, k;
assert(cgroup);
@@
-933,10
+934,10
@@
static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, cons
#ifdef HAVE_XATTR
assert_se(snprintf(buf, sizeof(buf), "%lu", (unsigned long) pid) < (int) sizeof(buf));
#ifdef HAVE_XATTR
assert_se(snprintf(buf, sizeof(buf), "%lu", (unsigned long) pid) < (int) sizeof(buf));
- r =
snprintf(path, sizeof(path), "/sys/fs/cgroup/systemd/%s", cgroup
);
- if (r
>= (int) sizeof(path)
) {
- log_error("
cgroup name too long"
);
- return
-EINVAL
;
+ r =
cg_get_path(SYSTEMD_CGROUP_CONTROLLER, cgroup, NULL, &path
);
+ if (r
< 0
) {
+ log_error("
Failed to get path: %s", strerror(-r)
);
+ return
r
;
}
r = setxattr(path, "trusted.init_pid", buf, strlen(buf), XATTR_CREATE);
}
r = setxattr(path, "trusted.init_pid", buf, strlen(buf), XATTR_CREATE);
@@
-954,7
+955,7
@@
static int save_attributes(const char *cgroup, pid_t pid, const char *uuid, cons
k = setxattr(path, "trusted.root_directory", directory, strlen(directory), XATTR_CREATE);
if (k < 0) {
k = setxattr(path, "trusted.root_directory", directory, strlen(directory), XATTR_CREATE);
if (k < 0) {
- log_warning("Failed to set %s attribute on %s: %m", "trusted.
machine_id
", path);
+ log_warning("Failed to set %s attribute on %s: %m", "trusted.
root_directory
", path);
if (r == 0)
r = k;
}
if (r == 0)
r = k;
}
@@
-1457,8
+1458,7
@@
int main(int argc, char *argv[]) {
if (setup_cgroup(newcg) < 0)
goto child_fail;
if (setup_cgroup(newcg) < 0)
goto child_fail;
- close_nointr_nofail(pipefd2[1]);
- close_nointr_nofail(pipefd2[0]);
+ close_pipe(pipefd2);
/* Mark everything as slave, so that we still
* receive mounts from the real root, but don't
/* Mark everything as slave, so that we still
* receive mounts from the real root, but don't