summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2022-11-21 10:49:37 +0100
committerDaan De Meyer <daan.j.demeyer@gmail.com>2022-11-21 10:49:37 +0100
commit92b11378ff2e32626df830756d552d8e7e20e4a5 (patch)
treed00d187054cd8c337bbe5236ba9852c75c5cb3ab /src
parentmkfs-util: Use GID_FMT (diff)
downloadsystemd-92b11378ff2e32626df830756d552d8e7e20e4a5.tar.xz
systemd-92b11378ff2e32626df830756d552d8e7e20e4a5.zip
mkfs-util: Prefer fd based stat() where possible
Diffstat (limited to 'src')
-rw-r--r--src/shared/mkfs-util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shared/mkfs-util.c b/src/shared/mkfs-util.c
index 0f4d85b58c..b06ba32089 100644
--- a/src/shared/mkfs-util.c
+++ b/src/shared/mkfs-util.c
@@ -165,7 +165,7 @@ static int do_mcopy(const char *node, const char *root) {
if (r < 0)
return log_oom();
- if (stat(root, &st) < 0)
+ if (fstat(dirfd(rootdir), &st) < 0)
return log_error_errno(errno, "Failed to stat '%s': %m", root);
r = safe_fork("(mcopy)", FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_WAIT|FORK_STDOUT_TO_STDERR|FORK_NEW_USERNS, NULL);