From: Thomas Weißschuh Date: Sat, 1 Nov 2025 13:58:34 +0000 (+0100) Subject: fincore: do not fall back to mincore if cachestat fails with EPERM X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6cdbe06519ebc235c3d0fbb8e0092ffc8abf0ce6;p=thirdparty%2Futil-linux.git fincore: do not fall back to mincore if cachestat fails with EPERM cachestat() and mincore() both require that the tested file is (potentially) writable by the current user. If this permission check fails, cachestat() will return EPERM while mincore() will simply mark all pages as resident in core, as a proper EPERM would violate its API contract. But when cachestat() fails with EPERM we know that mincore() will not return real data, so instead show an error message. Reported-by: Christian Hesse Signed-off-by: Thomas Weißschuh --- diff --git a/misc-utils/fincore.c b/misc-utils/fincore.c index c297c1045..7ccec2a82 100644 --- a/misc-utils/fincore.c +++ b/misc-utils/fincore.c @@ -370,7 +370,7 @@ static int fincore_fd (struct fincore_control *ctl, if (errno != ENOSYS || ctl->cachestat) warn(_("failed to do cachestat: %s"), st->name); - if (ctl->cachestat) + if (errno == EPERM || ctl->cachestat) return -errno; return mincore_fd(ctl, fd, st);