diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index ec8a8d5c3eb..dc119e87849 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -5546,6 +5546,18 @@ as follows: @end lisp +@item +@value{tramp} does not show directories or files although they are +readable + +@vindex tramp-use-file-attributes +Internally, @value{tramp} uses commands like @command{ls} or +@command{stat} in order to determine file permissions. On some file +systems, like @acronym{GPFS}, they don't report proper information. +Set the user option @code{tramp-use-file-attributes} to @code{nil} in +such a case. + + @item Where are remote files trashed to? diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index fb728dadd2d..5b1c4ba5b19 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -480,7 +480,7 @@ Emacs dired can't find files." (with-tramp-file-property v localname "file-executable-p" ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (or (tramp-check-cached-permissions v ?x) (tramp-check-cached-permissions v ?s)) (tramp-adb-send-command-and-check @@ -498,7 +498,7 @@ Emacs dired can't find files." (with-tramp-file-property v localname "file-readable-p" ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (tramp-handle-file-readable-p filename) (tramp-adb-send-command-and-check v (format "test -r %s" (tramp-shell-quote-argument localname))))))) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index a13ce01fd50..02be2ed4b7f 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1770,7 +1770,7 @@ ID-FORMAT valid values are `string' and `integer'." (tramp-set-file-property v localname "file-acl" acl-string) t) ;; In case of errors, we return nil. - (tramp-flush-file-property v localname "file-acl-string") + (tramp-flush-file-property v localname "file-acl") nil))) ;; Simple functions using the `test' command. @@ -1781,7 +1781,7 @@ ID-FORMAT valid values are `string' and `integer'." (with-tramp-file-property v localname "file-executable-p" ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (or (tramp-check-cached-permissions v ?x) (tramp-check-cached-permissions v ?s)) (tramp-run-test v "-x" localname))))) @@ -1792,7 +1792,7 @@ ID-FORMAT valid values are `string' and `integer'." (with-tramp-file-property v localname "file-readable-p" ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (tramp-handle-file-readable-p filename) (tramp-run-test v "-r" localname))))) @@ -1824,7 +1824,7 @@ ID-FORMAT valid values are `string' and `integer'." (if (file-exists-p filename) ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (tramp-check-cached-permissions v ?w) (tramp-run-test v "-w" localname)) ;; If file doesn't exist, check if directory is writable. diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 7bbfec62753..c82cd2dc0e1 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -475,7 +475,7 @@ the result will be a local, non-Tramp, file name." (with-tramp-file-property v localname "file-executable-p" ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (or (tramp-check-cached-permissions v ?x) (tramp-check-cached-permissions v ?s)) (tramp-sudoedit-send-command @@ -515,7 +515,7 @@ the result will be a local, non-Tramp, file name." (with-tramp-file-property v localname "file-readable-p" ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (tramp-handle-file-readable-p filename) (tramp-sudoedit-send-command v "test" "-r" (file-name-unquote localname)))))) @@ -600,7 +600,7 @@ the result will be a local, non-Tramp, file name." (if (file-exists-p filename) ;; Examine `file-attributes' cache to see if request can be ;; satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (tramp-check-cached-permissions v ?w) (tramp-sudoedit-send-command v "test" "-w" (file-name-unquote localname))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 4dd0d1d63a4..ee7fa59ad21 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3444,6 +3444,20 @@ BODY is the backend specific code." (tramp-dissect-file-name ,directory) 'file-missing ,directory) nil))) +(defcustom tramp-use-file-attributes t + "Whether to use \"file-attributes\" file property for check. +This is relevant for `file-directory-p', `file-executable-p', +`file-exists-p', and `file-readable-p'. On some file systems, like +GPFS, the permission string is not trustworthy." + :version "30.1" + :type 'boolean) + +(defsubst tramp-use-file-attributes (vec) + "Whether to use \"file-attributes\" file property for check." + (and tramp-use-file-attributes + (tramp-file-property-p + vec (tramp-file-name-localname vec) "file-attributes"))) + (defmacro tramp-skeleton-file-exists-p (filename &rest body) "Skeleton for `tramp-*-handle-file-exists-p'. BODY is the backend specific code." @@ -3460,7 +3474,7 @@ BODY is the backend specific code." (with-tramp-file-property v localname "file-exists-p" ;; Examine `file-attributes' cache to see if request can ;; be satisfied without remote operation. - (if (tramp-file-property-p v localname "file-attributes") + (if (tramp-use-file-attributes v) (not (null (tramp-get-file-property v localname "file-attributes"))) ,@body))))))