Subject: bug#29070: 26.0.90; emacs-26.0.90 pretest

From: Andreas Schwab <[email-masked]>
Date: Tue, 31 Oct 2017 15:27:32 +0100

On Okt 31 2017, andrés ramírez <[email-masked]> wrote:

> Hi Andreas.
>> What is the kernel version you are running?
>
> Linux chulpaca 3.4.113-sun8i #18 SMP PREEMPT Thu Jun 15 02:16:06 CEST 2017 armv7l GNU/Linux

That kernel does not support fstat on the O_PATH fd.  Please try this
patch:

diff --git a/src/dired.c b/src/dired.c
index 28d1cffb44..f192cf5c49 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 only supports fstat on O_PATH file
+	     descriptors since version 3.6.  Handle this error like
+	     missing support for O_PATH.  */
+	  if (err == EBADF)
+	    err = EINVAL;
+	}
       else
 	{
 	  err = 0;

Andreas.

-- 
Andreas Schwab, [email-masked]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."