From: Zbigniew Jędrzejewski-Szmek Date: Thu, 20 Apr 2023 15:42:57 +0000 (+0200) Subject: detect-virt: add message at debug level X-Git-Tag: v254-rc1~671 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08c2f9c626e0f0052d505b1b7e52f335c0fbfa1d;p=thirdparty%2Fsystemd.git detect-virt: add message at debug level Normal users do not have permissions to access /proc/1/root, so 'systemd-detect-virt -r' fails, but the output, even at debug level is cryptic: $ SYSTEMD_LOG_LEVEL=debug build/systemd-detect-virt -r Failed to check for chroot() environment: Permission denied Let's make this a bit easier to figure out: $ SYSTEMD_LOG_LEVEL=debug build/systemd-detect-virt -r Cannot stat /proc/1/root: Permission denied Failed to check for chroot() environment: Permission denied I looked over other users of files_same(), and I think in general the message at debug level is OK for them too. --- diff --git a/src/basic/stat-util.c b/src/basic/stat-util.c index e97770707f2..335daca2345 100644 --- a/src/basic/stat-util.c +++ b/src/basic/stat-util.c @@ -190,10 +190,10 @@ int files_same(const char *filea, const char *fileb, int flags) { assert(fileb); if (fstatat(AT_FDCWD, filea, &a, flags) < 0) - return -errno; + return log_debug_errno(errno, "Cannot stat %s: %m", filea); if (fstatat(AT_FDCWD, fileb, &b, flags) < 0) - return -errno; + return log_debug_errno(errno, "Cannot stat %s: %m", fileb); return stat_inode_same(&a, &b); }