aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2026-02-12 19:24:10 +0100
committerMichael Albinus2026-02-12 19:24:10 +0100
commite0e0e95f5be6beb4e0a528e95ac466751b2f6a31 (patch)
tree875c633a843db3d9befd3a478e6ca8b76d29e3b0
parenteece2377dd2e2113f97b27d4ca43f718e6e3e2a7 (diff)
downloademacs-e0e0e95f5be6beb4e0a528e95ac466751b2f6a31.tar.gz
emacs-e0e0e95f5be6beb4e0a528e95ac466751b2f6a31.zip
Tramp signals 'remote-file-error' consequently
* doc/misc/tramp.texi (External packages): Mention also special events. Emphasise, that Tramp raises remote-file-error. * etc/NEWS: Tramp signals 'remote-file-error' consequently. Presentational fixes and improvements. * lisp/net/tramp.el (tramp-skeleton-process-file) (tramp-handle-make-symbolic-link, tramp-process-actions) (tramp-wait-for-regexp, tramp-send-string): * lisp/net/tramp-adb.el (tramp-adb-get-device) (tramp-adb-send-command-and-check, tramp-adb-barf-unless-okay) (tramp-adb-wait-for-output, tramp-adb-maybe-open-connection): * lisp/net/tramp-archive.el (tramp-archive-handle-not-implemented): * lisp/net/tramp-crypt.el (tramp-crypt-do-encrypt-or-decrypt-file-name) (tramp-crypt-do-encrypt-or-decrypt-file): * lisp/net/tramp-gvfs.el (tramp-gvfs-dbus-event-error) (tramp-gvfs-maybe-open-connection): * lisp/net/tramp-sh.el (tramp-do-directory-files-and-attributes-with-perl) (tramp-do-copy-or-rename-file-directly) (tramp-do-copy-or-rename-file-out-of-band) (tramp-sh-handle-file-local-copy, tramp-sh-handle-write-region) (tramp-bundle-read-file-names, tramp-maybe-send-script) (tramp-find-file-exists-command, tramp-barf-if-no-shell-prompt) (tramp-maybe-open-connection, tramp-wait-for-output) (tramp-send-command-and-check, tramp-barf-unless-okay) (tramp-send-command-and-read, tramp-get-ls-command): * lisp/net/tramp-smb.el (tramp-smb-handle-file-attributes) (tramp-smb-handle-make-symbolic-link) (tramp-smb-maybe-open-connection, tramp-smb-call-winexe): * lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command-and-read): Raise a `remote-file-error' in case of connection problems. * lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection): Improve check for host. * lisp/net/tramp-smb.el (tramp-smb-get-localname): Improve error message. * lisp/net/tramp-sudoedit.el (tramp-default-host-alist): Set a default for "sudoedit" method. (tramp-sudoedit-maybe-open-connection): Check for proper host name. (tramp-sudoedit-send-command): Do not expand ?h. * lisp/net/tramp.el (tramp-compute-multi-hops): Check for cycle proxy definition. * test/lisp/net/tramp-archive-tests.el (tramp-archive-test20-file-modes) (tramp-archive-test21-file-links): Check for `rmote-file-error'. * test/lisp/net/tramp-tests.el (tramp-file-name-with-sudo): Declare. (tramp--test-ignore-make-symbolic-link-error): Check for `rmote-file-error'. (tramp-test03-file-name-method-rules): Delete. (tramp-test03-file-error): New test. (tramp--test-supports-processes-p): Make it more rebust.
-rw-r--r--doc/misc/tramp.texi10
-rw-r--r--etc/NEWS14
-rw-r--r--lisp/net/tramp-adb.el23
-rw-r--r--lisp/net/tramp-archive.el2
-rw-r--r--lisp/net/tramp-crypt.el4
-rw-r--r--lisp/net/tramp-gvfs.el10
-rw-r--r--lisp/net/tramp-rclone.el94
-rw-r--r--lisp/net/tramp-sh.el53
-rw-r--r--lisp/net/tramp-smb.el20
-rw-r--r--lisp/net/tramp-sshfs.el2
-rw-r--r--lisp/net/tramp-sudoedit.el11
-rw-r--r--lisp/net/tramp.el19
-rw-r--r--test/lisp/net/tramp-archive-tests.el6
-rw-r--r--test/lisp/net/tramp-tests.el52
14 files changed, 186 insertions, 134 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi
index c916588a060..73c3e1ed326 100644
--- a/doc/misc/tramp.texi
+++ b/doc/misc/tramp.texi
@@ -6658,7 +6658,7 @@ root directory, it is most likely sufficient to make the
6658@code{default-directory} of the process buffer as the root directory. 6658@code{default-directory} of the process buffer as the root directory.
6659 6659
6660 6660
6661@subsection Timers, process filters, process sentinels, redisplay 6661@subsection Timers, process filters, process sentinels, special events, redisplay
6662 6662
6663@vindex remote-file-error 6663@vindex remote-file-error
6664Timers run asynchronously at any time when Emacs is waiting for 6664Timers run asynchronously at any time when Emacs is waiting for
@@ -6678,7 +6678,13 @@ wrapping the timer function body as follows:
6678@end lisp 6678@end lisp
6679 6679
6680A similar problem could happen with process filters, process 6680A similar problem could happen with process filters, process
6681sentinels, and redisplay (updating the mode line). 6681sentinels, special event handlers, and redisplay (updating the mode
6682line).
6683
6684@strong{Note} that @value{tramp} raises a @code{remote-file-error}
6685error for any connection-related problem. You can protect against all
6686such problems with the code snippet above (or with a
6687@code{condition-case} form with a @code{remote-file-error} handler).
6682 6688
6683 6689
6684@node Extension packages 6690@node Extension packages
diff --git a/etc/NEWS b/etc/NEWS
index 076a4e2c15e..02185050e12 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -62,7 +62,7 @@ You can keep the old behavior by putting '(xterm-mouse-mode -1)' in your
62init file. 62init file.
63 63
64+++ 64+++
65** 'site-start.el' is now loaded before the user's early init file. 65** site-start.el is now loaded before the user's early init file.
66Previously, the order was early-init.el, site-start.el and then the 66Previously, the order was early-init.el, site-start.el and then the
67user's regular init file, but now site-start.el comes first. This 67user's regular init file, but now site-start.el comes first. This
68allows site administrators to customize things that can normally only be 68allows site administrators to customize things that can normally only be
@@ -2183,6 +2183,12 @@ To unconditionally enable 'flyspell-mode' from a hook, use this instead:
2183** Tramp 2183** Tramp
2184 2184
2185+++ 2185+++
2186*** Tramp signals 'remote-file-error' in case of connection problems.
2187This is a subcategory of 'file-error'. Therefore, all checks for
2188'file-error' in 'condition-case', 'ignore-error', 'error-conditions' and
2189alike still work.
2190
2191+++
2186*** New command 'tramp-cleanup-bufferless-connections'. 2192*** New command 'tramp-cleanup-bufferless-connections'.
2187Connection-related objects for which no associated buffers exist, except 2193Connection-related objects for which no associated buffers exist, except
2188for Tramp internal buffers, are flushed. This is helpful to prune 2194for Tramp internal buffers, are flushed. This is helpful to prune
@@ -3352,7 +3358,7 @@ changing the marking state in the calendar buffer.
3352A new library has been added to the calendar for handling iCalendar 3358A new library has been added to the calendar for handling iCalendar
3353(RFC5545) data. The library is designed for reuse in other parts of 3359(RFC5545) data. The library is designed for reuse in other parts of
3354Emacs and in third-party packages. Package authors can find the new 3360Emacs and in third-party packages. Package authors can find the new
3355library in the Emacs distribution under lisp/calendar/icalendar-*.el. 3361library in the Emacs distribution under "lisp/calendar/icalendar-*.el".
3356 3362
3357Most of the functions and variables in the older icalendar.el have been 3363Most of the functions and variables in the older icalendar.el have been
3358marked obsolete and now suggest appropriate replacements from the new 3364marked obsolete and now suggest appropriate replacements from the new
@@ -3605,7 +3611,7 @@ This package provides platform-neutral interfaces to block your system
3605from entering idle sleep and a hook to process pre-sleep and post-wake 3611from entering idle sleep and a hook to process pre-sleep and post-wake
3606events. You can use this to avoid the system entering an idle sleep 3612events. You can use this to avoid the system entering an idle sleep
3607state and interrupting a long-running process due to lack of user 3613state and interrupting a long-running process due to lack of user
3608activity. The sleep event hook lets you, for example close external 3614activity. The sleep event hook lets you, for example, close external
3609connections or serial ports before sleeping, and reestablish them when 3615connections or serial ports before sleeping, and reestablish them when
3610the system wakes up. 3616the system wakes up.
3611 3617
@@ -3615,6 +3621,7 @@ blocking requires org.freedesktop.Screensaver service), macOS
3615(sleep/display blocking requires version 10.9 or later, sleep events are 3621(sleep/display blocking requires version 10.9 or later, sleep events are
3616supported on all versions), MS-Windows (sleep blocking is supported on 3622supported on all versions), MS-Windows (sleep blocking is supported on
3617all versions, sleep events require Windows 8 or later). 3623all versions, sleep events require Windows 8 or later).
3624
3618 3625
3619* Incompatible Lisp Changes in Emacs 31.1 3626* Incompatible Lisp Changes in Emacs 31.1
3620 3627
@@ -3788,6 +3795,7 @@ When no tags file is loaded, symbol completion just won't provide any
3788suggestions. So the 'M-?' command now works without a tags table. And 3795suggestions. So the 'M-?' command now works without a tags table. And
3789the 'M-.' will show a message describing the several built-in options 3796the 'M-.' will show a message describing the several built-in options
3790that will provide an Xref backend when used. 3797that will provide an Xref backend when used.
3798
3791 3799
3792* Lisp Changes in Emacs 31.1 3800* Lisp Changes in Emacs 31.1
3793 3801
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 5bcb92536fd..c20b5df9b59 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -974,7 +974,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
974 (sleep-for 0.1) 974 (sleep-for 0.1)
975 host) 975 host)
976 (t (tramp-error 976 (t (tramp-error
977 vec 'file-error "Could not find device %s" host))))))) 977 vec 'remote-file-error "Could not find device %s" host)))))))
978 978
979(defun tramp-adb-execute-adb-command (vec &rest args) 979(defun tramp-adb-execute-adb-command (vec &rest args)
980 "Execute an adb command. 980 "Execute an adb command.
@@ -1047,7 +1047,7 @@ the exit status."
1047 (with-current-buffer (tramp-get-connection-buffer vec) 1047 (with-current-buffer (tramp-get-connection-buffer vec)
1048 (unless (tramp-search-regexp (rx "tramp_exit_status " (+ digit))) 1048 (unless (tramp-search-regexp (rx "tramp_exit_status " (+ digit)))
1049 (tramp-error 1049 (tramp-error
1050 vec 'file-error "Couldn't find exit status of `%s'" command)) 1050 vec 'remote-file-error "Couldn't find exit status of `%s'" command))
1051 (skip-chars-forward "^ ") 1051 (skip-chars-forward "^ ")
1052 (prog1 1052 (prog1
1053 (if exit-status 1053 (if exit-status
@@ -1060,13 +1060,14 @@ the exit status."
1060 "Run COMMAND, check exit status, throw error if exit status not okay. 1060 "Run COMMAND, check exit status, throw error if exit status not okay.
1061FMT and ARGS are passed to `error'." 1061FMT and ARGS are passed to `error'."
1062 (unless (tramp-adb-send-command-and-check vec command) 1062 (unless (tramp-adb-send-command-and-check vec command)
1063 (apply #'tramp-error vec 'file-error fmt args))) 1063 (apply #'tramp-error vec 'remote-file-error fmt args)))
1064 1064
1065(defun tramp-adb-wait-for-output (proc &optional timeout) 1065(defun tramp-adb-wait-for-output (proc &optional timeout)
1066 "Wait for output from remote command." 1066 "Wait for output from remote command."
1067 (unless (buffer-live-p (process-buffer proc)) 1067 (unless (buffer-live-p (process-buffer proc))
1068 (delete-process proc) 1068 (delete-process proc)
1069 (tramp-error proc 'file-error "Process `%s' not available, try again" proc)) 1069 (tramp-error
1070 proc 'remote-file-error "Process `%s' not available, try again" proc))
1070 (let ((prompt (tramp-get-connection-property proc "prompt" tramp-adb-prompt))) 1071 (let ((prompt (tramp-get-connection-property proc "prompt" tramp-adb-prompt)))
1071 (with-current-buffer (process-buffer proc) 1072 (with-current-buffer (process-buffer proc)
1072 (if (tramp-wait-for-regexp proc timeout prompt) 1073 (if (tramp-wait-for-regexp proc timeout prompt)
@@ -1085,10 +1086,11 @@ FMT and ARGS are passed to `error'."
1085 (delete-region (point) (point-max)))) 1086 (delete-region (point) (point-max))))
1086 (if timeout 1087 (if timeout
1087 (tramp-error 1088 (tramp-error
1088 proc 'file-error 1089 proc 'remote-file-error
1089 "[[Remote prompt `%s' not found in %d secs]]" prompt timeout) 1090 "[[Remote prompt `%s' not found in %d secs]]" prompt timeout)
1090 (tramp-error 1091 (tramp-error
1091 proc 'file-error "[[Remote prompt `%s' not found]]" prompt)))))) 1092 proc 'remote-file-error
1093 "[[Remote prompt `%s' not found]]" prompt))))))
1092 1094
1093(defun tramp-adb-maybe-open-connection (vec) 1095(defun tramp-adb-maybe-open-connection (vec)
1094 "Maybe open a connection VEC. 1096 "Maybe open a connection VEC.
@@ -1110,13 +1112,14 @@ connection if a previous connection has died for some reason."
1110 ;; whether it is still the same device. 1112 ;; whether it is still the same device.
1111 (when 1113 (when
1112 (and user (not (tramp-get-connection-property vec " su-command-p" t))) 1114 (and user (not (tramp-get-connection-property vec " su-command-p" t)))
1113 (tramp-error vec 'file-error "Cannot switch to user `%s'" user)) 1115 (tramp-error vec 'remote-file-error "Cannot switch to user `%s'" user))
1114 1116
1115 (unless (process-live-p p) 1117 (unless (process-live-p p)
1116 (save-match-data 1118 (save-match-data
1117 (when (and p (processp p)) (delete-process p)) 1119 (when (and p (processp p)) (delete-process p))
1118 (if (tramp-string-empty-or-nil-p device) 1120 (if (tramp-string-empty-or-nil-p device)
1119 (tramp-error vec 'file-error "Device %s not connected" host)) 1121 (tramp-error
1122 vec 'remote-file-error "Device %s not connected" host))
1120 (with-tramp-progress-reporter vec 3 "Opening adb shell connection" 1123 (with-tramp-progress-reporter vec 3 "Opening adb shell connection"
1121 (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct? 1124 (let* ((coding-system-for-read 'utf-8-dos) ; Is this correct?
1122 (process-connection-type tramp-process-connection-type) 1125 (process-connection-type tramp-process-connection-type)
@@ -1137,7 +1140,7 @@ connection if a previous connection has died for some reason."
1137 (tramp-send-string vec tramp-rsh-end-of-line) 1140 (tramp-send-string vec tramp-rsh-end-of-line)
1138 (tramp-adb-wait-for-output p 30) 1141 (tramp-adb-wait-for-output p 30)
1139 (unless (process-live-p p) 1142 (unless (process-live-p p)
1140 (tramp-error vec 'file-error "Terminated!")) 1143 (tramp-error vec 'remote-file-error "Terminated!"))
1141 1144
1142 ;; Set connection-local variables. 1145 ;; Set connection-local variables.
1143 (tramp-set-connection-local-variables vec) 1146 (tramp-set-connection-local-variables vec)
@@ -1193,7 +1196,7 @@ connection if a previous connection has died for some reason."
1193 ;; Do not flush, we need the nil value. 1196 ;; Do not flush, we need the nil value.
1194 (tramp-set-connection-property vec " su-command-p" nil) 1197 (tramp-set-connection-property vec " su-command-p" nil)
1195 (tramp-error 1198 (tramp-error
1196 vec 'file-error "Cannot switch to user `%s'" user))) 1199 vec 'remote-file-error "Cannot switch to user `%s'" user)))
1197 1200
1198 ;; Mark it as connected. 1201 ;; Mark it as connected.
1199 (tramp-set-connection-property p "connected" t)))))))) 1202 (tramp-set-connection-property p "connected" t))))))))
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index a4323156c2a..e970fd1cd56 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -737,7 +737,7 @@ offered."
737 (apply #'tramp-archive-file-name-for-operation operation args))))) 737 (apply #'tramp-archive-file-name-for-operation operation args)))))
738 (tramp-message v 10 "%s" (cons operation args)) 738 (tramp-message v 10 "%s" (cons operation args))
739 (tramp-error 739 (tramp-error
740 v 'file-error 740 v 'remote-file-error
741 "Operation `%s' not implemented for file archives" operation))) 741 "Operation `%s' not implemented for file archives" operation)))
742 742
743(add-hook 'tramp-unload-hook 743(add-hook 'tramp-unload-hook
diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el
index 565b9f0a5aa..59e4cea2edb 100644
--- a/lisp/net/tramp-crypt.el
+++ b/lisp/net/tramp-crypt.el
@@ -446,7 +446,7 @@ Otherwise, return NAME."
446 crypt-vec (if (eq op 'encrypt) "encode" "decode") 446 crypt-vec (if (eq op 'encrypt) "encode" "decode")
447 tramp-compat-temporary-file-directory localname) 447 tramp-compat-temporary-file-directory localname)
448 (tramp-error 448 (tramp-error
449 crypt-vec 'file-error "%s of file name %s failed" 449 crypt-vec 'remote-file-error "%s of file name %s failed"
450 (if (eq op 'encrypt) "Encoding" "Decoding") name)) 450 (if (eq op 'encrypt) "Encoding" "Decoding") name))
451 (with-current-buffer (tramp-get-connection-buffer crypt-vec) 451 (with-current-buffer (tramp-get-connection-buffer crypt-vec)
452 (goto-char (point-min)) 452 (goto-char (point-min))
@@ -481,7 +481,7 @@ Raise an error if this fails."
481 (file-name-directory infile) 481 (file-name-directory infile)
482 (concat "/" (file-name-nondirectory infile))) 482 (concat "/" (file-name-nondirectory infile)))
483 (tramp-error 483 (tramp-error
484 crypt-vec 'file-error "%s of file %s failed" 484 crypt-vec 'remote-file-error "%s of file %s failed"
485 (if (eq op 'encrypt) "Encrypting" "Decrypting") infile)) 485 (if (eq op 'encrypt) "Encrypting" "Decrypting") infile))
486 (with-current-buffer (tramp-get-connection-buffer crypt-vec) 486 (with-current-buffer (tramp-get-connection-buffer crypt-vec)
487 (write-region nil nil outfile))))) 487 (write-region nil nil outfile)))))
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 64efce227d6..0f68e4d768a 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1006,7 +1006,7 @@ The global value will always be nil; it is bound where needed.")
1006 "Called when a D-Bus error message arrives, see `dbus-event-error-functions'." 1006 "Called when a D-Bus error message arrives, see `dbus-event-error-functions'."
1007 (when tramp-gvfs-dbus-event-vector 1007 (when tramp-gvfs-dbus-event-vector
1008 (tramp-message tramp-gvfs-dbus-event-vector 6 "%S" event) 1008 (tramp-message tramp-gvfs-dbus-event-vector 6 "%S" event)
1009 (tramp-error tramp-gvfs-dbus-event-vector 'file-error (cadr err)))) 1009 (tramp-error tramp-gvfs-dbus-event-vector 'remote-file-error (cadr err))))
1010 1010
1011(add-hook 'dbus-event-error-functions #'tramp-gvfs-dbus-event-error) 1011(add-hook 'dbus-event-error-functions #'tramp-gvfs-dbus-event-error)
1012(add-hook 'tramp-gvfs-unload-hook 1012(add-hook 'tramp-gvfs-unload-hook
@@ -2234,7 +2234,7 @@ connection if a previous connection has died for some reason."
2234 method) 2234 method)
2235 tramp-gvfs-mounttypes) 2235 tramp-gvfs-mounttypes)
2236 (tramp-error 2236 (tramp-error
2237 vec 'file-error "Method `%s' not supported by GVFS" method))) 2237 vec 'remote-file-error "Method `%s' not supported by GVFS" method)))
2238 2238
2239 ;; For password handling, we need a process bound to the 2239 ;; For password handling, we need a process bound to the
2240 ;; connection buffer. Therefore, we create a dummy process. 2240 ;; connection buffer. Therefore, we create a dummy process.
@@ -2332,10 +2332,10 @@ connection if a previous connection has died for some reason."
2332 vec 'tramp-connection-timeout tramp-connection-timeout) 2332 vec 'tramp-connection-timeout tramp-connection-timeout)
2333 (if (tramp-string-empty-or-nil-p user-domain) 2333 (if (tramp-string-empty-or-nil-p user-domain)
2334 (tramp-error 2334 (tramp-error
2335 vec 'file-error 2335 vec 'remote-file-error
2336 "Timeout reached mounting %s using %s" host-port method) 2336 "Timeout reached mounting %s using %s" host-port method)
2337 (tramp-error 2337 (tramp-error
2338 vec 'file-error 2338 vec 'remote-file-error
2339 "Timeout reached mounting %s@%s using %s" 2339 "Timeout reached mounting %s@%s using %s"
2340 user-domain host-port method))) 2340 user-domain host-port method)))
2341 (while (not (tramp-get-file-property vec "/" "fuse-mountpoint")) 2341 (while (not (tramp-get-file-property vec "/" "fuse-mountpoint"))
@@ -2345,7 +2345,7 @@ connection if a previous connection has died for some reason."
2345 ;; is marked with the fuse-mountpoint "/". We shall react. 2345 ;; is marked with the fuse-mountpoint "/". We shall react.
2346 (when (string-equal 2346 (when (string-equal
2347 (tramp-get-file-property vec "/" "fuse-mountpoint" "") "/") 2347 (tramp-get-file-property vec "/" "fuse-mountpoint" "") "/")
2348 (tramp-error vec 'file-error "FUSE mount denied")) 2348 (tramp-error vec 'remote-file-error "FUSE mount denied"))
2349 2349
2350 ;; Save the password. 2350 ;; Save the password.
2351 (ignore-errors 2351 (ignore-errors
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 6b0daeba2ac..cd5c3f46f54 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -381,53 +381,53 @@ connection if a previous connection has died for some reason."
381 381
382 (with-tramp-debug-message vec "Opening connection" 382 (with-tramp-debug-message vec "Opening connection"
383 (let ((host (tramp-file-name-host vec))) 383 (let ((host (tramp-file-name-host vec)))
384 (when (rassoc `(,host) (tramp-rclone-parse-device-names nil)) 384 (when (or (tramp-string-empty-or-nil-p host)
385 (if (tramp-string-empty-or-nil-p host) 385 (not (rassoc `(,host) (tramp-rclone-parse-device-names nil))))
386 (tramp-error vec 'file-error "Storage %s not connected" host)) 386 (tramp-error vec 'remote-file-error "Storage %s not connected" host))
387 ;; We need a process bound to the connection buffer. 387
388 ;; Therefore, we create a dummy process. Maybe there is a 388 ;; We need a process bound to the connection buffer. Therefore,
389 ;; better solution? 389 ;; we create a dummy process. Maybe there is a better solution?
390 (unless (get-buffer-process (tramp-get-connection-buffer vec)) 390 (unless (get-buffer-process (tramp-get-connection-buffer vec))
391 (let ((p (make-network-process 391 (let ((p (make-network-process
392 :name (tramp-get-connection-name vec) 392 :name (tramp-get-connection-name vec)
393 :buffer (tramp-get-connection-buffer vec) 393 :buffer (tramp-get-connection-buffer vec)
394 :server t :host 'local :service t :noquery t))) 394 :server t :host 'local :service t :noquery t)))
395 (tramp-post-process-creation p vec) 395 (tramp-post-process-creation p vec)
396 396
397 ;; Set connection-local variables. 397 ;; Set connection-local variables.
398 (tramp-set-connection-local-variables vec))) 398 (tramp-set-connection-local-variables vec)))
399 399
400 ;; Create directory. 400 ;; Create directory.
401 (unless (file-directory-p (tramp-fuse-mount-point vec)) 401 (unless (file-directory-p (tramp-fuse-mount-point vec))
402 (make-directory (tramp-fuse-mount-point vec) 'parents)) 402 (make-directory (tramp-fuse-mount-point vec) 'parents))
403 403
404 ;; Mount. This command does not return, so we use 0 as 404 ;; Mount. This command does not return, so we use 0 as
405 ;; DESTINATION of `tramp-call-process'. 405 ;; DESTINATION of `tramp-call-process'.
406 (unless (tramp-fuse-mounted-p vec) 406 (unless (tramp-fuse-mounted-p vec)
407 (apply 407 (apply
408 #'tramp-call-process 408 #'tramp-call-process
409 vec tramp-rclone-program nil 0 nil 409 vec tramp-rclone-program nil 0 nil
410 "mount" (tramp-fuse-mount-spec vec) 410 "mount" (tramp-fuse-mount-spec vec)
411 (tramp-fuse-mount-point vec) 411 (tramp-fuse-mount-point vec)
412 (tramp-get-method-parameter vec 'tramp-mount-args)) 412 (tramp-get-method-parameter vec 'tramp-mount-args))
413 (while (not (file-exists-p (tramp-make-tramp-file-name vec 'noloc))) 413 (while (not (file-exists-p (tramp-make-tramp-file-name vec 'noloc)))
414 (tramp-cleanup-connection vec 'keep-debug 'keep-password)) 414 (tramp-cleanup-connection vec 'keep-debug 'keep-password))
415 (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec))) 415 (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec)))
416 416
417 ;; Mark it as connected. 417 ;; Mark it as connected.
418 (tramp-set-connection-property 418 (tramp-set-connection-property
419 (tramp-get-connection-process vec) "connected" t))) 419 (tramp-get-connection-process vec) "connected" t)))
420 420
421 ;; In `tramp-check-cached-permissions', the connection properties 421 ;; In `tramp-check-cached-permissions', the connection properties
422 ;; "{uid,gid}-{integer,string}" are used. We set them to proper values. 422 ;; "{uid,gid}-{integer,string}" are used. We set them to proper values.
423 (with-tramp-connection-property 423 (with-tramp-connection-property
424 vec "uid-integer" (tramp-get-local-uid 'integer)) 424 vec "uid-integer" (tramp-get-local-uid 'integer))
425 (with-tramp-connection-property 425 (with-tramp-connection-property
426 vec "gid-integer" (tramp-get-local-gid 'integer)) 426 vec "gid-integer" (tramp-get-local-gid 'integer))
427 (with-tramp-connection-property 427 (with-tramp-connection-property
428 vec "uid-string" (tramp-get-local-uid 'string)) 428 vec "uid-string" (tramp-get-local-uid 'string))
429 (with-tramp-connection-property 429 (with-tramp-connection-property
430 vec "gid-string" (tramp-get-local-gid 'string)))) 430 vec "gid-string" (tramp-get-local-gid 'string)))
431 431
432(defun tramp-rclone-send-command (vec &rest args) 432(defun tramp-rclone-send-command (vec &rest args)
433 "Send a command to connection VEC. 433 "Send a command to connection VEC.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 97b72ba00ad..13e886b2c13 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1969,7 +1969,7 @@ ID-FORMAT valid values are `string' and `integer'."
1969 (tramp-send-command-and-read 1969 (tramp-send-command-and-read
1970 vec (format "tramp_perl_directory_files_and_attributes %s" 1970 vec (format "tramp_perl_directory_files_and_attributes %s"
1971 (tramp-shell-quote-argument localname))))) 1971 (tramp-shell-quote-argument localname)))))
1972 (when (stringp object) (tramp-error vec 'file-error object)) 1972 (when (stringp object) (tramp-error vec 'remote-file-error object))
1973 object)) 1973 object))
1974 1974
1975;; FIXME: Fix function to work with count parameter. 1975;; FIXME: Fix function to work with count parameter.
@@ -2378,7 +2378,7 @@ the uid and gid from FILENAME."
2378 ((eq op 'copy) "cp -f") 2378 ((eq op 'copy) "cp -f")
2379 ((eq op 'rename) "mv -f") 2379 ((eq op 'rename) "mv -f")
2380 (t (tramp-error 2380 (t (tramp-error
2381 v 'file-error 2381 v 'remote-file-error
2382 "Unknown operation `%s', must be `copy' or `rename'" 2382 "Unknown operation `%s', must be `copy' or `rename'"
2383 op)))) 2383 op))))
2384 (localname1 (tramp-file-local-name filename)) 2384 (localname1 (tramp-file-local-name filename))
@@ -2608,7 +2608,7 @@ The method used must be an out-of-band method."
2608 ;; Check for local copy program. 2608 ;; Check for local copy program.
2609 (unless (executable-find copy-program) 2609 (unless (executable-find copy-program)
2610 (tramp-error 2610 (tramp-error
2611 v 'file-error "Cannot find local copy program: %s" copy-program)) 2611 v 'remote-file-error "Cannot find local copy program: %s" copy-program))
2612 2612
2613 ;; Install listener on the remote side. The prompt must be 2613 ;; Install listener on the remote side. The prompt must be
2614 ;; consumed later on, when the process does not listen anymore. 2614 ;; consumed later on, when the process does not listen anymore.
@@ -2618,7 +2618,7 @@ The method used must be an out-of-band method."
2618 (tramp-find-executable 2618 (tramp-find-executable
2619 v remote-copy-program (tramp-get-remote-path v))) 2619 v remote-copy-program (tramp-get-remote-path v)))
2620 (tramp-error 2620 (tramp-error
2621 v 'file-error 2621 v 'remote-file-error
2622 "Cannot find remote listener: %s" remote-copy-program)) 2622 "Cannot find remote listener: %s" remote-copy-program))
2623 (setq remote-copy-program 2623 (setq remote-copy-program
2624 (string-join 2624 (string-join
@@ -2629,7 +2629,7 @@ The method used must be an out-of-band method."
2629 (tramp-send-command v remote-copy-program) 2629 (tramp-send-command v remote-copy-program)
2630 (with-timeout 2630 (with-timeout
2631 (60 (tramp-error 2631 (60 (tramp-error
2632 v 'file-error 2632 v 'remote-file-error
2633 "Listener process not running on remote host: `%s'" 2633 "Listener process not running on remote host: `%s'"
2634 remote-copy-program)) 2634 remote-copy-program))
2635 (tramp-send-command v (format "netstat -l | grep -q :%s" listener)) 2635 (tramp-send-command v (format "netstat -l | grep -q :%s" listener))
@@ -3468,7 +3468,8 @@ will be used."
3468 3468
3469 ;; Oops, I don't know what to do. 3469 ;; Oops, I don't know what to do.
3470 (t (tramp-error 3470 (t (tramp-error
3471 v 'file-error "Wrong method specification for `%s'" method))) 3471 v 'remote-file-error
3472 "Wrong method specification for `%s'" method)))
3472 3473
3473 ;; Error handling. 3474 ;; Error handling.
3474 ((error quit) 3475 ((error quit)
@@ -3663,7 +3664,7 @@ will be used."
3663 ;; That's not expected. 3664 ;; That's not expected.
3664 (t 3665 (t
3665 (tramp-error 3666 (tramp-error
3666 v 'file-error 3667 v 'remote-file-error
3667 (concat "Method `%s' should specify both encoding and " 3668 (concat "Method `%s' should specify both encoding and "
3668 "decoding command or an scp program") 3669 "decoding command or an scp program")
3669 method))))))))) 3670 method)))))))))
@@ -3689,7 +3690,7 @@ are \"file-exists-p\", \"file-readable-p\", \"file-directory-p\" and
3689 tramp-end-of-heredoc 3690 tramp-end-of-heredoc
3690 (mapconcat #'tramp-shell-quote-argument files "\n") 3691 (mapconcat #'tramp-shell-quote-argument files "\n")
3691 tramp-end-of-heredoc)) 3692 tramp-end-of-heredoc))
3692 (tramp-error vec 'file-error "%s" (tramp-get-buffer-string))) 3693 (tramp-error vec 'remote-file-error "%s" (tramp-get-buffer-string)))
3693 ;; Read the expression. 3694 ;; Read the expression.
3694 (goto-char (point-min)) 3695 (goto-char (point-min))
3695 (read (current-buffer)))) 3696 (read (current-buffer))))
@@ -4165,7 +4166,7 @@ Only send the definition if it has not already been done."
4165 ;; Expand format specifiers. 4166 ;; Expand format specifiers.
4166 (unless (setq script (tramp-expand-script vec script)) 4167 (unless (setq script (tramp-expand-script vec script))
4167 (tramp-error 4168 (tramp-error
4168 vec 'file-error 4169 vec 'remote-file-error
4169 (format "Script %s is not applicable on remote host" name))) 4170 (format "Script %s is not applicable on remote host" name)))
4170 ;; Send it. 4171 ;; Send it.
4171 (tramp-barf-unless-okay 4172 (tramp-barf-unless-okay
@@ -4325,13 +4326,15 @@ file exists and nonzero exit status otherwise."
4325 ;; We cannot use `tramp-get-ls-command', this results in an infloop. 4326 ;; We cannot use `tramp-get-ls-command', this results in an infloop.
4326 ;; (Bug#65321) 4327 ;; (Bug#65321)
4327 (ignore-errors 4328 (ignore-errors
4328 (and (setq result (format "ls -d >%s" (tramp-get-remote-null-device vec))) 4329 (and (setq
4330 result
4331 (format "ls -d >%s" (tramp-get-remote-null-device vec)))
4329 (tramp-send-command-and-check 4332 (tramp-send-command-and-check
4330 vec (format "%s %s" result existing)) 4333 vec (format "%s %s" result existing))
4331 (not (tramp-send-command-and-check 4334 (not (tramp-send-command-and-check
4332 vec (format "%s %s" result nonexistent)))))) 4335 vec (format "%s %s" result nonexistent))))))
4333 (tramp-error 4336 (tramp-error
4334 vec 'file-error "Couldn't find command to check if file exists")) 4337 vec 'remote-file-error "Couldn't find command to check if file exists"))
4335 (tramp-set-file-property vec existing "file-exists-p" t) 4338 (tramp-set-file-property vec existing "file-exists-p" t)
4336 result)) 4339 result))
4337 4340
@@ -4484,7 +4487,8 @@ seconds. If not, it produces an error message with the given ERROR-ARGS."
4484 (error 4487 (error
4485 (delete-process proc) 4488 (delete-process proc)
4486 (apply #'tramp-error-with-buffer 4489 (apply #'tramp-error-with-buffer
4487 (tramp-get-connection-buffer vec) vec 'file-error error-args))))) 4490 (tramp-get-connection-buffer vec) vec
4491 'remote-file-error error-args)))))
4488 4492
4489(defvar tramp-config-check nil 4493(defvar tramp-config-check nil
4490 "A function to be called with one argument, VEC. 4494 "A function to be called with one argument, VEC.
@@ -5293,8 +5297,8 @@ connection if a previous connection has died for some reason."
5293 (unless (and (process-live-p p) 5297 (unless (and (process-live-p p)
5294 (tramp-wait-for-output p 10)) 5298 (tramp-wait-for-output p 10))
5295 ;; The error will be caught locally. 5299 ;; The error will be caught locally.
5296 (tramp-error vec 'file-error "Awake did fail"))) 5300 (tramp-error vec 'remote-file-error "Awake did fail")))
5297 (file-error 5301 (remote-file-error
5298 (tramp-cleanup-connection vec t) 5302 (tramp-cleanup-connection vec t)
5299 (setq p nil))) 5303 (setq p nil)))
5300 5304
@@ -5314,7 +5318,8 @@ connection if a previous connection has died for some reason."
5314 (setenv "HISTFILESIZE" "0") 5318 (setenv "HISTFILESIZE" "0")
5315 (setenv "HISTSIZE" "0")))) 5319 (setenv "HISTSIZE" "0"))))
5316 (unless (stringp tramp-encoding-shell) 5320 (unless (stringp tramp-encoding-shell)
5317 (tramp-error vec 'file-error "`tramp-encoding-shell' not set")) 5321 (tramp-error
5322 vec 'remote-file-error "`tramp-encoding-shell' not set"))
5318 (let* ((current-host tramp-system-name) 5323 (let* ((current-host tramp-system-name)
5319 (target-alist (tramp-compute-multi-hops vec)) 5324 (target-alist (tramp-compute-multi-hops vec))
5320 (previous-hop tramp-null-hop) 5325 (previous-hop tramp-null-hop)
@@ -5520,7 +5525,8 @@ function waits for output unless NOOUTPUT is set."
5520 "Wait for output from remote command." 5525 "Wait for output from remote command."
5521 (unless (buffer-live-p (process-buffer proc)) 5526 (unless (buffer-live-p (process-buffer proc))
5522 (delete-process proc) 5527 (delete-process proc)
5523 (tramp-error proc 'file-error "Process `%s' not available, try again" proc)) 5528 (tramp-error
5529 proc 'remote-file-error "Process `%s' not available, try again" proc))
5524 (with-current-buffer (process-buffer proc) 5530 (with-current-buffer (process-buffer proc)
5525 (let* (;; Initially, `tramp-end-of-output' is "#$ ". There might 5531 (let* (;; Initially, `tramp-end-of-output' is "#$ ". There might
5526 ;; be leading ANSI control escape sequences, which must be 5532 ;; be leading ANSI control escape sequences, which must be
@@ -5551,11 +5557,11 @@ function waits for output unless NOOUTPUT is set."
5551 (delete-region (point) (point-max)))) 5557 (delete-region (point) (point-max))))
5552 (if timeout 5558 (if timeout
5553 (tramp-error 5559 (tramp-error
5554 proc 'file-error 5560 proc 'remote-file-error
5555 "[[Remote prompt `%s' not found in %d secs]]" 5561 "[[Remote prompt `%s' not found in %d secs]]"
5556 tramp-end-of-output timeout) 5562 tramp-end-of-output timeout)
5557 (tramp-error 5563 (tramp-error
5558 proc 'file-error 5564 proc 'remote-file-error
5559 "[[Remote prompt `%s' not found]]" tramp-end-of-output))) 5565 "[[Remote prompt `%s' not found]]" tramp-end-of-output)))
5560 ;; Return value is whether end-of-output sentinel was found. 5566 ;; Return value is whether end-of-output sentinel was found.
5561 found))) 5567 found)))
@@ -5594,7 +5600,7 @@ the exit status."
5594 (with-current-buffer (tramp-get-connection-buffer vec) 5600 (with-current-buffer (tramp-get-connection-buffer vec)
5595 (unless (tramp-search-regexp (rx "tramp_exit_status " (+ digit))) 5601 (unless (tramp-search-regexp (rx "tramp_exit_status " (+ digit)))
5596 (tramp-error 5602 (tramp-error
5597 vec 'file-error "Couldn't find exit status of `%s'" command)) 5603 vec 'remote-file-error "Couldn't find exit status of `%s'" command))
5598 (skip-chars-forward "^ ") 5604 (skip-chars-forward "^ ")
5599 (prog1 5605 (prog1
5600 (if exit-status 5606 (if exit-status
@@ -5608,7 +5614,7 @@ the exit status."
5608Similar to `tramp-send-command-and-check' but accepts two more arguments 5614Similar to `tramp-send-command-and-check' but accepts two more arguments
5609FMT and ARGS which are passed to `error'." 5615FMT and ARGS which are passed to `error'."
5610 (or (tramp-send-command-and-check vec command) 5616 (or (tramp-send-command-and-check vec command)
5611 (apply #'tramp-error vec 'file-error fmt args))) 5617 (apply #'tramp-error vec 'remote-file-error fmt args)))
5612 5618
5613(defun tramp-send-command-and-read (vec command &optional noerror marker) 5619(defun tramp-send-command-and-read (vec command &optional noerror marker)
5614 "Run COMMAND and return the output, which must be a Lisp expression. 5620 "Run COMMAND and return the output, which must be a Lisp expression.
@@ -5627,7 +5633,7 @@ raises an error."
5627 (search-forward-regexp marker) 5633 (search-forward-regexp marker)
5628 (error (unless noerror 5634 (error (unless noerror
5629 (tramp-error 5635 (tramp-error
5630 vec 'file-error 5636 vec 'remote-file-error
5631 "`%s' does not return the marker `%s': `%s'" 5637 "`%s' does not return the marker `%s': `%s'"
5632 command marker (buffer-string)))))) 5638 command marker (buffer-string))))))
5633 ;; Read the expression. 5639 ;; Read the expression.
@@ -5641,7 +5647,7 @@ raises an error."
5641 (error nil))) 5647 (error nil)))
5642 (error (unless noerror 5648 (error (unless noerror
5643 (tramp-error 5649 (tramp-error
5644 vec 'file-error 5650 vec 'remote-file-error
5645 "`%s' does not return a valid Lisp expression: `%s'" 5651 "`%s' does not return a valid Lisp expression: `%s'"
5646 command (buffer-string)))))))) 5652 command (buffer-string))))))))
5647 5653
@@ -5854,7 +5860,8 @@ Nonexistent directories are removed from spec."
5854 (setq result (concat result " --color=never"))) 5860 (setq result (concat result " --color=never")))
5855 (throw 'ls-found result)) 5861 (throw 'ls-found result))
5856 (setq dl (cdr dl)))))) 5862 (setq dl (cdr dl))))))
5857 (tramp-error vec 'file-error "Couldn't find a proper `ls' command")))) 5863 (tramp-error
5864 vec 'remote-file-error "Couldn't find a proper `ls' command"))))
5858 5865
5859(defun tramp-get-ls-command-with (vec option) 5866(defun tramp-get-ls-command-with (vec option)
5860 "Return OPTION, if the remote `ls' command supports the OPTION option." 5867 "Return OPTION, if the remote `ls' command supports the OPTION option."
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index b87eee0fcce..554aa354c00 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -821,7 +821,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
821 (setq filename (directory-file-name (expand-file-name filename))) 821 (setq filename (directory-file-name (expand-file-name filename)))
822 (with-parsed-tramp-file-name filename nil 822 (with-parsed-tramp-file-name filename nil
823 (tramp-convert-file-attributes v localname id-format 823 (tramp-convert-file-attributes v localname id-format
824 (ignore-errors 824 (condition-case err
825 (if (tramp-smb-get-stat-capability v) 825 (if (tramp-smb-get-stat-capability v)
826 (tramp-smb-do-file-attributes-with-stat v) 826 (tramp-smb-do-file-attributes-with-stat v)
827 ;; Reading just the filename entry via "dir localname" is 827 ;; Reading just the filename entry via "dir localname" is
@@ -851,7 +851,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
851 (nth 1 entry) ;8 mode 851 (nth 1 entry) ;8 mode
852 nil ;9 gid weird 852 nil ;9 gid weird
853 inode ;10 inode number 853 inode ;10 inode number
854 device)))))))) ;11 file system number 854 device)))) ;11 file system number
855 (remote-file-error (signal (car err) (cdr err)))
856 (error)))))
855 857
856(defun tramp-smb-do-file-attributes-with-stat (vec) 858(defun tramp-smb-do-file-attributes-with-stat (vec)
857 "Implement `file-attributes' for Tramp files using `stat' command." 859 "Implement `file-attributes' for Tramp files using `stat' command."
@@ -1382,7 +1384,7 @@ will be used."
1382 "Like `make-symbolic-link' for Tramp files." 1384 "Like `make-symbolic-link' for Tramp files."
1383 (let ((v (tramp-dissect-file-name (expand-file-name linkname)))) 1385 (let ((v (tramp-dissect-file-name (expand-file-name linkname))))
1384 (unless (tramp-smb-get-cifs-capabilities v) 1386 (unless (tramp-smb-get-cifs-capabilities v)
1385 (tramp-error v 'file-error "make-symbolic-link not supported"))) 1387 (tramp-error v 'remote-file-error "make-symbolic-link not supported")))
1386 1388
1387 (tramp-skeleton-make-symbolic-link target linkname ok-if-already-exists 1389 (tramp-skeleton-make-symbolic-link target linkname ok-if-already-exists
1388 (unless (tramp-smb-send-command 1390 (unless (tramp-smb-send-command
@@ -1571,8 +1573,7 @@ will be used."
1571 (tramp-search-regexp (rx "tramp_exit_status " (+ digit))) 1573 (tramp-search-regexp (rx "tramp_exit_status " (+ digit)))
1572 (tramp-error 1574 (tramp-error
1573 v 'file-error 1575 v 'file-error
1574 "Couldn't find exit status of `%s'" 1576 "Couldn't find exit status of `%s'" tramp-smb-acl-program))
1575 tramp-smb-acl-program))
1576 (skip-chars-forward "^ ") 1577 (skip-chars-forward "^ ")
1577 (when (zerop (read (current-buffer))) 1578 (when (zerop (read (current-buffer)))
1578 ;; Success. 1579 ;; Success.
@@ -1705,7 +1706,7 @@ If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
1705 (when (string-match-p (rx blank eol) localname) 1706 (when (string-match-p (rx blank eol) localname)
1706 (tramp-error 1707 (tramp-error
1707 vec 'file-error 1708 vec 'file-error
1708 "Invalid file name %s" (tramp-make-tramp-file-name vec localname))) 1709 "Invalid file name `%s'" (tramp-make-tramp-file-name vec localname)))
1709 1710
1710 localname))) 1711 localname)))
1711 1712
@@ -1988,7 +1989,7 @@ If ARGUMENT is non-nil, use it as argument for
1988 (unless tramp-smb-version 1989 (unless tramp-smb-version
1989 (unless (executable-find tramp-smb-program) 1990 (unless (executable-find tramp-smb-program)
1990 (tramp-error 1991 (tramp-error
1991 vec 'file-error 1992 vec 'remote-file-error
1992 "Cannot find command %s in %s" tramp-smb-program exec-path)) 1993 "Cannot find command %s in %s" tramp-smb-program exec-path))
1993 (setq tramp-smb-version (shell-command-to-string command)) 1994 (setq tramp-smb-version (shell-command-to-string command))
1994 (tramp-message vec 6 command) 1995 (tramp-message vec 6 command)
@@ -2165,11 +2166,12 @@ Removes smb prompt. Returns nil if an error message has appeared."
2165 ;; Check for program. 2166 ;; Check for program.
2166 (unless (executable-find tramp-smb-winexe-program) 2167 (unless (executable-find tramp-smb-winexe-program)
2167 (tramp-error 2168 (tramp-error
2168 vec 'file-error "Cannot find program: %s" tramp-smb-winexe-program)) 2169 vec 'remote-file-error "Cannot find program: %s" tramp-smb-winexe-program))
2169 2170
2170 ;; winexe does not supports ports. 2171 ;; winexe does not supports ports.
2171 (when (tramp-file-name-port vec) 2172 (when (tramp-file-name-port vec)
2172 (tramp-error vec 'file-error "Port not supported for remote processes")) 2173 (tramp-error
2174 vec 'remote-file-error "Port not supported for remote processes"))
2173 2175
2174 ;; Check share. 2176 ;; Check share.
2175 (unless (tramp-smb-get-share vec) 2177 (unless (tramp-smb-get-share vec)
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 338d128cc4e..2cb5b5b1ed1 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -359,7 +359,7 @@ connection if a previous connection has died for some reason."
359 vec 'tramp-mount-args nil 359 vec 'tramp-mount-args nil
360 ?p (or (tramp-file-name-port vec) "")))))) 360 ?p (or (tramp-file-name-port vec) ""))))))
361 (tramp-error 361 (tramp-error
362 vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec))) 362 vec 'remote-file-error "Error mounting %s" (tramp-fuse-mount-spec vec)))
363 363
364 ;; Mark it as connected. 364 ;; Mark it as connected.
365 (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec)) 365 (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec))
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index d3bb8b8478e..9511c899b2b 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -52,6 +52,10 @@
52 `(,(rx bos (literal tramp-sudoedit-method) eos) 52 `(,(rx bos (literal tramp-sudoedit-method) eos)
53 nil ,tramp-root-id-string)) 53 nil ,tramp-root-id-string))
54 54
55 (add-to-list 'tramp-default-host-alist
56 `(,(rx bos (literal tramp-sudoedit-method) eos)
57 nil ,(system-name)))
58
55 (tramp-set-completion-function 59 (tramp-set-completion-function
56 tramp-sudoedit-method tramp-completion-function-alist-su)) 60 tramp-sudoedit-method tramp-completion-function-alist-su))
57 61
@@ -742,6 +746,10 @@ connection if a previous connection has died for some reason."
742 (unless (tramp-connectable-p vec) 746 (unless (tramp-connectable-p vec)
743 (throw 'non-essential 'non-essential)) 747 (throw 'non-essential 'non-essential))
744 748
749 (unless (string-match-p tramp-local-host-regexp (tramp-file-name-host vec))
750 (tramp-error
751 vec 'remote-file-error "%s is not a local host" (tramp-file-name-host vec)))
752
745 (with-tramp-debug-message vec "Opening connection" 753 (with-tramp-debug-message vec "Opening connection"
746 ;; We need a process bound to the connection buffer. Therefore, 754 ;; We need a process bound to the connection buffer. Therefore,
747 ;; we create a dummy process. Maybe there is a better solution? 755 ;; we create a dummy process. Maybe there is a better solution?
@@ -775,7 +783,6 @@ in case of error, t otherwise."
775 (append 783 (append
776 (tramp-expand-args 784 (tramp-expand-args
777 vec 'tramp-sudo-login nil 785 vec 'tramp-sudo-login nil
778 ?h (or (tramp-file-name-host vec) "")
779 ?u (or (tramp-file-name-user vec) "")) 786 ?u (or (tramp-file-name-user vec) ""))
780 (flatten-tree args)))) 787 (flatten-tree args))))
781 ;; We suppress the messages `Waiting for prompts from remote shell'. 788 ;; We suppress the messages `Waiting for prompts from remote shell'.
@@ -817,7 +824,7 @@ In case there is no valid Lisp expression, it raises an error."
817 (when (search-forward-regexp (rx (not blank)) (line-end-position) t) 824 (when (search-forward-regexp (rx (not blank)) (line-end-position) t)
818 (error nil))) 825 (error nil)))
819 (error (tramp-error 826 (error (tramp-error
820 vec 'file-error 827 vec 'remote-file-error
821 "`%s' does not return a valid Lisp expression: `%s'" 828 "`%s' does not return a valid Lisp expression: `%s'"
822 (car args) (buffer-string))))))) 829 (car args) (buffer-string)))))))
823 830
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index f57b572532a..5281d8e4db5 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3931,7 +3931,7 @@ BODY is the backend specific code."
3931 ;; The implementation is not complete yet. 3931 ;; The implementation is not complete yet.
3932 (when (and (numberp ,destination) (zerop ,destination)) 3932 (when (and (numberp ,destination) (zerop ,destination))
3933 (tramp-error 3933 (tramp-error
3934 v 'file-error "Implementation does not handle immediate return")) 3934 v 'remote-file-error "Implementation does not handle immediate return"))
3935 3935
3936 (let (command input tmpinput stderr tmpstderr outbuf ret) 3936 (let (command input tmpinput stderr tmpstderr outbuf ret)
3937 ;; Determine input. 3937 ;; Determine input.
@@ -5239,6 +5239,9 @@ Do not set it manually, it is used buffer-local in `tramp-get-lock-pid'.")
5239 ?u (or (tramp-file-name-user (car target-alist)) "") 5239 ?u (or (tramp-file-name-user (car target-alist)) "")
5240 ?h (or (tramp-file-name-host (car target-alist)) "")))) 5240 ?h (or (tramp-file-name-host (car target-alist)) ""))))
5241 (with-parsed-tramp-file-name proxy l 5241 (with-parsed-tramp-file-name proxy l
5242 (when (member l target-alist)
5243 (tramp-user-error
5244 vec "Cycle proxy definition `%s' in multi-hop" proxy))
5242 ;; Add the hop. 5245 ;; Add the hop.
5243 (push l target-alist) 5246 (push l target-alist)
5244 ;; Start next search. 5247 ;; Start next search.
@@ -5505,7 +5508,7 @@ processes."
5505This is the fallback implementation for backends which do not 5508This is the fallback implementation for backends which do not
5506support symbolic links." 5509support symbolic links."
5507 (tramp-error 5510 (tramp-error
5508 (tramp-dissect-file-name (expand-file-name linkname)) 'file-error 5511 (tramp-dissect-file-name (expand-file-name linkname)) 'remote-file-error
5509 "make-symbolic-link not supported")) 5512 "make-symbolic-link not supported"))
5510 5513
5511(defun tramp-handle-memory-info () 5514(defun tramp-handle-memory-info ()
@@ -6255,7 +6258,7 @@ performed successfully. Any other value means an error."
6255 (tramp-clear-passwd vec) 6258 (tramp-clear-passwd vec)
6256 (delete-process proc) 6259 (delete-process proc)
6257 (tramp-error-with-buffer 6260 (tramp-error-with-buffer
6258 (tramp-get-connection-buffer vec) vec 'file-error 6261 (tramp-get-connection-buffer vec) vec 'remote-file-error
6259 (cond 6262 (cond
6260 ((eq exit 'permission-denied) "Permission denied") 6263 ((eq exit 'permission-denied) "Permission denied")
6261 ((eq exit 'out-of-band-failed) 6264 ((eq exit 'out-of-band-failed)
@@ -6402,7 +6405,7 @@ nil."
6402 (tramp-accept-process-output proc) 6405 (tramp-accept-process-output proc)
6403 (unless (process-live-p proc) 6406 (unless (process-live-p proc)
6404 (tramp-error-with-buffer 6407 (tramp-error-with-buffer
6405 nil proc 'file-error "Process has died")) 6408 nil proc 'remote-file-error "Process has died"))
6406 (setq found (tramp-check-for-regexp proc regexp)))) 6409 (setq found (tramp-check-for-regexp proc regexp))))
6407 ;; The process could have timed out, for example due to session 6410 ;; The process could have timed out, for example due to session
6408 ;; timeout of sudo. The process buffer does not exist any longer then. 6411 ;; timeout of sudo. The process buffer does not exist any longer then.
@@ -6412,9 +6415,10 @@ nil."
6412 (unless found 6415 (unless found
6413 (if timeout 6416 (if timeout
6414 (tramp-error 6417 (tramp-error
6415 proc 'file-error "[[Regexp `%s' not found in %d secs]]" 6418 proc 'remote-file-error "[[Regexp `%s' not found in %d secs]]"
6416 regexp timeout) 6419 regexp timeout)
6417 (tramp-error proc 'file-error "[[Regexp `%s' not found]]" regexp))) 6420 (tramp-error
6421 proc 'remote-file-error "[[Regexp `%s' not found]]" regexp)))
6418 found)) 6422 found))
6419 6423
6420;; It seems that Tru64 Unix does not like it if long strings are sent 6424;; It seems that Tru64 Unix does not like it if long strings are sent
@@ -6431,7 +6435,8 @@ the remote host use line-endings as defined in the variable
6431 (chunksize (tramp-get-connection-property p "chunksize"))) 6435 (chunksize (tramp-get-connection-property p "chunksize")))
6432 (unless p 6436 (unless p
6433 (tramp-error 6437 (tramp-error
6434 vec 'file-error "Can't send string to remote host -- not logged in")) 6438 vec 'remote-file-error
6439 "Can't send string to remote host -- not logged in"))
6435 (tramp-set-connection-property p "last-cmd-time" (current-time)) 6440 (tramp-set-connection-property p "last-cmd-time" (current-time))
6436 (tramp-message vec 10 "%s" string) 6441 (tramp-message vec 10 "%s" string)
6437 (with-current-buffer (tramp-get-connection-buffer vec) 6442 (with-current-buffer (tramp-get-connection-buffer vec)
diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el
index f3bfaac005c..79fbe38b299 100644
--- a/test/lisp/net/tramp-archive-tests.el
+++ b/test/lisp/net/tramp-archive-tests.el
@@ -757,7 +757,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
757 ;; `set-file-modes' is not implemented. 757 ;; `set-file-modes' is not implemented.
758 (should-error 758 (should-error
759 (set-file-modes tmp-name1 #o777) 759 (set-file-modes tmp-name1 #o777)
760 :type 'file-error) 760 :type 'remote-file-error)
761 (should (= (file-modes tmp-name1) #o400)) 761 (should (= (file-modes tmp-name1) #o400))
762 (should-not (file-executable-p tmp-name1)) 762 (should-not (file-executable-p tmp-name1))
763 (should-not (file-writable-p tmp-name1)) 763 (should-not (file-writable-p tmp-name1))
@@ -766,7 +766,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
766 ;; `set-file-modes' is not implemented. 766 ;; `set-file-modes' is not implemented.
767 (should-error 767 (should-error
768 (set-file-modes tmp-name2 #o777) 768 (set-file-modes tmp-name2 #o777)
769 :type 'file-error) 769 :type 'remote-file-error)
770 (should (= (file-modes tmp-name2) #o500)) 770 (should (= (file-modes tmp-name2) #o500))
771 (should (file-executable-p tmp-name2)) 771 (should (file-executable-p tmp-name2))
772 (should-not (file-writable-p tmp-name2))) 772 (should-not (file-writable-p tmp-name2)))
@@ -796,7 +796,7 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'."
796 ;; `make-symbolic-link' is not implemented. 796 ;; `make-symbolic-link' is not implemented.
797 (should-error 797 (should-error
798 (make-symbolic-link tmp-name1 tmp-name2) 798 (make-symbolic-link tmp-name1 tmp-name2)
799 :type 'file-error) 799 :type 'remote-file-error)
800 (should (file-symlink-p tmp-name2)) 800 (should (file-symlink-p tmp-name2))
801 (should (file-regular-p tmp-name2)) 801 (should (file-regular-p tmp-name2))
802 (should 802 (should
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index bbfe15d2f59..28d773ca616 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -71,6 +71,7 @@
71(declare-function edebug-mode "edebug") 71(declare-function edebug-mode "edebug")
72(declare-function project-mode-line-format "project") 72(declare-function project-mode-line-format "project")
73(declare-function tramp-check-remote-uname "tramp-sh") 73(declare-function tramp-check-remote-uname "tramp-sh")
74(declare-function tramp-file-name-with-sudo "tramp-cmds")
74(declare-function tramp-find-executable "tramp-sh") 75(declare-function tramp-find-executable "tramp-sh")
75(declare-function tramp-get-remote-chmod-h "tramp-sh") 76(declare-function tramp-get-remote-chmod-h "tramp-sh")
76(declare-function tramp-get-remote-path "tramp-sh") 77(declare-function tramp-get-remote-path "tramp-sh")
@@ -185,7 +186,7 @@ The temporary file is not created."
185 (declare (indent defun) (debug (body))) 186 (declare (indent defun) (debug (body)))
186 `(condition-case err 187 `(condition-case err
187 (progn ,@body) 188 (progn ,@body)
188 (file-error 189 (remote-file-error
189 (unless (string-match-p 190 (unless (string-match-p
190 (rx bol (| "make-symbolic-link not supported" 191 (rx bol (| "make-symbolic-link not supported"
191 (: "Making symbolic link" 192 (: "Making symbolic link"
@@ -2203,19 +2204,31 @@ being the result.")
2203 m)) 2204 m))
2204 :type 'user-error))))) 2205 :type 'user-error)))))
2205 2206
2206(ert-deftest tramp-test03-file-name-method-rules () 2207(ert-deftest tramp-test03-file-error ()
2207 "Check file name rules for some methods." 2208 "Check that Tramp signals an error in case of connection problems."
2208 (skip-unless (eq tramp-syntax 'default)) 2209 ;; Connect to a non-existing host.
2209 (skip-unless (tramp--test-enabled)) 2210 (let ((vec (copy-tramp-file-name tramp-test-vec))
2210 2211 ;; Don't poison it.
2211 ;; Multi hops are allowed for inline methods only. 2212 (tramp-default-proxies-alist tramp-default-proxies-alist)
2212 (let (non-essential) 2213 (tramp-show-ad-hoc-proxies t))
2213 (should-error 2214 (cl-letf* (((symbol-function #'read-string) #'ignore) ; Suppress password.
2214 (expand-file-name "/ssh:user1@host1|method:user2@host2:/path/to/file") 2215 ((tramp-file-name-host vec) "example.com.invalid"))
2215 :type 'user-error) 2216 (should-error
2216 (should-error 2217 (file-exists-p (tramp-make-tramp-file-name vec))
2217 (expand-file-name "/method:user1@host1|ssh:user2@host2:/path/to/file") 2218 ;; `user-error' is raised if the host shall be local.
2218 :type 'user-error))) 2219 ;; `remote-file-error' is raised if the host cannot be connected.
2220 :type (if (tramp--test-ange-ftp-p)
2221 'ftp-error '(user-error remote-file-error)))
2222 (should-error
2223 (file-exists-p (tramp-make-tramp-file-name vec))
2224 ;; `ftp-error' and `remote-file-error' are subcategories of
2225 ;; `file-error'. Let's check this as well.
2226 :type '(user-error file-error))
2227 ;; Check multi-hop.
2228 (should-error
2229 (file-exists-p
2230 (tramp-file-name-with-sudo (tramp-make-tramp-file-name vec)))
2231 :type '(user-error file-error)))))
2219 2232
2220(ert-deftest tramp-test04-substitute-in-file-name () 2233(ert-deftest tramp-test04-substitute-in-file-name ()
2221 "Check `substitute-in-file-name'." 2234 "Check `substitute-in-file-name'."
@@ -7637,11 +7650,12 @@ This requires restrictions of file name syntax."
7637 (unless (tramp--test-crypt-p) 7650 (unless (tramp--test-crypt-p)
7638 (or (tramp--test-adb-p) (tramp--test-sh-p) (tramp--test-sshfs-p) 7651 (or (tramp--test-adb-p) (tramp--test-sh-p) (tramp--test-sshfs-p)
7639 (and (tramp--test-smb-p) 7652 (and (tramp--test-smb-p)
7640 (file-writable-p 7653 (ignore-errors
7641 (file-name-concat 7654 (file-writable-p
7642 (file-remote-p ert-remote-temporary-file-directory) 7655 (file-name-concat
7643 ;; We check a directory on the "ADMIN$" share. 7656 (file-remote-p ert-remote-temporary-file-directory)
7644 "ADMIN$" "Boot")))))) 7657 ;; We check a directory on the "ADMIN$" share.
7658 "ADMIN$" "Boot")))))))
7645 7659
7646(defun tramp--test-supports-set-file-modes-p () 7660(defun tramp--test-supports-set-file-modes-p ()
7647 "Return whether the method under test supports setting file modes." 7661 "Return whether the method under test supports setting file modes."