diff options
| -rw-r--r-- | lisp/ChangeLog | 24 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 193 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 13 |
3 files changed, 126 insertions, 104 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 66514f7488c..37e0b7aa1a2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,27 @@ | |||
| 1 | 2014-02-27 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp.el (tramp-call-process): Improve trace message. | ||
| 4 | (tramp-handle-insert-file-contents): Trace error case. | ||
| 5 | |||
| 6 | * net/tramp-adb.el (tramp-adb-file-name-handler-alist) | ||
| 7 | <insert-directory>: Use `tramp-handle-insert-directory'. | ||
| 8 | (tramp-adb-handle-insert-directory): Remove function. | ||
| 9 | (tramp-adb-send-command-and-check): New defun, replacing | ||
| 10 | `tramp-adb-command-exit-status'. Change all callees. | ||
| 11 | (tramp-adb-handle-file-attributes) | ||
| 12 | (tramp-adb-handle-directory-files-and-attributes): Use it. | ||
| 13 | (tramp-adb-ls-output-name-less-p): Use | ||
| 14 | `directory-listing-before-filename-regexp'. | ||
| 15 | (tramp-adb-handle-delete-directory): Flush also file properties of | ||
| 16 | the truename of directory. | ||
| 17 | (tramp-adb-handle-file-name-all-completions): Add "./" and "../". | ||
| 18 | (tramp-adb-handle-file-local-copy): Make the local copy readable. | ||
| 19 | (tramp-adb-handle-write-region): Implement APPEND. | ||
| 20 | (tramp-adb-handle-rename-file): Make it more robust. Flush file | ||
| 21 | properties correctly. | ||
| 22 | (tramp-adb-maybe-open-connection): Set `tramp-current-*' | ||
| 23 | variables. Check for connected devices only when needed. | ||
| 24 | |||
| 1 | 2014-02-27 Glenn Morris <rgm@gnu.org> | 25 | 2014-02-27 Glenn Morris <rgm@gnu.org> |
| 2 | 26 | ||
| 3 | * minibuffer.el (completion-table-dynamic) | 27 | * minibuffer.el (completion-table-dynamic) |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 8f2098c136b..4480e4a7189 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -38,7 +38,6 @@ | |||
| 38 | 38 | ||
| 39 | ;; Pacify byte-compiler. | 39 | ;; Pacify byte-compiler. |
| 40 | (defvar directory-sep-char) | 40 | (defvar directory-sep-char) |
| 41 | (defvar dired-move-to-filename-regexp) | ||
| 42 | 41 | ||
| 43 | (defcustom tramp-adb-program "adb" | 42 | (defcustom tramp-adb-program "adb" |
| 44 | "Name of the Android Debug Bridge program." | 43 | "Name of the Android Debug Bridge program." |
| @@ -134,7 +133,7 @@ | |||
| 134 | (find-backup-file-name . tramp-handle-find-backup-file-name) | 133 | (find-backup-file-name . tramp-handle-find-backup-file-name) |
| 135 | ;; `find-file-noselect' performed by default handler. | 134 | ;; `find-file-noselect' performed by default handler. |
| 136 | ;; `get-file-buffer' performed by default handler. | 135 | ;; `get-file-buffer' performed by default handler. |
| 137 | (insert-directory . tramp-adb-handle-insert-directory) | 136 | (insert-directory . tramp-handle-insert-directory) |
| 138 | (insert-file-contents . tramp-handle-insert-file-contents) | 137 | (insert-file-contents . tramp-handle-insert-file-contents) |
| 139 | (load . tramp-handle-load) | 138 | (load . tramp-handle-load) |
| 140 | (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) | 139 | (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) |
| @@ -309,17 +308,17 @@ pass to the OPERATION." | |||
| 309 | (defun tramp-adb-handle-file-attributes (filename &optional id-format) | 308 | (defun tramp-adb-handle-file-attributes (filename &optional id-format) |
| 310 | "Like `file-attributes' for Tramp files." | 309 | "Like `file-attributes' for Tramp files." |
| 311 | (unless id-format (setq id-format 'integer)) | 310 | (unless id-format (setq id-format 'integer)) |
| 312 | (ignore-errors | 311 | (with-parsed-tramp-file-name filename nil |
| 313 | (with-parsed-tramp-file-name filename nil | 312 | (with-tramp-file-property |
| 314 | (with-tramp-file-property | 313 | v localname (format "file-attributes-%s" id-format) |
| 315 | v localname (format "file-attributes-%s" id-format) | 314 | (and |
| 316 | (tramp-adb-barf-unless-okay | 315 | (tramp-adb-send-command-and-check |
| 317 | v (format "%s -d -l %s" | 316 | v (format "%s -d -l %s" |
| 318 | (tramp-adb-get-ls-command v) | 317 | (tramp-adb-get-ls-command v) |
| 319 | (tramp-shell-quote-argument localname)) "") | 318 | (tramp-shell-quote-argument localname))) |
| 320 | (with-current-buffer (tramp-get-buffer v) | 319 | (with-current-buffer (tramp-get-buffer v) |
| 321 | (tramp-adb-sh-fix-ls-output) | 320 | (tramp-adb-sh-fix-ls-output) |
| 322 | (cdar (tramp-do-parse-file-attributes-with-ls v id-format))))))) | 321 | (cdar (tramp-do-parse-file-attributes-with-ls v id-format))))))) |
| 323 | 322 | ||
| 324 | (defun tramp-do-parse-file-attributes-with-ls (vec &optional id-format) | 323 | (defun tramp-do-parse-file-attributes-with-ls (vec &optional id-format) |
| 325 | "Parse `file-attributes' for Tramp files using the ls(1) command." | 324 | "Parse `file-attributes' for Tramp files using the ls(1) command." |
| @@ -366,11 +365,19 @@ pass to the OPERATION." | |||
| 366 | (with-tramp-file-property | 365 | (with-tramp-file-property |
| 367 | v localname (format "directory-files-attributes-%s-%s-%s-%s" | 366 | v localname (format "directory-files-attributes-%s-%s-%s-%s" |
| 368 | full match id-format nosort) | 367 | full match id-format nosort) |
| 369 | (tramp-adb-barf-unless-okay | ||
| 370 | v (format "%s -a -l %s" | ||
| 371 | (tramp-adb-get-ls-command v) | ||
| 372 | (tramp-shell-quote-argument localname)) "") | ||
| 373 | (with-current-buffer (tramp-get-buffer v) | 368 | (with-current-buffer (tramp-get-buffer v) |
| 369 | (when (tramp-adb-send-command-and-check | ||
| 370 | v (format "%s -a -l %s" | ||
| 371 | (tramp-adb-get-ls-command v) | ||
| 372 | (tramp-shell-quote-argument localname))) | ||
| 373 | ;; We insert also filename/. and filename/.., because "ls" doesn't. | ||
| 374 | (narrow-to-region (point) (point)) | ||
| 375 | (tramp-adb-send-command | ||
| 376 | v (format "%s -d -a -l %s %s" | ||
| 377 | (tramp-adb-get-ls-command v) | ||
| 378 | (concat (file-name-as-directory localname) ".") | ||
| 379 | (concat (file-name-as-directory localname) ".."))) | ||
| 380 | (widen)) | ||
| 374 | (tramp-adb-sh-fix-ls-output) | 381 | (tramp-adb-sh-fix-ls-output) |
| 375 | (let ((result (tramp-do-parse-file-attributes-with-ls | 382 | (let ((result (tramp-do-parse-file-attributes-with-ls |
| 376 | v (or id-format 'integer)))) | 383 | v (or id-format 'integer)))) |
| @@ -392,8 +399,7 @@ pass to the OPERATION." | |||
| 392 | (defun tramp-adb-get-ls-command (vec) | 399 | (defun tramp-adb-get-ls-command (vec) |
| 393 | (with-tramp-connection-property vec "ls" | 400 | (with-tramp-connection-property vec "ls" |
| 394 | (tramp-message vec 5 "Finding a suitable `ls' command") | 401 | (tramp-message vec 5 "Finding a suitable `ls' command") |
| 395 | (if (zerop (tramp-adb-command-exit-status | 402 | (if (tramp-adb-send-command-and-check vec "ls --color=never -al /dev/null") |
| 396 | vec "ls --color=never -al /dev/null")) | ||
| 397 | ;; On CyanogenMod based system BusyBox is used and "ls" output | 403 | ;; On CyanogenMod based system BusyBox is used and "ls" output |
| 398 | ;; coloring is enabled by default. So we try to disable it | 404 | ;; coloring is enabled by default. So we try to disable it |
| 399 | ;; when possible. | 405 | ;; when possible. |
| @@ -417,35 +423,6 @@ Convert (\"-al\") to (\"-a\" \"-l\"). Remove arguments like \"--dired\"." | |||
| 417 | (and (not (string-match "\\(^--\\|^[^-]\\)" s)) s)) | 423 | (and (not (string-match "\\(^--\\|^[^-]\\)" s)) s)) |
| 418 | switches)))))) | 424 | switches)))))) |
| 419 | 425 | ||
| 420 | (defun tramp-adb-handle-insert-directory | ||
| 421 | (filename switches &optional _wildcard _full-directory-p) | ||
| 422 | "Like `insert-directory' for Tramp files." | ||
| 423 | (when (stringp switches) | ||
| 424 | (setq switches (tramp-adb--gnu-switches-to-ash (split-string switches)))) | ||
| 425 | (with-parsed-tramp-file-name (file-truename filename) nil | ||
| 426 | (with-current-buffer (tramp-get-buffer v) | ||
| 427 | (let ((name (tramp-shell-quote-argument (directory-file-name localname))) | ||
| 428 | (switch-d (member "-d" switches)) | ||
| 429 | (switch-t (member "-t" switches)) | ||
| 430 | (switches (mapconcat 'identity (remove "-t" switches) " "))) | ||
| 431 | (tramp-adb-barf-unless-okay | ||
| 432 | v (format "%s %s %s" (tramp-adb-get-ls-command v) switches name) | ||
| 433 | "Cannot insert directory listing: %s" filename) | ||
| 434 | (unless switch-d | ||
| 435 | ;; We insert also filename/. and filename/.., because "ls" doesn't. | ||
| 436 | (narrow-to-region (point) (point)) | ||
| 437 | (ignore-errors | ||
| 438 | (tramp-adb-barf-unless-okay | ||
| 439 | v (format "%s -d %s %s %s" | ||
| 440 | (tramp-adb-get-ls-command v) | ||
| 441 | switches | ||
| 442 | (concat (file-name-as-directory name) ".") | ||
| 443 | (concat (file-name-as-directory name) "..")) | ||
| 444 | "Cannot insert directory listing: %s" filename)) | ||
| 445 | (widen)) | ||
| 446 | (tramp-adb-sh-fix-ls-output switch-t))) | ||
| 447 | (insert-buffer-substring (tramp-get-buffer v)))) | ||
| 448 | |||
| 449 | (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time) | 426 | (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time) |
| 450 | "Insert dummy 0 in empty size columns. | 427 | "Insert dummy 0 in empty size columns. |
| 451 | Androids \"ls\" command doesn't insert size column for directories: | 428 | Androids \"ls\" command doesn't insert size column for directories: |
| @@ -489,9 +466,9 @@ Emacs dired can't find files." | |||
| 489 | (defun tramp-adb-ls-output-name-less-p (a b) | 466 | (defun tramp-adb-ls-output-name-less-p (a b) |
| 490 | "Sort \"ls\" output by name, ascending." | 467 | "Sort \"ls\" output by name, ascending." |
| 491 | (let (posa posb) | 468 | (let (posa posb) |
| 492 | (string-match dired-move-to-filename-regexp a) | 469 | (string-match directory-listing-before-filename-regexp a) |
| 493 | (setq posa (match-end 0)) | 470 | (setq posa (match-end 0)) |
| 494 | (string-match dired-move-to-filename-regexp b) | 471 | (string-match directory-listing-before-filename-regexp b) |
| 495 | (setq posb (match-end 0)) | 472 | (setq posb (match-end 0)) |
| 496 | (string-lessp (substring a posa) (substring b posb)))) | 473 | (string-lessp (substring a posa) (substring b posb)))) |
| 497 | 474 | ||
| @@ -511,6 +488,9 @@ Emacs dired can't find files." | |||
| 511 | (defun tramp-adb-handle-delete-directory (directory &optional recursive) | 488 | (defun tramp-adb-handle-delete-directory (directory &optional recursive) |
| 512 | "Like `delete-directory' for Tramp files." | 489 | "Like `delete-directory' for Tramp files." |
| 513 | (setq directory (expand-file-name directory)) | 490 | (setq directory (expand-file-name directory)) |
| 491 | (with-parsed-tramp-file-name (file-truename directory) nil | ||
| 492 | (tramp-flush-file-property v (file-name-directory localname)) | ||
| 493 | (tramp-flush-directory-property v localname)) | ||
| 514 | (with-parsed-tramp-file-name directory nil | 494 | (with-parsed-tramp-file-name directory nil |
| 515 | (tramp-flush-file-property v (file-name-directory localname)) | 495 | (tramp-flush-file-property v (file-name-directory localname)) |
| 516 | (tramp-flush-directory-property v localname) | 496 | (tramp-flush-directory-property v localname) |
| @@ -538,20 +518,22 @@ Emacs dired can't find files." | |||
| 538 | (with-tramp-file-property v localname "file-name-all-completions" | 518 | (with-tramp-file-property v localname "file-name-all-completions" |
| 539 | (save-match-data | 519 | (save-match-data |
| 540 | (tramp-adb-send-command | 520 | (tramp-adb-send-command |
| 541 | v (format "%s %s" | 521 | v (format "%s -a %s" |
| 542 | (tramp-adb-get-ls-command v) | 522 | (tramp-adb-get-ls-command v) |
| 543 | (tramp-shell-quote-argument localname))) | 523 | (tramp-shell-quote-argument localname))) |
| 544 | (mapcar | 524 | (mapcar |
| 545 | (lambda (f) | 525 | (lambda (f) |
| 546 | (if (file-directory-p f) | 526 | (if (file-directory-p (expand-file-name f directory)) |
| 547 | (file-name-as-directory f) | 527 | (file-name-as-directory f) |
| 548 | f)) | 528 | f)) |
| 549 | (with-current-buffer (tramp-get-buffer v) | 529 | (with-current-buffer (tramp-get-buffer v) |
| 550 | (delq | 530 | (append |
| 551 | nil | 531 | '("." "..") |
| 552 | (mapcar | 532 | (delq |
| 553 | (lambda (l) (and (not (string-match "^[[:space:]]*$" l)) l)) | 533 | nil |
| 554 | (split-string (buffer-string) "\n")))))))))) | 534 | (mapcar |
| 535 | (lambda (l) (and (not (string-match "^[[:space:]]*$" l)) l)) | ||
| 536 | (split-string (buffer-string) "\n"))))))))))) | ||
| 555 | 537 | ||
| 556 | (defun tramp-adb-handle-file-local-copy (filename) | 538 | (defun tramp-adb-handle-file-local-copy (filename) |
| 557 | "Like `file-local-copy' for Tramp files." | 539 | "Like `file-local-copy' for Tramp files." |
| @@ -567,7 +549,10 @@ Emacs dired can't find files." | |||
| 567 | (delete-file tmpfile) | 549 | (delete-file tmpfile) |
| 568 | (tramp-error | 550 | (tramp-error |
| 569 | v 'file-error "Cannot make local copy of file `%s'" filename)) | 551 | v 'file-error "Cannot make local copy of file `%s'" filename)) |
| 570 | (set-file-modes tmpfile (file-modes filename))) | 552 | (set-file-modes |
| 553 | tmpfile | ||
| 554 | (logior (or (file-modes filename) 0) | ||
| 555 | (tramp-compat-octal-to-decimal "0400")))) | ||
| 571 | tmpfile))) | 556 | tmpfile))) |
| 572 | 557 | ||
| 573 | (defun tramp-adb-handle-file-writable-p (filename) | 558 | (defun tramp-adb-handle-file-writable-p (filename) |
| @@ -577,9 +562,8 @@ But handle the case, if the \"test\" command is not available." | |||
| 577 | (with-tramp-file-property v localname "file-writable-p" | 562 | (with-tramp-file-property v localname "file-writable-p" |
| 578 | (if (tramp-adb-find-test-command v) | 563 | (if (tramp-adb-find-test-command v) |
| 579 | (if (file-exists-p filename) | 564 | (if (file-exists-p filename) |
| 580 | (zerop | 565 | (tramp-adb-send-command-and-check |
| 581 | (tramp-adb-command-exit-status | 566 | v (format "test -w %s" (tramp-shell-quote-argument localname))) |
| 582 | v (format "test -w %s" (tramp-shell-quote-argument localname)))) | ||
| 583 | (and | 567 | (and |
| 584 | (file-directory-p (file-name-directory filename)) | 568 | (file-directory-p (file-name-directory filename)) |
| 585 | (file-writable-p (file-name-directory filename)))) | 569 | (file-writable-p (file-name-directory filename)))) |
| @@ -599,9 +583,6 @@ But handle the case, if the \"test\" command is not available." | |||
| 599 | "Like `write-region' for Tramp files." | 583 | "Like `write-region' for Tramp files." |
| 600 | (setq filename (expand-file-name filename)) | 584 | (setq filename (expand-file-name filename)) |
| 601 | (with-parsed-tramp-file-name filename nil | 585 | (with-parsed-tramp-file-name filename nil |
| 602 | (when append | ||
| 603 | (tramp-error | ||
| 604 | v 'file-error "Cannot append to file using Tramp (`%s')" filename)) | ||
| 605 | (when (and confirm (file-exists-p filename)) | 586 | (when (and confirm (file-exists-p filename)) |
| 606 | (unless (y-or-n-p (format "File %s exists; overwrite anyway? " | 587 | (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
| 607 | filename)) | 588 | filename)) |
| @@ -612,6 +593,12 @@ But handle the case, if the \"test\" command is not available." | |||
| 612 | (tramp-flush-file-property v localname) | 593 | (tramp-flush-file-property v localname) |
| 613 | (let* ((curbuf (current-buffer)) | 594 | (let* ((curbuf (current-buffer)) |
| 614 | (tmpfile (tramp-compat-make-temp-file filename))) | 595 | (tmpfile (tramp-compat-make-temp-file filename))) |
| 596 | (when (and append (file-exists-p filename)) | ||
| 597 | (copy-file filename tmpfile 'ok) | ||
| 598 | (set-file-modes | ||
| 599 | tmpfile | ||
| 600 | (logior (or (file-modes tmpfile) 0) | ||
| 601 | (tramp-compat-octal-to-decimal "0600")))) | ||
| 615 | (tramp-run-real-handler | 602 | (tramp-run-real-handler |
| 616 | 'write-region | 603 | 'write-region |
| 617 | (list start end tmpfile append 'no-message lockname confirm)) | 604 | (list start end tmpfile append 'no-message lockname confirm)) |
| @@ -645,8 +632,8 @@ But handle the case, if the \"test\" command is not available." | |||
| 645 | (let ((time (if (or (null time) (equal time '(0 0))) | 632 | (let ((time (if (or (null time) (equal time '(0 0))) |
| 646 | (current-time) | 633 | (current-time) |
| 647 | time))) | 634 | time))) |
| 648 | (tramp-adb-command-exit-status | 635 | (tramp-adb-send-command-and-check |
| 649 | ;; use shell arithmetic because of Emacs integer size limit | 636 | ;; Use shell arithmetic because of Emacs integer size limit. |
| 650 | v (format "touch -t $(( %d * 65536 + %d )) %s" | 637 | v (format "touch -t $(( %d * 65536 + %d )) %s" |
| 651 | (car time) (cadr time) | 638 | (car time) (cadr time) |
| 652 | (tramp-shell-quote-argument localname)))))) | 639 | (tramp-shell-quote-argument localname)))))) |
| @@ -704,32 +691,36 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 704 | (setq filename (expand-file-name filename) | 691 | (setq filename (expand-file-name filename) |
| 705 | newname (expand-file-name newname)) | 692 | newname (expand-file-name newname)) |
| 706 | 693 | ||
| 707 | (with-parsed-tramp-file-name | 694 | (let ((t1 (tramp-tramp-file-p filename)) |
| 708 | (if (tramp-tramp-file-p filename) filename newname) nil | 695 | (t2 (tramp-tramp-file-p newname))) |
| 709 | (with-tramp-progress-reporter | 696 | (with-parsed-tramp-file-name (if t1 filename newname) nil |
| 710 | v 0 (format "Renaming %s to %s" newname filename) | 697 | (with-tramp-progress-reporter |
| 711 | 698 | v 0 (format "Renaming %s to %s" filename newname) | |
| 712 | (if (and (tramp-equal-remote filename newname) | 699 | |
| 713 | (not (file-directory-p filename))) | 700 | (if (and t1 t2 |
| 714 | (progn | 701 | (tramp-equal-remote filename newname) |
| 715 | (when (and (not ok-if-already-exists) | 702 | (not (file-directory-p filename))) |
| 716 | (file-exists-p newname)) | 703 | (let ((l1 (tramp-file-name-handler |
| 717 | (tramp-error v 'file-already-exists newname)) | 704 | 'file-remote-p filename 'localname)) |
| 718 | ;; We must also flush the cache of the directory, because | 705 | (l2 (tramp-file-name-handler |
| 719 | ;; `file-attributes' reads the values from there. | 706 | 'file-remote-p newname 'localname))) |
| 720 | (tramp-flush-file-property v (file-name-directory localname)) | 707 | (when (and (not ok-if-already-exists) |
| 721 | (tramp-flush-file-property v localname) | 708 | (file-exists-p newname)) |
| 722 | ;; Short track. | 709 | (tramp-error v 'file-already-exists newname)) |
| 723 | (tramp-adb-barf-unless-okay | 710 | ;; We must also flush the cache of the directory, because |
| 724 | v (format | 711 | ;; `file-attributes' reads the values from there. |
| 725 | "mv %s %s" | 712 | (tramp-flush-file-property v (file-name-directory l1)) |
| 726 | (tramp-file-name-handler 'file-remote-p filename 'localname) | 713 | (tramp-flush-file-property v l1) |
| 727 | localname) | 714 | (tramp-flush-file-property v (file-name-directory l2)) |
| 728 | "Error renaming %s to %s" filename newname)) | 715 | (tramp-flush-file-property v l2) |
| 729 | 716 | ;; Short track. | |
| 730 | ;; Rename by copy. | 717 | (tramp-adb-barf-unless-okay |
| 731 | (copy-file filename newname ok-if-already-exists t t) | 718 | v (format "mv %s %s" l1 l2) |
| 732 | (delete-file filename))))) | 719 | "Error renaming %s to %s" filename newname)) |
| 720 | |||
| 721 | ;; Rename by copy. | ||
| 722 | (copy-file filename newname ok-if-already-exists t t) | ||
| 723 | (delete-file filename)))))) | ||
| 733 | 724 | ||
| 734 | (defun tramp-adb-handle-process-file | 725 | (defun tramp-adb-handle-process-file |
| 735 | (program &optional infile destination display &rest args) | 726 | (program &optional infile destination display &rest args) |
| @@ -1010,7 +1001,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 1010 | "Checks, whether the ash has a builtin \"test\" command. | 1001 | "Checks, whether the ash has a builtin \"test\" command. |
| 1011 | This happens for Android >= 4.0." | 1002 | This happens for Android >= 4.0." |
| 1012 | (with-tramp-connection-property vec "test" | 1003 | (with-tramp-connection-property vec "test" |
| 1013 | (zerop (tramp-adb-command-exit-status vec "type test")))) | 1004 | (tramp-adb-send-command-and-check vec "type test"))) |
| 1014 | 1005 | ||
| 1015 | ;; Connection functions | 1006 | ;; Connection functions |
| 1016 | 1007 | ||
| @@ -1033,9 +1024,9 @@ This happens for Android >= 4.0." | |||
| 1033 | (while (re-search-forward "\r+$" nil t) | 1024 | (while (re-search-forward "\r+$" nil t) |
| 1034 | (replace-match "" nil nil))))) | 1025 | (replace-match "" nil nil))))) |
| 1035 | 1026 | ||
| 1036 | (defun tramp-adb-command-exit-status | 1027 | (defun tramp-adb-send-command-and-check |
| 1037 | (vec command) | 1028 | (vec command) |
| 1038 | "Run COMMAND and return its exit status. | 1029 | "Run COMMAND and and check its exit status. |
| 1039 | Sends `echo $?' along with the COMMAND for checking the exit status. If | 1030 | Sends `echo $?' along with the COMMAND for checking the exit status. If |
| 1040 | COMMAND is nil, just sends `echo $?'. Returns the exit status found." | 1031 | COMMAND is nil, just sends `echo $?'. Returns the exit status found." |
| 1041 | (tramp-adb-send-command | 1032 | (tramp-adb-send-command |
| @@ -1049,14 +1040,14 @@ COMMAND is nil, just sends `echo $?'. Returns the exit status found." | |||
| 1049 | vec 'file-error "Couldn't find exit status of `%s'" command)) | 1040 | vec 'file-error "Couldn't find exit status of `%s'" command)) |
| 1050 | (skip-chars-forward "^ ") | 1041 | (skip-chars-forward "^ ") |
| 1051 | (prog1 | 1042 | (prog1 |
| 1052 | (read (current-buffer)) | 1043 | (zerop (read (current-buffer))) |
| 1053 | (let (buffer-read-only) | 1044 | (let (buffer-read-only) |
| 1054 | (delete-region (match-beginning 0) (point-max)))))) | 1045 | (delete-region (match-beginning 0) (point-max)))))) |
| 1055 | 1046 | ||
| 1056 | (defun tramp-adb-barf-unless-okay (vec command fmt &rest args) | 1047 | (defun tramp-adb-barf-unless-okay (vec command fmt &rest args) |
| 1057 | "Run COMMAND, check exit status, throw error if exit status not okay. | 1048 | "Run COMMAND, check exit status, throw error if exit status not okay. |
| 1058 | FMT and ARGS are passed to `error'." | 1049 | FMT and ARGS are passed to `error'." |
| 1059 | (unless (zerop (tramp-adb-command-exit-status vec command)) | 1050 | (unless (tramp-adb-send-command-and-check vec command) |
| 1060 | (apply 'tramp-error vec 'file-error fmt args))) | 1051 | (apply 'tramp-error vec 'file-error fmt args))) |
| 1061 | 1052 | ||
| 1062 | (defun tramp-adb-wait-for-output (proc &optional timeout) | 1053 | (defun tramp-adb-wait-for-output (proc &optional timeout) |
| @@ -1099,7 +1090,7 @@ connection if a previous connection has died for some reason." | |||
| 1099 | (p (get-buffer-process buf)) | 1090 | (p (get-buffer-process buf)) |
| 1100 | (host (tramp-file-name-host vec)) | 1091 | (host (tramp-file-name-host vec)) |
| 1101 | (user (tramp-file-name-user vec)) | 1092 | (user (tramp-file-name-user vec)) |
| 1102 | (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) | 1093 | devices) |
| 1103 | 1094 | ||
| 1104 | ;; Maybe we know already that "su" is not supported. We cannot | 1095 | ;; Maybe we know already that "su" is not supported. We cannot |
| 1105 | ;; use a connection property, because we have not checked yet | 1096 | ;; use a connection property, because we have not checked yet |
| @@ -1111,6 +1102,10 @@ connection if a previous connection has died for some reason." | |||
| 1111 | (and p (processp p) (memq (process-status p) '(run open))) | 1102 | (and p (processp p) (memq (process-status p) '(run open))) |
| 1112 | (save-match-data | 1103 | (save-match-data |
| 1113 | (when (and p (processp p)) (delete-process p)) | 1104 | (when (and p (processp p)) (delete-process p)) |
| 1105 | (setq tramp-current-method (tramp-file-name-method vec) | ||
| 1106 | tramp-current-user (tramp-file-name-user vec) | ||
| 1107 | tramp-current-host (tramp-file-name-host vec) | ||
| 1108 | devices (mapcar 'cadr (tramp-adb-parse-device-names nil))) | ||
| 1114 | (if (not devices) | 1109 | (if (not devices) |
| 1115 | (tramp-error vec 'file-error "No device connected")) | 1110 | (tramp-error vec 'file-error "No device connected")) |
| 1116 | (if (and (> (length host) 0) (not (member host devices))) | 1111 | (if (and (> (length host) 0) (not (member host devices))) |
| @@ -1165,7 +1160,7 @@ connection if a previous connection has died for some reason." | |||
| 1165 | ;; Change user if indicated. | 1160 | ;; Change user if indicated. |
| 1166 | (when user | 1161 | (when user |
| 1167 | (tramp-adb-send-command vec (format "su %s" user)) | 1162 | (tramp-adb-send-command vec (format "su %s" user)) |
| 1168 | (unless (zerop (tramp-adb-command-exit-status vec nil)) | 1163 | (unless (tramp-adb-send-command-and-check vec nil) |
| 1169 | (delete-process p) | 1164 | (delete-process p) |
| 1170 | (tramp-set-file-property vec "" "su-command-p" nil) | 1165 | (tramp-set-file-property vec "" "su-command-p" nil) |
| 1171 | (tramp-error | 1166 | (tramp-error |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 581aaa40c99..7d88869a0d1 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3050,10 +3050,13 @@ User is always nil." | |||
| 3050 | v 3 (format "Inserting `%s'" filename) | 3050 | v 3 (format "Inserting `%s'" filename) |
| 3051 | (unwind-protect | 3051 | (unwind-protect |
| 3052 | (if (not (file-exists-p filename)) | 3052 | (if (not (file-exists-p filename)) |
| 3053 | ;; We don't raise a Tramp error, because it might be | 3053 | (progn |
| 3054 | ;; suppressed, like in `find-file-noselect-1'. | 3054 | ;; We don't raise a Tramp error, because it might be |
| 3055 | (signal 'file-error | 3055 | ;; suppressed, like in `find-file-noselect-1'. |
| 3056 | (list "File not found on remote host" filename)) | 3056 | (tramp-message |
| 3057 | v 1 "File not `%s' found on remote host" filename) | ||
| 3058 | (signal 'file-error | ||
| 3059 | (list "File not found on remote host" filename))) | ||
| 3057 | 3060 | ||
| 3058 | (if (and (tramp-local-host-p v) | 3061 | (if (and (tramp-local-host-p v) |
| 3059 | (let (file-name-handler-alist) | 3062 | (let (file-name-handler-alist) |
| @@ -4082,7 +4085,7 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1. | |||
| 4082 | Furthermore, traces are written with verbosity of 6." | 4085 | Furthermore, traces are written with verbosity of 6." |
| 4083 | (tramp-message | 4086 | (tramp-message |
| 4084 | (vector tramp-current-method tramp-current-user tramp-current-host nil nil) | 4087 | (vector tramp-current-method tramp-current-user tramp-current-host nil nil) |
| 4085 | 6 "%s %s %s" program infile args) | 4088 | 6 "`%s %s' %s" program (mapconcat 'identity args " ") infile) |
| 4086 | (if (executable-find program) | 4089 | (if (executable-find program) |
| 4087 | (apply 'call-process program infile destination display args) | 4090 | (apply 'call-process program infile destination display args) |
| 4088 | 1)) | 4091 | 1)) |