aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2012-02-07 19:44:36 +0200
committerEli Zaretskii2012-02-07 19:44:36 +0200
commit5e0d957fe021bc921bfa4f7568f5501c43ca7fc5 (patch)
treeb6ae71512ffd4615522638a619445d0d050f9ef2
parent98d7371e7a9568f51aa016ec2cbee7d56ff1ad50 (diff)
downloademacs-5e0d957fe021bc921bfa4f7568f5501c43ca7fc5.tar.gz
emacs-5e0d957fe021bc921bfa4f7568f5501c43ca7fc5.zip
Fix bug #4673 with Dired when `stat' fails for ".." or other files.
lisp/ls-lisp.el (ls-lisp-sanitize): New function. (ls-lisp-insert-directory): Use it to fix or remove any elements in file-alist with missing attributes.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/ls-lisp.el17
2 files changed, 23 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 60ececebe26..2ac59b16494 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12012-02-07 Eli Zaretskii <eliz@gnu.org>
2
3 * ls-lisp.el (ls-lisp-sanitize): New function.
4 (ls-lisp-insert-directory): Use it to fix or remove any elements
5 in file-alist with missing attributes. (Bug#4673)
6
12012-02-07 Alan Mackenzie <acm@muc.de> 72012-02-07 Alan Mackenzie <acm@muc.de>
2 8
3 Fix spurious recognition of c-in-knr-argdecl. 9 Fix spurious recognition of c-in-knr-argdecl.
diff --git a/lisp/ls-lisp.el b/lisp/ls-lisp.el
index 576c746761d..de489871887 100644
--- a/lisp/ls-lisp.el
+++ b/lisp/ls-lisp.el
@@ -331,6 +331,7 @@ not contain `d', so that a full listing is expected."
331 ;; do all bindings here for speed 331 ;; do all bindings here for speed
332 total-line files elt short file-size attr 332 total-line files elt short file-size attr
333 fuid fgid uid-len gid-len) 333 fuid fgid uid-len gid-len)
334 (setq file-alist (ls-lisp-sanitize file-alist))
334 (cond ((memq ?A switches) 335 (cond ((memq ?A switches)
335 (setq file-alist 336 (setq file-alist
336 (ls-lisp-delete-matching "^\\.\\.?$" file-alist))) 337 (ls-lisp-delete-matching "^\\.\\.?$" file-alist)))
@@ -437,6 +438,22 @@ not contain `d', so that a full listing is expected."
437 (message "%s: doesn't exist or is inaccessible" file) 438 (message "%s: doesn't exist or is inaccessible" file)
438 (ding) (sit-for 2))))) ; to show user the message! 439 (ding) (sit-for 2))))) ; to show user the message!
439 440
441(defun ls-lisp-sanitize (file-alist)
442 "Sanitize the elements in FILE-ALIST.
443Fixes any elements in the alist for directory entries whose file
444attributes are nil (meaning that `file-attributes' failed for
445them). This is known to happen for some network shares, in
446particular for the \"..\" directory entry.
447
448If the \"..\" directory entry has nil attributes, the attributes
449are copied from the \".\" entry, if they are non-nil. Otherwise,
450the offending element is removed from the list, as are any
451elements for other directory entries with nil attributes."
452 (if (and (null (cdr (assoc ".." file-alist)))
453 (cdr (assoc "." file-alist)))
454 (setcdr (assoc ".." file-alist) (cdr (assoc "." file-alist))))
455 (rassq-delete-all nil file-alist))
456
440(defun ls-lisp-column-format (file-alist) 457(defun ls-lisp-column-format (file-alist)
441 "Insert the file names (only) in FILE-ALIST into the current buffer. 458 "Insert the file names (only) in FILE-ALIST into the current buffer.
442Format in columns, sorted vertically, following GNU ls -C. 459Format in columns, sorted vertically, following GNU ls -C.