[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-28 5946370: Check, whether an FUSE mount has been broken in Tramp
From: |
Michael Albinus |
Subject: |
emacs-28 5946370: Check, whether an FUSE mount has been broken in Tramp |
Date: |
Tue, 5 Oct 2021 05:27:55 -0400 (EDT) |
branch: emacs-28
commit 5946370cd1d6728f2edd071fa8befc88fd0bd7a7
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
Check, whether an FUSE mount has been broken in Tramp
* lisp/net/tramp-fuse.el (tramp-fuse-mount-timeout): New defconst.
(tramp-fuse-mounted-p): Use it. Check for a file property instead
of a connection property.
(tramp-fuse-unmount): Dito.
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
Do not trust existence of a process, whether the volume is mounted.
---
lisp/net/tramp-fuse.el | 25 ++++++++++++++++---------
lisp/net/tramp-sshfs.el | 50 ++++++++++++++++++++++++-------------------------
2 files changed, 41 insertions(+), 34 deletions(-)
diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el
index d2bac2d..c359082 100644
--- a/lisp/net/tramp-fuse.el
+++ b/lisp/net/tramp-fuse.el
@@ -156,19 +156,27 @@
(tramp-file-name-host-port vec))
tramp-compat-temporary-file-directory)))
+(defconst tramp-fuse-mount-timeout
+ (eval (car (get 'remote-file-name-inhibit-cache 'standard-value)) t)
+ "Time period to check whether the mount point still exists.
+It has the same meaning as `remote-file-name-inhibit-cache'.")
+
(defun tramp-fuse-mounted-p (vec)
"Check, whether fuse volume determined by VEC is mounted."
- (when (tramp-get-connection-process vec)
- ;; We cannot use `with-connection-property', because we don't want
- ;; to cache a nil result.
- (or (tramp-get-connection-property
- (tramp-get-connection-process vec) "mounted" nil)
+ ;; Remember the mount status by using a file property on "/",
+ ;; instead of using a connection property, because a file property
+ ;; has a timeout. Having a timeout lets us regularly recheck the
+ ;; mount status, as requested by `tramp-fuse-mount-timeout'. We
+ ;; cannot use `with-tramp-file-property', because we don't want to
+ ;; cache a nil result.
+ (let ((remote-file-name-inhibit-cache tramp-fuse-mount-timeout))
+ (or (tramp-get-file-property vec "/" "mounted" nil)
(let* ((default-directory tramp-compat-temporary-file-directory)
(command (format "mount -t fuse.%s" (tramp-file-name-method
vec)))
(mount (shell-command-to-string command)))
(tramp-message vec 6 "%s\n%s" command mount)
- (tramp-set-connection-property
- (tramp-get-connection-process vec) "mounted"
+ (tramp-set-file-property
+ vec "/" "mounted"
(when (string-match
(format
"^\\(%s\\)\\s-" (regexp-quote (tramp-fuse-mount-spec vec)))
@@ -191,8 +199,7 @@
(mount-point (tramp-fuse-mount-point vec))
(command (format "%s -u %s" (tramp-fuse-get-fusermount) mount-point)))
(tramp-message vec 6 "%s\n%s" command (shell-command-to-string command))
- (tramp-flush-connection-property
- (tramp-get-connection-process vec) "mounted")
+ (tramp-flush-file-property vec "/" "mounted")
(setq tramp-fuse-mount-points
(delete (tramp-file-name-unify vec) tramp-fuse-mount-points))
;; Give the caches a chance to expire.
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 2be0485..1bd4c5d 100644
--- a/lisp/net/tramp-sshfs.el
+++ b/lisp/net/tramp-sshfs.el
@@ -349,31 +349,31 @@ connection if a previous connection has died for some
reason."
(tramp-set-connection-property p "lock-pid" (truncate (time-to-seconds)))
;; Set connection-local variables.
- (tramp-set-connection-local-variables vec)
-
- ;; Create directory.
- (unless (file-directory-p (tramp-fuse-mount-point vec))
- (make-directory (tramp-fuse-mount-point vec) 'parents))
-
- (unless
- (or (tramp-fuse-mounted-p vec)
- (with-temp-buffer
- (zerop
- (apply
- #'tramp-call-process
- vec tramp-sshfs-program nil t nil
- (tramp-fuse-mount-spec vec)
- (tramp-fuse-mount-point vec)
- (tramp-expand-args
- vec 'tramp-mount-args
- ?p (or (tramp-file-name-port vec) "")))))
- (tramp-error
- vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec))))
-
- ;; Mark it as connected.
- (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec))
- (tramp-set-connection-property
- (tramp-get-connection-process vec) "connected" t)))
+ (tramp-set-connection-local-variables vec)))
+
+ ;; Create directory.
+ (unless (file-directory-p (tramp-fuse-mount-point vec))
+ (make-directory (tramp-fuse-mount-point vec) 'parents))
+
+ (unless
+ (or (tramp-fuse-mounted-p vec)
+ (with-temp-buffer
+ (zerop
+ (apply
+ #'tramp-call-process
+ vec tramp-sshfs-program nil t nil
+ (tramp-fuse-mount-spec vec)
+ (tramp-fuse-mount-point vec)
+ (tramp-expand-args
+ vec 'tramp-mount-args
+ ?p (or (tramp-file-name-port vec) ""))))))
+ (tramp-error
+ vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec)))
+
+ ;; Mark it as connected.
+ (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec))
+ (tramp-set-connection-property
+ (tramp-get-connection-process vec) "connected" t)
;; In `tramp-check-cached-permissions', the connection properties
;; "{uid,gid}-{integer,string}" are used. We set them to proper values.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-28 5946370: Check, whether an FUSE mount has been broken in Tramp,
Michael Albinus <=