aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2021-10-05 11:27:48 +0200
committerMichael Albinus2021-10-05 11:27:48 +0200
commit5946370cd1d6728f2edd071fa8befc88fd0bd7a7 (patch)
tree6ead6a95170efb5b89de245b63de1e502c18ee6e
parent90575a6c0c17e88671999867f0773fef5ea516a8 (diff)
downloademacs-5946370cd1d6728f2edd071fa8befc88fd0bd7a7.tar.gz
emacs-5946370cd1d6728f2edd071fa8befc88fd0bd7a7.zip
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.
-rw-r--r--lisp/net/tramp-fuse.el25
-rw-r--r--lisp/net/tramp-sshfs.el50
2 files changed, 41 insertions, 34 deletions
diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el
index d2bac2d0ee2..c359082dc1e 100644
--- a/lisp/net/tramp-fuse.el
+++ b/lisp/net/tramp-fuse.el
@@ -156,19 +156,27 @@
156 (tramp-file-name-host-port vec)) 156 (tramp-file-name-host-port vec))
157 tramp-compat-temporary-file-directory))) 157 tramp-compat-temporary-file-directory)))
158 158
159(defconst tramp-fuse-mount-timeout
160 (eval (car (get 'remote-file-name-inhibit-cache 'standard-value)) t)
161 "Time period to check whether the mount point still exists.
162It has the same meaning as `remote-file-name-inhibit-cache'.")
163
159(defun tramp-fuse-mounted-p (vec) 164(defun tramp-fuse-mounted-p (vec)
160 "Check, whether fuse volume determined by VEC is mounted." 165 "Check, whether fuse volume determined by VEC is mounted."
161 (when (tramp-get-connection-process vec) 166 ;; Remember the mount status by using a file property on "/",
162 ;; We cannot use `with-connection-property', because we don't want 167 ;; instead of using a connection property, because a file property
163 ;; to cache a nil result. 168 ;; has a timeout. Having a timeout lets us regularly recheck the
164 (or (tramp-get-connection-property 169 ;; mount status, as requested by `tramp-fuse-mount-timeout'. We
165 (tramp-get-connection-process vec) "mounted" nil) 170 ;; cannot use `with-tramp-file-property', because we don't want to
171 ;; cache a nil result.
172 (let ((remote-file-name-inhibit-cache tramp-fuse-mount-timeout))
173 (or (tramp-get-file-property vec "/" "mounted" nil)
166 (let* ((default-directory tramp-compat-temporary-file-directory) 174 (let* ((default-directory tramp-compat-temporary-file-directory)
167 (command (format "mount -t fuse.%s" (tramp-file-name-method vec))) 175 (command (format "mount -t fuse.%s" (tramp-file-name-method vec)))
168 (mount (shell-command-to-string command))) 176 (mount (shell-command-to-string command)))
169 (tramp-message vec 6 "%s\n%s" command mount) 177 (tramp-message vec 6 "%s\n%s" command mount)
170 (tramp-set-connection-property 178 (tramp-set-file-property
171 (tramp-get-connection-process vec) "mounted" 179 vec "/" "mounted"
172 (when (string-match 180 (when (string-match
173 (format 181 (format
174 "^\\(%s\\)\\s-" (regexp-quote (tramp-fuse-mount-spec vec))) 182 "^\\(%s\\)\\s-" (regexp-quote (tramp-fuse-mount-spec vec)))
@@ -191,8 +199,7 @@
191 (mount-point (tramp-fuse-mount-point vec)) 199 (mount-point (tramp-fuse-mount-point vec))
192 (command (format "%s -u %s" (tramp-fuse-get-fusermount) mount-point))) 200 (command (format "%s -u %s" (tramp-fuse-get-fusermount) mount-point)))
193 (tramp-message vec 6 "%s\n%s" command (shell-command-to-string command)) 201 (tramp-message vec 6 "%s\n%s" command (shell-command-to-string command))
194 (tramp-flush-connection-property 202 (tramp-flush-file-property vec "/" "mounted")
195 (tramp-get-connection-process vec) "mounted")
196 (setq tramp-fuse-mount-points 203 (setq tramp-fuse-mount-points
197 (delete (tramp-file-name-unify vec) tramp-fuse-mount-points)) 204 (delete (tramp-file-name-unify vec) tramp-fuse-mount-points))
198 ;; Give the caches a chance to expire. 205 ;; Give the caches a chance to expire.
diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el
index 2be0485fbf1..1bd4c5dc1c8 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."
349 (tramp-set-connection-property p "lock-pid" (truncate (time-to-seconds))) 349 (tramp-set-connection-property p "lock-pid" (truncate (time-to-seconds)))
350 350
351 ;; Set connection-local variables. 351 ;; Set connection-local variables.
352 (tramp-set-connection-local-variables vec) 352 (tramp-set-connection-local-variables vec)))
353 353
354 ;; Create directory. 354 ;; Create directory.
355 (unless (file-directory-p (tramp-fuse-mount-point vec)) 355 (unless (file-directory-p (tramp-fuse-mount-point vec))
356 (make-directory (tramp-fuse-mount-point vec) 'parents)) 356 (make-directory (tramp-fuse-mount-point vec) 'parents))
357 357
358 (unless 358 (unless
359 (or (tramp-fuse-mounted-p vec) 359 (or (tramp-fuse-mounted-p vec)
360 (with-temp-buffer 360 (with-temp-buffer
361 (zerop 361 (zerop
362 (apply 362 (apply
363 #'tramp-call-process 363 #'tramp-call-process
364 vec tramp-sshfs-program nil t nil 364 vec tramp-sshfs-program nil t nil
365 (tramp-fuse-mount-spec vec) 365 (tramp-fuse-mount-spec vec)
366 (tramp-fuse-mount-point vec) 366 (tramp-fuse-mount-point vec)
367 (tramp-expand-args 367 (tramp-expand-args
368 vec 'tramp-mount-args 368 vec 'tramp-mount-args
369 ?p (or (tramp-file-name-port vec) ""))))) 369 ?p (or (tramp-file-name-port vec) ""))))))
370 (tramp-error 370 (tramp-error
371 vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec)))) 371 vec 'file-error "Error mounting %s" (tramp-fuse-mount-spec vec)))
372 372
373 ;; Mark it as connected. 373 ;; Mark it as connected.
374 (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec)) 374 (add-to-list 'tramp-fuse-mount-points (tramp-file-name-unify vec))
375 (tramp-set-connection-property 375 (tramp-set-connection-property
376 (tramp-get-connection-process vec) "connected" t))) 376 (tramp-get-connection-process vec) "connected" t)
377 377
378 ;; In `tramp-check-cached-permissions', the connection properties 378 ;; In `tramp-check-cached-permissions', the connection properties
379 ;; "{uid,gid}-{integer,string}" are used. We set them to proper values. 379 ;; "{uid,gid}-{integer,string}" are used. We set them to proper values.