emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in `get-free-disk-space'


From: Ehud Karni
Subject: Bug in `get-free-disk-space'
Date: Sun, 5 Sep 2010 18:00:54 +0300

When the mount name has a space or `directory-free-space-args' is set
to "-h" (human readable format), `get-free-disk-space' in lisp/files.el
gives wrong results:

example of `df -h' with spaces in the mount name:

Filesystem            Size  Used Avail Use% Mounted on
/dev/md/d0p2          2.7T  1.7T  1.1T  61% /RAID
//dc-2000-xp/ehuds D  172G  169G  2.8G  99% /ehuds/D
//dc-2000-xp/ehuds U - Gibuy
                      233G  228G  5.2G  98% /ehuds/U

The patch bellow (against trunc/lisp/files.el) fix this problem and
adds units to the use and available values.

Ehud.


diff -c /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el-org 
/f-s/gnu/src/emacs-bzr/trunk/lisp/files.el
*** /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el-org      Wed Sep  1 18:47:47 2010
--- /f-s/gnu/src/emacs-bzr/trunk/lisp/files.el  Sun Sep  5 15:52:28 2010
***************
*** 5594,5606 ****
            (forward-line 1)
            (if (not (eobp))
                (progn
!                 ;; Move to the end of the "available blocks" number.
!                 (skip-chars-forward "^ \t")
!                 (forward-word 3)
!                 ;; Copy it into AVAILABLE.
                  (let ((end (point)))
!                   (forward-word -1)
!                   (buffer-substring (point) end))))))))))

  ;; The following expression replaces `dired-move-to-filename-regexp'.
  (defvar directory-listing-before-filename-regexp
--- 5594,5613 ----
            (forward-line 1)
            (if (not (eobp))
                (progn
!
! ;;  example of `df -h' with spaces in the mount name
! ;;  Filesystem            Size  Used Avail Use% Mounted on
! ;;  /dev/md/d0p2          2.7T  1.7T  1.1T  61% /RAID
! ;;  //dc-2000-xp/ehuds D  172G  169G  2.8G  99% /ehuds/D
! ;;  //dc-2000-xp/ehuds U - Gibuy
! ;;                        233G  228G  5.2G  98% /ehuds/U
!                 ;; use the % as an anchor
!                 (search-forward "%")
!                 (skip-chars-backward "%[0-9]")
!                 (skip-chars-backward " ")
                  (let ((end (point)))
!                    (skip-chars-backward ".[0-9][A-Z]")
!                    (buffer-substring (point) end))))))))))

  ;; The following expression replaces `dired-move-to-filename-regexp'.
  (defvar directory-listing-before-filename-regexp
***************
*** 5936,5942 ****
                      ;; Replace "total" with "used", to avoid confusion.
                      (replace-match "total used in directory" nil nil nil 1)
                      (end-of-line)
!                     (insert " available " available))))))))))

  (defun insert-directory-adj-pos (pos error-lines)
    "Convert `ls --dired' file name position value POS to a buffer position.
--- 5943,5952 ----
                      ;; Replace "total" with "used", to avoid confusion.
                      (replace-match "total used in directory" nil nil nil 1)
                      (end-of-line)
!                     (insert " KB, available " available
!                             (if (string-match "[A-Z]" available) ""
!                                 (if (string-match "m" 
directory-free-space-args)
!                                     " MB" " KB"))))))))))))

  (defun insert-directory-adj-pos (pos error-lines)
    "Convert `ls --dired' file name position value POS to a buffer position.



--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7976-561  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry



reply via email to

[Prev in Thread] Current Thread [Next in Thread]