From: Andreas Schwab Date: Wed, 1 Nov 2017 14:26:21 +0000 (+0100) Subject: Avoid wrong value from file-attributes on Linux kernel before 3.6 X-Git-Tag: emacs-26.0.91~419 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8453423c7c5e1886a301fb61c4077650f59e670b;p=emacs.git Avoid wrong value from file-attributes on Linux kernel before 3.6 * dired.c (file_attributes): Handle unsupported fstat on O_PATH descriptors. (bug#29070) --- diff --git a/src/dired.c b/src/dired.c index 28d1cffb44c..239b1acd1fb 100644 --- a/src/dired.c +++ b/src/dired.c @@ -953,7 +953,14 @@ file_attributes (int fd, char const *name, { record_unwind_protect_int (close_file_unwind, namefd); if (fstat (namefd, &s) != 0) - err = errno; + { + err = errno; + /* The Linux kernel before version 3.6 does not support + fstat on O_PATH file descriptors. Handle this error like + missing support for O_PATH. */ + if (err == EBADF) + err = EINVAL; + } else { err = 0;