diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-12-24 11:59:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-24 11:59:58 +0100 |
commit | ebe6ff658d2f97fe5b1b8ce390ee75e8e592938f (patch) | |
tree | 1ca42f41ea057e0849377342767d02c5b2f45fb5 /src/nspawn | |
parent | 15ce16477039f1bcdb7c9a4b3de8dc223804c2ca (diff) | |
parent | 785dde091d60c1364394425446673bf298b16661 (diff) | |
download | systemd-ebe6ff658d2f97fe5b1b8ce390ee75e8e592938f.tar.gz |
Merge pull request #7663 from keszybz/mkdir-return-value
util-lib: fix return value in mkdir_parents()
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn-mount.c | 9 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 24 |
2 files changed, 18 insertions, 15 deletions
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c index 920e114718..c9236ea3d1 100644 --- a/src/nspawn/nspawn-mount.c +++ b/src/nspawn/nspawn-mount.c @@ -474,9 +474,9 @@ static int mkdir_userns(const char *path, mode_t mode, MountSettingsMask mask, u assert(path); - r = mkdir(path, mode); - if (r < 0 && errno != EEXIST) - return -errno; + r = mkdir_errno_wrapper(path, mode); + if (r < 0 && r != -EEXIST) + return r; if ((mask & MOUNT_USE_USERNS) == 0) return 0; @@ -484,8 +484,7 @@ static int mkdir_userns(const char *path, mode_t mode, MountSettingsMask mask, u if (mask & MOUNT_IN_USERNS) return 0; - r = lchown(path, uid_shift, uid_shift); - if (r < 0) + if (lchown(path, uid_shift, uid_shift) < 0) return -errno; return 0; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 71b14e2302..f646971c30 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1313,13 +1313,14 @@ static int userns_lchown(const char *p, uid_t uid, gid_t gid) { static int userns_mkdir(const char *root, const char *path, mode_t mode, uid_t uid, gid_t gid) { const char *q; + int r; q = prefix_roota(root, path); - if (mkdir(q, mode) < 0) { - if (errno == EEXIST) - return 0; - return -errno; - } + r = mkdir_errno_wrapper(q, mode); + if (r == -EEXIST) + return 0; + if (r < 0) + return r; return userns_lchown(q, uid, gid); } @@ -1599,8 +1600,10 @@ static int setup_pts(const char *dest) { /* Mount /dev/pts itself */ p = prefix_roota(dest, "/dev/pts"); - if (mkdir(p, 0755) < 0) - return log_error_errno(errno, "Failed to create /dev/pts: %m"); + r = mkdir_errno_wrapper(p, 0755); + if (r < 0) + return log_error_errno(r, "Failed to create /dev/pts: %m"); + r = mount_verbose(LOG_ERR, "devpts", p, "devpts", MS_NOSUID|MS_NOEXEC, options); if (r < 0) return r; @@ -1846,12 +1849,13 @@ static int setup_journal(const char *directory) { /* don't create parents here — if the host doesn't have * permanent journal set up, don't force it here */ - if (mkdir(p, 0755) < 0 && errno != EEXIST) { + r = mkdir_errno_wrapper(p, 0755); + if (r < 0 && r != -EEXIST) { if (try) { - log_debug_errno(errno, "Failed to create %s, skipping journal setup: %m", p); + log_debug_errno(r, "Failed to create %s, skipping journal setup: %m", p); return 0; } else - return log_error_errno(errno, "Failed to create %s: %m", p); + return log_error_errno(r, "Failed to create %s: %m", p); } } else if (access(p, F_OK) < 0) |