From: Mike Yuan Date: Wed, 25 Feb 2026 08:26:44 +0000 (+0100) Subject: core/namespace: rename() might return ENOTEMPTY if target dir exists X-Git-Tag: v260-rc1~6^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a45fb074fedb488f5d16a0a3a50bd0e866453756;p=thirdparty%2Fsystemd.git core/namespace: rename() might return ENOTEMPTY if target dir exists --- diff --git a/src/core/namespace.c b/src/core/namespace.c index d363ac0973a..aa80570885e 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -3338,6 +3338,8 @@ static int make_tmp_prefix(const char *prefix) { _cleanup_close_ int fd = -EBADF; int r; + assert(prefix); + /* Don't do anything unless we know the dir is actually missing */ r = access(prefix, F_OK); if (r >= 0) @@ -3369,7 +3371,7 @@ static int make_tmp_prefix(const char *prefix) { r = RET_NERRNO(rename(t, prefix)); if (r < 0) { (void) rmdir(t); - return r == -EEXIST ? 0 : r; /* it's fine if someone else created the dir by now */ + return IN_SET(r, -EEXIST, -ENOTEMPTY) ? 0 : r; /* it's fine if someone else created the dir by now */ } return 0;