[systemd-devel] [PATCH 2/2] nspawn: skip symlink to a combined cgroup hierarchy if it already exists
Lennart Poettering
lennart at poettering.net
Wed May 13 05:50:01 PDT 2015
On Wed, 13.05.15 11:15, Iago López Galeiras (iago at endocode.com) wrote:
> - if (symlink(combined, target) < 0)
> + if (symlink(combined, target) < 0) {
> + if (errno == EEXIST) {
> + r = readlink_malloc(target, &p);
> + if (r < 0)
> + return log_error_errno(r, "Failed to read link %s: %m", target);
> + else if (!streq(p, combined)) {
> + log_error("Invalid existing symlink for combined hierarchy");
> + return -EINVAL;
> + }
> + } else
> return log_error_errno(errno, "Failed to create symlink for combined hierarchy: %m");
Indentation is weird, needs to be 8 space...
I think I'd prefer if the code for supressing and error when the
symlink is already OK would actually live in some new call in util.c
though. Maybe call it symlink_idempotent() or so?
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list