From: Michael Albinus Date: Sun, 16 Jun 2024 14:03:41 +0000 (+0200) Subject: Tramp: handle non-standard file system like GPFS X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8282595cf0076a39a0b7615002686063b00da1da;p=emacs.git Tramp: handle non-standard file system like GPFS * doc/misc/tramp.texi (Frequently Asked Questions): Explain tramp-use-file-attributes. * lisp/net/tramp.el (tramp-use-file-attributes): New defcustom and defsubst. (tramp-skeleton-file-exists-p): * lisp/net/tramp-adb.el (tramp-adb-handle-file-executable-p) (tramp-adb-handle-file-readable-p): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-file-executable-p) (tramp-sudoedit-handle-file-readable-p) (tramp-sudoedit-handle-file-writable-p): Use it. * lisp/net/tramp-sh.el (tramp-sh-handle-file-executable-p) (tramp-sh-handle-file-readable-p) (tramp-sh-handle-file-writable-p): Use it. (tramp-sh-handle-set-file-acl): Fix property name. (cherry picked from commit 90234ba7f024f3dae342689b47930835e4904503) --- diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index bba9dfbb037..8342c330236 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 58886392dda..3a0cb69b2c6 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -1772,7 +1772,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. @@ -1783,7 +1783,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))))) @@ -1794,7 +1794,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))))) @@ -1826,7 +1826,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 279c46bfd8c..131250ba93a 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -477,7 +477,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 @@ -517,7 +517,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)))))) @@ -602,7 +602,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 fb49e57f781..b900357a215 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3434,6 +3434,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." @@ -3450,7 +3464,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))))))