GNU bug report logs - #60943
28.2; ‘tramp-handle-file-regular-p’ misses symlinks

Previous Next

Package: emacs;

Reported by: Greg Pfeil <greg <at> technomadic.org>

Date: Thu, 19 Jan 2023 08:22:02 UTC

Severity: normal

Found in version 28.2

Fixed in version 29.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 60943 <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Greg Pfeil <greg <at> technomadic.org>
Cc: 60943 <at> debbugs.gnu.org
Subject: Re: bug#60943: 28.2; ‘tramp-handle-file-regular-p’ misses symlinks
Date: Fri, 20 Jan 2023 11:56:07 +0100
Greg Pfeil <greg <at> technomadic.org> writes:

Hi Greg,

> I think sockets (where the 0th char is ?s) are also considered regular
> files. Also, I think that patch checks whether the truename is a
> regular file, but I believe /all/ symlinks are considered regular.

No, neither sockets nor symlinks to directories count as regular
files. See the Elisp manual (info "(elisp) Kinds of Files")

A socket is an "other I/O device" according to the description. And
symlinks are regular files only, if they point to a regular file.

> It just changes the equality check to check for the set of valid
> values. If we had the mode as a number, we could just check the one
> bit for regular files (which I think is what ‘file-regular-p’ does).

You can always check yourself in Emacs with a local file. For example,
if you have a socket like "/run/user/1000/bus":

--8<---------------cut here---------------start------------->8---
(file-exists-p (concat (getenv "XDG_RUNTIME_DIR") "/bus"))
=> t

(file-attribute-modes (file-attributes (concat (getenv "XDG_RUNTIME_DIR") "/bus")))
=> "srw-rw-rw-"

(file-regular-p (concat (getenv "XDG_RUNTIME_DIR") "/bus"))
=> nil
--8<---------------cut here---------------end--------------->8---

Or

--8<---------------cut here---------------start------------->8---
(make-directory "/tmp/foo")
(file-attribute-modes (file-attributes "/tmp/foo"))
=> "drwxr-xr-x"

(make-symbolic-link "/tmp/foo" "/tmp/bar")
(file-attribute-modes (file-attributes "/tmp/bar"))
=> "lrwxrwxrwx"

(file-regular-p "/tmp/bar")
=> nil
--8<---------------cut here---------------end--------------->8---

for symbolic links.

Best regards, Michael.




This bug report was last modified 2 years and 121 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.