Commit 5961e4fa authored by Michael Albinus's avatar Michael Albinus
Browse files

Use POSIX "df" in Tramp, if available

* lisp/net/tramp-sh.el (tramp-get-remote-df):
Support also POSIX.1 "df".
(tramp-sh-handle-file-system-info): Adapt accordingly.
parent 67b1053d
Pipeline #579 passed with stage
in 50 minutes and 8 seconds
...@@ -3817,22 +3817,26 @@ file-notify events." ...@@ -3817,22 +3817,26 @@ file-notify events."
(tramp-message v 5 "file system info: %s" localname) (tramp-message v 5 "file system info: %s" localname)
(tramp-send-command (tramp-send-command
v (format v (format
"%s --block-size=1 --output=size,used,avail %s" "%s %s"
(tramp-get-remote-df v) (tramp-shell-quote-argument localname))) (tramp-get-remote-df v) (tramp-shell-quote-argument localname)))
(with-current-buffer (tramp-get-connection-buffer v) (with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min)) (goto-char (point-min))
(forward-line) (forward-line)
(when (looking-at (when (looking-at
(eval-when-compile (eval-when-compile
(concat "[[:space:]]*\\([[:digit:]]+\\)" (concat "\\(?:^/[^[:space:]]*[[:space:]]\\)?"
"[[:space:]]*\\([[:digit:]]+\\)"
"[[:space:]]+\\([[:digit:]]+\\)" "[[:space:]]+\\([[:digit:]]+\\)"
"[[:space:]]+\\([[:digit:]]+\\)"))) "[[:space:]]+\\([[:digit:]]+\\)")))
(list (string-to-number (match-string 1)) (mapcar
;; The second value is the used size. We need the (lambda (d)
;; free size. (* d (tramp-get-connection-property v "df-blocksize" 0)))
(- (string-to-number (match-string 1)) (list (string-to-number (match-string 1))
(string-to-number (match-string 2))) ;; The second value is the used size. We need the
(string-to-number (match-string 3))))))))) ;; free size.
(- (string-to-number (match-string 1))
(string-to-number (match-string 2)))
(string-to-number (match-string 3))))))))))
;;; Internal Functions: ;;; Internal Functions:
...@@ -5578,12 +5582,24 @@ This command is returned only if `delete-by-moving-to-trash' is non-nil." ...@@ -5578,12 +5582,24 @@ This command is returned only if `delete-by-moving-to-trash' is non-nil."
"Determine remote `df' command." "Determine remote `df' command."
(with-tramp-connection-property vec "df" (with-tramp-connection-property vec "df"
(tramp-message vec 5 "Finding a suitable `df' command") (tramp-message vec 5 "Finding a suitable `df' command")
(let ((result (tramp-find-executable vec "df" (tramp-get-remote-path vec)))) (let ((df (tramp-find-executable vec "df" (tramp-get-remote-path vec)))
(and result)
result (when df
(tramp-send-command-and-check (cond
vec (format "%s --block-size=1 --output=size,used,avail /" result)) ;; coreutils.
result)))) ((tramp-send-command-and-check
vec
(format
"%s /"
(setq result
(format "%s --block-size=1 --output=size,used,avail" df))))
(tramp-set-connection-property vec "df-blocksize" 1)
result)
;; POSIX.1
((tramp-send-command-and-check
vec (format "%s /" (setq result (format "%s -k" df))))
(tramp-set-connection-property vec "df-blocksize" 1024)
result))))))
(defun tramp-get-remote-gio-monitor (vec) (defun tramp-get-remote-gio-monitor (vec)
"Determine remote `gio-monitor' command." "Determine remote `gio-monitor' command."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment