summaryrefslogtreecommitdiff
path: root/lisp/net/tramp-smb.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/tramp-smb.el')
-rw-r--r--lisp/net/tramp-smb.el274
1 files changed, 146 insertions, 128 deletions
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 509e2e388b8..70b72d82f54 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -49,7 +49,9 @@
;; This is just a guess. We don't know whether the share "C$"
;; is available for public use, and whether the user has write
;; access.
- (tramp-tmpdir "/C$/Temp"))))
+ (tramp-tmpdir "/C$/Temp")
+ ;; Another guess. We might implement a better check later on.
+ (tramp-case-insensitive t))))
;; Add a default for `tramp-default-method-alist'. Rule: If there is
;; a domain in USER, it must be the SMB method.
@@ -74,14 +76,16 @@
(defcustom tramp-smb-program "smbclient"
"Name of SMB client to run."
:group 'tramp
- :type 'string)
+ :type 'string
+ :require 'tramp)
;;;###tramp-autoload
(defcustom tramp-smb-acl-program "smbcacls"
"Name of SMB acls to run."
:group 'tramp
:type 'string
- :version "24.4")
+ :version "24.4"
+ :require 'tramp)
;;;###tramp-autoload
(defcustom tramp-smb-conf "/dev/null"
@@ -89,7 +93,8 @@
If it is nil, no smb.conf will be added to the `tramp-smb-program'
call, letting the SMB client use the default one."
:group 'tramp
- :type '(choice (const nil) (file :must-match t)))
+ :type '(choice (const nil) (file :must-match t))
+ :require 'tramp)
(defvar tramp-smb-version nil
"Version string of the SMB client.")
@@ -129,7 +134,8 @@ call, letting the SMB client use the default one."
"ERRnosuchshare"
;; Windows 4.0 (Windows NT), Windows 5.0 (Windows 2000),
;; Windows 5.1 (Windows XP), Windows 5.2 (Windows Server 2003),
- ;; Windows 6.0 (Windows Vista), Windows 6.1 (Windows 7).
+ ;; Windows 6.0 (Windows Vista), Windows 6.1 (Windows 7),
+ ;; Windows 6.3 (Windows Server 2012, Windows 10).
"NT_STATUS_ACCESS_DENIED"
"NT_STATUS_ACCOUNT_LOCKED_OUT"
"NT_STATUS_BAD_NETWORK_NAME"
@@ -224,7 +230,6 @@ See `tramp-actions-before-shell' for more info.")
(directory-files . tramp-smb-handle-directory-files)
(directory-files-and-attributes
. tramp-handle-directory-files-and-attributes)
- (dired-call-process . ignore)
(dired-compress-file . ignore)
(dired-uncache . tramp-handle-dired-uncache)
(expand-file-name . tramp-smb-handle-expand-file-name)
@@ -240,6 +245,7 @@ See `tramp-actions-before-shell' for more info.")
(file-modes . tramp-handle-file-modes)
(file-name-all-completions . tramp-smb-handle-file-name-all-completions)
(file-name-as-directory . tramp-handle-file-name-as-directory)
+ (file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p)
(file-name-completion . tramp-handle-file-name-completion)
(file-name-directory . tramp-handle-file-name-directory)
(file-name-nondirectory . tramp-handle-file-name-nondirectory)
@@ -265,6 +271,7 @@ See `tramp-actions-before-shell' for more info.")
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
(make-directory . tramp-smb-handle-make-directory)
(make-directory-internal . tramp-smb-handle-make-directory-internal)
+ (make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
(make-symbolic-link . tramp-smb-handle-make-symbolic-link)
(process-file . tramp-smb-handle-process-file)
(rename-file . tramp-smb-handle-rename-file)
@@ -276,7 +283,8 @@ See `tramp-actions-before-shell' for more info.")
(shell-command . tramp-handle-shell-command)
(start-file-process . tramp-smb-handle-start-file-process)
(substitute-in-file-name . tramp-smb-handle-substitute-in-file-name)
- (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
+ (temporary-file-directory . tramp-handle-temporary-file-directory)
+ (unhandled-file-name-directory . ignore)
(vc-registered . ignore)
(verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
(write-region . tramp-smb-handle-write-region))
@@ -291,7 +299,8 @@ If it isn't found in the local $PATH, the absolute path of winexe
shall be given. This is needed for remote processes."
:group 'tramp
:type 'string
- :version "24.3")
+ :version "24.3"
+ :require 'tramp)
;;;###tramp-autoload
(defcustom tramp-smb-winexe-shell-command "powershell.exe"
@@ -299,7 +308,8 @@ shall be given. This is needed for remote processes."
This must be Powershell V2 compatible."
:group 'tramp
:type 'string
- :version "24.3")
+ :version "24.3"
+ :require 'tramp)
;;;###tramp-autoload
(defcustom tramp-smb-winexe-shell-command-switch "-file -"
@@ -307,7 +317,8 @@ This must be Powershell V2 compatible."
This can be used to disable echo etc."
:group 'tramp
:type 'string
- :version "24.3")
+ :version "24.3"
+ :require 'tramp)
;; It must be a `defsubst' in order to push the whole code into
;; tramp-loaddefs.el. Otherwise, there would be recursive autoloading.
@@ -380,7 +391,7 @@ pass to the OPERATION."
(defun tramp-smb-action-with-tar (proc vec)
"Untar from connection buffer."
- (if (not (memq (process-status proc) '(run open)))
+ (if (not (tramp-compat-process-live-p proc))
(throw 'tramp-action 'process-died)
(with-current-buffer (tramp-get-connection-buffer vec)
@@ -419,15 +430,14 @@ pass to the OPERATION."
(unwind-protect
(progn
(make-directory tmpdir)
- (tramp-compat-copy-directory
- dirname tmpdir keep-date 'parents)
- (tramp-compat-copy-directory
+ (copy-directory dirname tmpdir keep-date 'parents)
+ (copy-directory
(expand-file-name (file-name-nondirectory dirname) tmpdir)
newname keep-date parents))
- (tramp-compat-delete-directory tmpdir 'recursive))))
+ (delete-directory tmpdir 'recursive))))
;; We can copy recursively.
- ((or t1 t2)
+ ((and (or t1 t2) (tramp-smb-get-cifs-capabilities v))
(when (and (file-directory-p newname)
(not (string-equal (file-name-nondirectory dirname)
(file-name-nondirectory newname))))
@@ -448,7 +458,7 @@ pass to the OPERATION."
(port (tramp-file-name-port v))
(share (tramp-smb-get-share v))
(localname (file-name-as-directory
- (tramp-compat-replace-regexp-in-string
+ (replace-regexp-in-string
"\\\\" "/" (tramp-smb-get-localname v))))
(tmpdir (make-temp-name
(expand-file-name
@@ -468,15 +478,19 @@ pass to the OPERATION."
(if t1
;; Source is remote.
(append args
- (list "-D" (shell-quote-argument localname)
+ (list "-D" (tramp-unquote-shell-quote-argument
+ localname)
"-c" (shell-quote-argument "tar qc - *")
"|" "tar" "xfC" "-"
- (shell-quote-argument tmpdir)))
+ (tramp-unquote-shell-quote-argument
+ tmpdir)))
;; Target is remote.
(append (list "tar" "cfC" "-"
- (shell-quote-argument dirname) "." "|")
+ (tramp-unquote-shell-quote-argument dirname)
+ "." "|")
args
- (list "-D" (shell-quote-argument localname)
+ (list "-D" (tramp-unquote-shell-quote-argument
+ localname)
"-c" (shell-quote-argument "tar qx -")))))
(unwind-protect
@@ -494,7 +508,8 @@ pass to the OPERATION."
;; target.
(make-directory
(expand-file-name
- ".." (concat tmpdir localname)) 'parents)
+ ".." (concat tmpdir localname))
+ 'parents)
(make-symbolic-link
newname (directory-file-name (concat tmpdir localname))))
@@ -510,21 +525,24 @@ pass to the OPERATION."
(tramp-message
v 6 "%s" (mapconcat 'identity (process-command p) " "))
(tramp-set-connection-property p "vector" v)
- (tramp-compat-set-process-query-on-exit-flag p nil)
+ (set-process-query-on-exit-flag p nil)
(tramp-process-actions p v nil tramp-smb-actions-with-tar)
- (while (memq (process-status p) '(run open))
+ (while (tramp-compat-process-live-p p)
(sit-for 0.1))
(tramp-message v 6 "\n%s" (buffer-string))))
;; Reset the transfer process properties.
(tramp-set-connection-property v "process-name" nil)
(tramp-set-connection-property v "process-buffer" nil)
- (when t1 (tramp-compat-delete-directory tmpdir 'recurse))))
+ (when t1 (delete-directory tmpdir 'recurse))))
;; Handle KEEP-DATE argument.
(when keep-date
- (set-file-times newname (nth 5 (file-attributes dirname))))
+ (set-file-times
+ newname
+ (tramp-compat-file-attribute-modification-time
+ (file-attributes dirname))))
;; Set the mode.
(unless keep-date
@@ -543,7 +561,7 @@ pass to the OPERATION."
(defun tramp-smb-handle-copy-file
(filename newname &optional ok-if-already-exists keep-date
- _preserve-uid-gid _preserve-extended-attributes)
+ _preserve-uid-gid _preserve-extended-attributes)
"Like `copy-file' for Tramp files.
KEEP-DATE has no effect in case NEWNAME resides on an SMB server.
PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
@@ -555,7 +573,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
0 (format "Copying %s to %s" filename newname)
(if (file-directory-p filename)
- (tramp-compat-copy-directory filename newname keep-date t t)
+ (tramp-compat-copy-directory
+ filename newname keep-date 'parents 'copy-contents)
(let ((tmpfile (file-local-copy filename)))
(if tmpfile
@@ -585,27 +604,30 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
v 'file-error "Target `%s' must contain a share name" newname))
(unless (tramp-smb-send-command
v (format "put \"%s\" \"%s\""
- filename (tramp-smb-get-localname v)))
+ (tramp-compat-file-name-unquote filename)
+ (tramp-smb-get-localname v)))
(tramp-error
v 'file-error "Cannot copy `%s' to `%s'" filename newname))))))
;; KEEP-DATE handling.
(when keep-date
- (set-file-times newname (nth 5 (file-attributes filename))))))
+ (set-file-times
+ newname
+ (tramp-compat-file-attribute-modification-time
+ (file-attributes filename))))))
(defun tramp-smb-handle-delete-directory (directory &optional recursive)
"Like `delete-directory' for Tramp files."
(setq directory (directory-file-name (expand-file-name directory)))
(when (file-exists-p directory)
- (if recursive
- (mapc
- (lambda (file)
- (if (file-directory-p file)
- (tramp-compat-delete-directory file recursive)
- (delete-file file)))
- ;; We do not want to delete "." and "..".
- (directory-files
- directory 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*")))
+ (when recursive
+ (mapc
+ (lambda (file)
+ (if (file-directory-p file)
+ (delete-directory file recursive)
+ (delete-file file)))
+ ;; We do not want to delete "." and "..".
+ (directory-files directory 'full directory-files-no-dot-files-regexp)))
(with-parsed-tramp-file-name directory nil
;; We must also flush the cache of the directory, because
@@ -664,8 +686,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
result)))
;; Sort them if necessary.
(unless nosort (setq result (sort result 'string-lessp)))
- ;; Remove double entries.
- (tramp-compat-delete-dups result)))
+ result))
(defun tramp-smb-handle-expand-file-name (name &optional dir)
"Like `expand-file-name' for Tramp files."
@@ -699,7 +720,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(defun tramp-smb-action-get-acl (proc vec)
"Read ACL data from connection buffer."
- (when (not (memq (process-status proc) '(run open)))
+ (unless (tramp-compat-process-live-p proc)
;; Accept pending output.
(while (tramp-accept-process-output proc 0.1))
(with-current-buffer (tramp-get-connection-buffer vec)
@@ -730,7 +751,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(domain (tramp-file-name-domain v))
(port (tramp-file-name-port v))
(share (tramp-smb-get-share v))
- (localname (tramp-compat-replace-regexp-in-string
+ (localname (replace-regexp-in-string
"\\\\" "/" (tramp-smb-get-localname v)))
(args (list (concat "//" real-host "/" share) "-E")))
@@ -744,7 +765,8 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(setq args (append args (list "-s" tramp-smb-conf))))
(setq
args
- (append args (list (shell-quote-argument localname) "2>/dev/null")))
+ (append args (list (tramp-unquote-shell-quote-argument localname)
+ "2>/dev/null")))
(unwind-protect
(with-temp-buffer
@@ -765,11 +787,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(tramp-message
v 6 "%s" (mapconcat 'identity (process-command p) " "))
(tramp-set-connection-property p "vector" v)
- (tramp-compat-set-process-query-on-exit-flag p nil)
+ (set-process-query-on-exit-flag p nil)
(tramp-process-actions p v nil tramp-smb-actions-get-acl)
(when (> (point-max) (point-min))
- (tramp-compat-funcall
- 'substring-no-properties (buffer-string)))))
+ (substring-no-properties (buffer-string)))))
;; Reset the transfer process properties.
(tramp-set-connection-property v "process-name" nil)
@@ -882,14 +903,16 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(defun tramp-smb-handle-file-directory-p (filename)
"Like `file-directory-p' for Tramp files."
(and (file-exists-p filename)
- (eq ?d (aref (nth 8 (file-attributes filename)) 0))))
+ (eq ?d
+ (aref (tramp-compat-file-attribute-modes (file-attributes filename))
+ 0))))
(defun tramp-smb-handle-file-local-copy (filename)
"Like `file-local-copy' for Tramp files."
(with-parsed-tramp-file-name filename nil
(unless (file-exists-p filename)
(tramp-error
- v 'file-error
+ v tramp-file-missing
"Cannot make local copy of non-existing file `%s'" filename))
(let ((tmpfile (tramp-compat-make-temp-file filename)))
(with-tramp-progress-reporter
@@ -909,22 +932,24 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
"Like `file-name-all-completions' for Tramp files."
(all-completions
filename
- (with-parsed-tramp-file-name directory nil
+ (with-parsed-tramp-file-name (expand-file-name directory) nil
(with-tramp-file-property v localname "file-name-all-completions"
(save-match-data
- (let ((entries (tramp-smb-get-file-entries directory)))
- (mapcar
- (lambda (x)
- (list
- (if (string-match "d" (nth 1 x))
- (file-name-as-directory (nth 0 x))
- (nth 0 x))))
- entries)))))))
+ (delete-dups
+ (mapcar
+ (lambda (x)
+ (list
+ (if (string-match "d" (nth 1 x))
+ (file-name-as-directory (nth 0 x))
+ (nth 0 x))))
+ (tramp-smb-get-file-entries directory))))))))
(defun tramp-smb-handle-file-writable-p (filename)
"Like `file-writable-p' for Tramp files."
(if (file-exists-p filename)
- (string-match "w" (or (nth 8 (file-attributes filename)) ""))
+ (string-match
+ "w"
+ (or (tramp-compat-file-attribute-modes (file-attributes filename)) ""))
(let ((dir (file-name-directory filename)))
(and (file-exists-p dir)
(file-writable-p dir)))))
@@ -1009,11 +1034,11 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(insert
(format
"%10s %3d %-8s %-8s %8s %s "
- (or (nth 8 attr) (nth 1 x)) ; mode
- (or (nth 1 attr) 1) ; inode
- (or (nth 2 attr) "nobody") ; uid
- (or (nth 3 attr) "nogroup") ; gid
- (or (nth 7 attr) (nth 2 x)) ; size
+ (or (tramp-compat-file-attribute-modes attr) (nth 1 x))
+ (or (tramp-compat-file-attribute-link-number attr) 1)
+ (or (tramp-compat-file-attribute-user-id attr) "nobody")
+ (or (tramp-compat-file-attribute-group-id attr) "nogroup")
+ (or (tramp-compat-file-attribute-size attr) (nth 2 x))
(format-time-string
(if (time-less-p (time-subtract (current-time) (nth 3 x))
tramp-half-a-year)
@@ -1068,9 +1093,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(tramp-smb-send-command
v
(if (tramp-smb-get-cifs-capabilities v)
- (format
- "posix_mkdir \"%s\" %s"
- file (tramp-compat-decimal-to-octal (default-file-modes)))
+ (format "posix_mkdir \"%s\" %o" file (default-file-modes))
(format "mkdir \"%s\"" file)))
;; We must also flush the cache of the directory, because
;; `file-attributes' reads the values from there.
@@ -1112,7 +1135,7 @@ target of the symlink differ."
"File %s already exists; make it a new name anyway? "
linkname)))
(tramp-error
- v2 'file-error
+ v2 'file-already-exists
"make-symbolic-link: file %s already exists" linkname))
(unless (tramp-smb-get-cifs-capabilities v1)
(tramp-error v2 'file-error "make-symbolic-link not supported"))
@@ -1215,7 +1238,7 @@ target of the symlink differ."
(narrow-to-region (point-max) (point-max))
(let ((p (tramp-get-connection-process v)))
(tramp-smb-send-command v "exit $lasterrorcode")
- (while (memq (process-status p) '(run open))
+ (while (tramp-compat-process-live-p p)
(sleep-for 0.1)
(setq ret (process-exit-status p))))
(delete-region (point-min) (point-max))
@@ -1240,12 +1263,7 @@ target of the symlink differ."
(unless outbuf
(kill-buffer (tramp-get-connection-property v "process-buffer" nil)))
- ;; `process-file-side-effects' has been introduced with GNU
- ;; Emacs 23.2. If set to nil, no remote file will be changed
- ;; by `program'. If it doesn't exist, we assume its default
- ;; value t.
- (unless (and (boundp 'process-file-side-effects)
- (not (symbol-value 'process-file-side-effects)))
+ (unless process-file-side-effects
(tramp-flush-directory-property v ""))
;; Return exit status.
@@ -1296,14 +1314,15 @@ target of the symlink differ."
(tramp-error v2 'file-error "Cannot rename `%s'" filename))))
;; We must rename via copy.
- (tramp-compat-copy-file filename newname ok-if-already-exists t t t)
+ (copy-file
+ filename newname ok-if-already-exists 'keep-time 'preserve-uid-gid)
(if (file-directory-p filename)
- (tramp-compat-delete-directory filename 'recursive)
+ (delete-directory filename 'recursive)
(delete-file filename)))))
(defun tramp-smb-action-set-acl (proc vec)
"Read ACL data from connection buffer."
- (when (not (memq (process-status proc) '(run open)))
+ (unless (tramp-compat-process-live-p proc)
;; Accept pending output.
(while (tramp-accept-process-output proc 0.1))
(with-current-buffer (tramp-get-connection-buffer vec)
@@ -1325,10 +1344,10 @@ target of the symlink differ."
(domain (tramp-file-name-domain v))
(port (tramp-file-name-port v))
(share (tramp-smb-get-share v))
- (localname (tramp-compat-replace-regexp-in-string
+ (localname (replace-regexp-in-string
"\\\\" "/" (tramp-smb-get-localname v)))
(args (list (concat "//" real-host "/" share) "-E" "-S"
- (tramp-compat-replace-regexp-in-string
+ (replace-regexp-in-string
"\n" "," acl-string))))
(if (not (zerop (length real-user)))
@@ -1341,7 +1360,7 @@ target of the symlink differ."
(setq args (append args (list "-s" tramp-smb-conf))))
(setq
args
- (append args (list (shell-quote-argument localname)
+ (append args (list (tramp-unquote-shell-quote-argument localname)
"&&" "echo" "tramp_exit_status" "0"
"||" "echo" "tramp_exit_status" "1")))
@@ -1364,7 +1383,7 @@ target of the symlink differ."
(tramp-message
v 6 "%s" (mapconcat 'identity (process-command p) " "))
(tramp-set-connection-property p "vector" v)
- (tramp-compat-set-process-query-on-exit-flag p nil)
+ (set-process-query-on-exit-flag p nil)
(tramp-process-actions p v nil tramp-smb-actions-set-acl)
(goto-char (point-max))
(unless (re-search-backward "tramp_exit_status [0-9]+" nil t)
@@ -1387,9 +1406,7 @@ target of the symlink differ."
(when (tramp-smb-get-cifs-capabilities v)
(tramp-flush-file-property v localname)
(unless (tramp-smb-send-command
- v (format "chmod \"%s\" %s"
- (tramp-smb-get-localname v)
- (tramp-compat-decimal-to-octal mode)))
+ v (format "chmod \"%s\" %o" (tramp-smb-get-localname v) mode))
(tramp-error
v 'file-error "Error while changing file's mode %s" filename)))))
@@ -1399,16 +1416,18 @@ target of the symlink differ."
(defun tramp-smb-handle-start-file-process (name buffer program &rest args)
"Like `start-file-process' for Tramp files."
(with-parsed-tramp-file-name default-directory nil
- (let ((command (mapconcat 'identity (cons program args) " "))
- (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
- (name1 name)
- (i 0))
+ (let* ((buffer
+ (if buffer
+ (get-buffer-create buffer)
+ ;; BUFFER can be nil. We use a temporary buffer.
+ (generate-new-buffer tramp-temp-buffer-name)))
+ (command (mapconcat 'identity (cons program args) " "))
+ (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
+ (name1 name)
+ (i 0))
(unwind-protect
(save-excursion
(save-restriction
- (unless buffer
- ;; BUFFER can be nil. We use a temporary buffer.
- (setq buffer (generate-new-buffer tramp-temp-buffer-name)))
(while (get-process name1)
;; NAME must be unique as process name.
(setq i (1+ i)
@@ -1445,24 +1464,25 @@ target of the symlink differ."
"Like `handle-substitute-in-file-name' for Tramp files.
\"//\" substitutes only in the local filename part. Catches
errors for shares like \"C$/\", which are common in Microsoft Windows."
- (with-parsed-tramp-file-name filename nil
- ;; Ignore in LOCALNAME everything before "//".
- (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
- (setq filename
- (concat (file-remote-p filename)
- (replace-match "\\1" nil nil localname)))))
- (condition-case nil
- (tramp-run-real-handler 'substitute-in-file-name (list filename))
- (error filename)))
+ ;; Check, whether the local part is a quoted file name.
+ (if (tramp-compat-file-name-quoted-p filename)
+ filename
+ (with-parsed-tramp-file-name filename nil
+ ;; Ignore in LOCALNAME everything before "//".
+ (when (and (stringp localname) (string-match ".+?/\\(/\\|~\\)" localname))
+ (setq filename
+ (concat (file-remote-p filename)
+ (replace-match "\\1" nil nil localname)))))
+ (condition-case nil
+ (tramp-run-real-handler 'substitute-in-file-name (list filename))
+ (error filename))))
(defun tramp-smb-handle-write-region
(start end filename &optional append visit lockname confirm)
"Like `write-region' for Tramp files."
(setq filename (expand-file-name filename))
(with-parsed-tramp-file-name filename nil
- ;; XEmacs takes a coding system as the seventh argument, not `confirm'.
- (when (and (not (featurep 'xemacs))
- confirm (file-exists-p filename))
+ (when (and confirm (file-exists-p filename))
(unless (y-or-n-p (format "File %s exists; overwrite anyway? "
filename))
(tramp-error v 'file-error "File not overwritten")))
@@ -1505,7 +1525,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
(defun tramp-smb-get-share (vec)
"Returns the share name of LOCALNAME."
(save-match-data
- (let ((localname (tramp-file-name-localname vec)))
+ (let ((localname (tramp-file-name-unquote-localname vec)))
(when (string-match "^/?\\([^/]+\\)/" localname)
(match-string 1 localname)))))
@@ -1513,7 +1533,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
"Returns the file name of LOCALNAME.
If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
(save-match-data
- (let ((localname (tramp-file-name-localname vec)))
+ (let ((localname (tramp-file-name-unquote-localname vec)))
(setq
localname
(if (string-match "^/?[^/]+\\(/.*\\)" localname)
@@ -1575,10 +1595,6 @@ Result is a list of (LOCALNAME MODE SIZE MONTH DAY TIME YEAR)."
;; Add directory itself.
(push '("" "drwxrwxrwx" 0 (0 0)) res)
- ;; There's a very strange error (debugged with XEmacs 21.4.14)
- ;; If there's no short delay, it returns nil. No idea about.
- (when (featurep 'xemacs) (sleep-for 0.01))
-
;; Return entries.
(delq nil res))))))
@@ -1717,7 +1733,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
(if (and sec min hour day month year)
(encode-time
sec min hour day
- (cdr (assoc (downcase month) tramp-parse-time-months))
+ (cdr (assoc (downcase month) parse-time-months))
year)
'(0 0)))
(list localname mode size mtime))))
@@ -1725,8 +1741,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
(defun tramp-smb-get-cifs-capabilities (vec)
"Check, whether the SMB server supports POSIX commands."
;; When we are not logged in yet, we return nil.
- (if (let ((p (tramp-get-connection-process vec)))
- (and p (processp p) (memq (process-status p) '(run open))))
+ (if (tramp-compat-process-live-p (tramp-get-connection-process vec))
(with-tramp-connection-property
(tramp-get-connection-process vec) "cifs-capabilities"
(save-match-data
@@ -1738,14 +1753,13 @@ Result is the list (LOCALNAME MODE SIZE MTIME)."
(member
"pathnames"
(split-string
- (buffer-substring (point) (point-at-eol)) nil t)))))))))
+ (buffer-substring (point) (point-at-eol)) nil 'omit)))))))))
(defun tramp-smb-get-stat-capability (vec)
"Check, whether the SMB server supports the STAT command."
;; When we are not logged in yet, we return nil.
(if (and (tramp-smb-get-share vec)
- (let ((p (tramp-get-connection-process vec)))
- (and p (processp p) (memq (process-status p) '(run open)))))
+ (tramp-compat-process-live-p (tramp-get-connection-process vec)))
(with-tramp-connection-property
(tramp-get-connection-process vec) "stat-capability"
(tramp-smb-send-command vec "stat \"/\""))))
@@ -1812,18 +1826,17 @@ If ARGUMENT is non-nil, use it as argument for
(tramp-get-connection-property
p "last-cmd-time" '(0 0 0)))
60)
- p (processp p) (memq (process-status p) '(run open))
+ (tramp-compat-process-live-p p)
(re-search-forward tramp-smb-errors nil t))
(delete-process p)
(setq p nil)))
;; Check whether it is still the same share.
- (unless
- (and p (processp p) (memq (process-status p) '(run open))
- (or argument
- (string-equal
- share
- (tramp-get-connection-property p "smb-share" ""))))
+ (unless (and (tramp-compat-process-live-p p)
+ (or argument
+ (string-equal
+ share
+ (tramp-get-connection-property p "smb-share" ""))))
(save-match-data
;; There might be unread output from checking for share names.
@@ -1878,7 +1891,7 @@ If ARGUMENT is non-nil, use it as argument for
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
(tramp-set-connection-property p "vector" vec)
- (tramp-compat-set-process-query-on-exit-flag p nil)
+ (set-process-query-on-exit-flag p nil)
;; Set variables for computing the prompt for reading password.
(setq tramp-current-method tramp-smb-method
@@ -1916,6 +1929,9 @@ If ARGUMENT is non-nil, use it as argument for
(tramp-set-connection-property p "smb-share" share)
(tramp-set-connection-property p "chunksize" 1)
+ ;; Set connection-local variables.
+ (tramp-set-connection-local-variables vec)
+
;; Mark it as connected.
(tramp-set-connection-property p "connected" t))
@@ -1954,7 +1970,7 @@ Returns nil if an error message has appeared."
;; Algorithm: get waiting output. See if last line contains
;; `tramp-smb-prompt' sentinel or `tramp-smb-errors' strings.
;; If not, wait a bit and again get waiting output.
- (while (and (not found) (not err) (memq (process-status p) '(run open)))
+ (while (and (not found) (not err) (tramp-compat-process-live-p p))
;; Accept pending output.
(tramp-accept-process-output p 0.1)
@@ -1968,7 +1984,7 @@ Returns nil if an error message has appeared."
(setq err (re-search-forward tramp-smb-errors nil t)))
;; When the process is still alive, read pending output.
- (while (and (not found) (memq (process-status p) '(run open)))
+ (while (and (not found) (tramp-compat-process-live-p p))
;; Accept pending output.
(tramp-accept-process-output p 0.1)
@@ -1992,7 +2008,7 @@ Returns nil if an error message has appeared."
"Send SIGKILL to the winexe process."
(ignore-errors
(let ((p (get-buffer-process (current-buffer))))
- (when (and p (processp p) (memq (process-status p) '(run open)))
+ (when (tramp-compat-process-live-p p)
(signal-process (process-id p) 'SIGINT)))))
(defun tramp-smb-call-winexe (vec)
@@ -2031,7 +2047,7 @@ Returns nil if an error message has appeared."
(defun tramp-smb-shell-quote-argument (s)
"Similar to `shell-quote-argument', but uses windows cmd syntax."
(let ((system-type 'ms-dos))
- (shell-quote-argument s)))
+ (tramp-unquote-shell-quote-argument s)))
(add-hook 'tramp-unload-hook
(lambda ()
@@ -2042,8 +2058,10 @@ Returns nil if an error message has appeared."
;;; TODO:
;; * Return more comprehensive file permission string.
+;;
;; * Try to remove the inclusion of dummy "" directory. Seems to be at
;; several places, especially in `tramp-smb-handle-insert-directory'.
+;;
;; * Ignore case in file names.
;;; tramp-smb.el ends here