GNU bug report logs - #6995
24.0.50; get-free-disk-space doesn't return available space in dired

Previous Next

Package: emacs;

Reported by: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>

Date: Tue, 7 Sep 2010 20:01:02 UTC

Severity: normal

Found in version 24.0.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6995 in the body.
You can then email your comments to 6995 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Tue, 07 Sep 2010 20:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thierry Volpiatto <thierry.volpiatto <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 07 Sep 2010 20:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; get-free-disk-space doesn't return available space in dired
Date: Tue, 07 Sep 2010 21:40:42 +0200
Hi,
The version of get-free-disk-space doesn't show available space in
dired, please fix it or revert to 23.2 version.

Actually it show:
total 10120

instead of:
total used in directory 9,9M available 24G

BTW the bug i sent long time ago (with a patch) about insert-directory
that doesn't show correctly available space when using h option of ls
is still not fixed.
e.g it should show something like:

total used in directory 9,9M available 24G
                                       ^^^


In GNU Emacs 24.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2010-09-07 on tux
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
configured using `configure  '--prefix=/usr' '--build=i686-pc-linux-gnu' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' '--sysconfdir=/etc' '--localstatedir=/var/lib' '--program-suffix=-emacs-24' '--infodir=/usr/share/info/emacs-24' '--with-crt-dir=/usr/lib' '--without-compress-info' '--with-sound' '--with-x' '--without-gconf' '--without-toolkit-scroll-bars' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xpm' '--without-imagemagick' '--with-xft' '--without-libotf' '--without-m17n-flt' '--with-x-toolkit=gtk' '--without-hesiod' '--without-kerberos' '--without-kerberos5' '--with-gpm' '--with-dbus' 'build_alias=i686-pc-linux-gnu' 'host_alias=i686-pc-linux-gnu' 'CFLAGS=-march=i686 -pipe -O2' 'LDFLAGS=-Wl,-O1 -Wl,--as-needed''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: fr_FR.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: fr_FR.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  global-undo-tree-mode: t
  undo-tree-mode: t
  eldoc-mode: t
  minibuffer-depth-indicate-mode: t
  auto-image-file-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  display-time-mode: t
  diff-auto-refine-mode: t
  recentf-mode: t
  savehist-mode: t
  desktop-save-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-< <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> C-x C-f C-. 
C-. <return> <f11> s c C-x C-f C-j C-x C-b <down> <down> 
<down> <C-tab> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <right> 
<right> <right> <right> <right> <right> <right> C-SPC 
C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f 
C-f C-f C-f C-f C-f C-f M-w M-x r e p o r t <down> 
<return>

Recent messages:
Desktop lazily opening my-blog.org (2 remaining)...done
Desktop lazily opening notes.org (1 remaining)...
OVERVIEW
Desktop lazily opening notes.org (1 remaining)...done
Lazy desktop load complete
Auto-saving...done
Collecting symbols...done
 [3 times]
Mark set


Load-path shadows:
/home/thierry/elisp/AC/auto-complete hides /home/thierry/elisp/auto-complete
/home/thierry/elisp/subversion/psvn hides /usr/share/emacs/site-lisp/subversion/psvn
~/elisp/g-client/json hides /usr/share/emacs/24.0.50/lisp/json
/usr/share/emacs/site-lisp/flim/hex-util hides /usr/share/emacs/24.0.50/lisp/hex-util
/usr/share/emacs/site-lisp/flim/sha1 hides /usr/share/emacs/24.0.50/lisp/sha1
/usr/share/emacs/site-lisp/flim/md4 hides /usr/share/emacs/24.0.50/lisp/md4
/usr/share/emacs/site-lisp/flim/ntlm hides /usr/share/emacs/24.0.50/lisp/net/ntlm
/usr/share/emacs/site-lisp/flim/hmac-def hides /usr/share/emacs/24.0.50/lisp/net/hmac-def
/usr/share/emacs/site-lisp/flim/sasl-digest hides /usr/share/emacs/24.0.50/lisp/net/sasl-digest
/usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/24.0.50/lisp/net/sasl
/usr/share/emacs/site-lisp/flim/hmac-md5 hides /usr/share/emacs/24.0.50/lisp/net/hmac-md5
/usr/share/emacs/site-lisp/flim/sasl-cram hides /usr/share/emacs/24.0.50/lisp/net/sasl-cram
/usr/share/emacs/site-lisp/flim/sasl-ntlm hides /usr/share/emacs/24.0.50/lisp/net/sasl-ntlm
/home/thierry/elisp/emms/lisp/tq hides /usr/share/emacs/24.0.50/lisp/emacs-lisp/tq

Features:
(shadow gnus-cite gnus-demon gnus-namazu gnus-dired nnshimbun shimbun
luna eword-encode eword-decode std11 mel path-util mime-def mcharset
mcs-20 mcs-e20 pces pces-e20 pces-20 broken pcustom poe gnus-bcklg spam
spam-stat bbdb-com bbdb gnus-uu yenc gnus-alias mail-extr gnus-msg
emacsbug xhg-dvc xhg xhg-annotate xhg-mq xhg-log vc-rcs align-let server
finder-inf package google-maps google-maps-static google-maps-geocode
google-maps-base json simple-call-tree el-expectations el-mock csv2org
iedit eieio-base eieio zop-to-char elscreen-server elscreen-dired
elscreen-w3m mule-util alist pym static apel-ver product elscreen
undo-tree smallurl mm-url xml-weather rectangle-utils auto-document eiv
tv-utils eldoc pcvs pcvs-parse pcvs-info pcvs-defs init-anything-thierry
descbinds-anything anything-ipython shell-history anything-complete
anything-show-completion anything-etags anything-match-plugin etags
anything-traverse anything-delicious anything-mercurial
addressbook-bookmark bzr-core cg-core xdarcs-core xgit-core xhg-core
xmtn-minimal tla smerge-mode dvc-state dvc-config dvc-diff dvc-fileinfo
diff dvc-cmenu dvc-about dvc-version dvc-revlist uniquify
anything-config w3m-bookmark rx anything firefox-protocol
bookmark-firefox-handler bookmark-extensions bookmark install-elisp
find-func mb-depth autodoc ioccur traverselisp thumb-page moz cl-info
slime-xref-browser slime-banner slime-tramp slime-asdf slime-fancy
slime-fontifying-fu slime-package-fu slime-references slime-scratch
slime-presentations slime-fuzzy slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc slime-parse slime-repl slime
apropos hideshow hyperspec thingatpt slime-autoloads boxquote rect
image-file tramp-imap tramp-gw tramp-fish tramp-smb tramp-cache
tramp-ftp tramp-cmds tramp tramp-compat trampver newsticker
newst-treeview newst-plainview newst-reader newst-ticker newst-backend
ledger pcomplete esh-arg esh-util lpr woman man assoc two-column
shell-command em-term term ehelp electric esh-toggle em-xtra flymake
pdbtrack pycomplete pymacs ipython python-mode info-look ansi-color
executable shell no-word regex-tool whitespace htmlfontify paren time
dired-tar compile dired-extension image-dired dired-details yaoddmuse
skeleton sgml-mode emms-mpd-config emms-playlist-limit emms-volume
emms-volume-amixer emms-i18n emms-history emms-score emms-stream-info
emms-metaplaylist-mode emms-bookmarks emms-lastfm-client xml parse-time
emms-cue emms-mode-line-icon emms-browser sort emms-playlist-sort
emms-last-played emms-player-xine emms-player-mpd tq emms-playing-time
emms-lyrics emms-url hl-line emms-tag-editor emms-mark emms-mode-line
emms-cache emms-info-ogginfo emms-info-mp3info emms-playlist-mode
emms-player-vlc emms-player-mplayer emms-info emms-streams later-do
emms-source-playlist emms-source-file emms-player-simple emms-setup emms
emms-compat winner dvc-init bzr-gnus tla-gnus xgit-gnus xhg-gnus
gnus-art mm-uu mml2015 mm-view smime password-cache dig dvc-gnus
tla-core pp tla-autoconf tla-defs dvc-log vc vc-dispatcher dvc-unified
dvc-tips dired-x dired-aux ffap ediff-merg ediff-diff ediff-wind
ediff-help ediff-util ediff-mult ediff-init ediff dvc-autoloads dvc-core
dvc-lisp dvc-buffers dvc-ui dvc-register dvc-utils dvc-emacs ewoc
dvc-defs dvc-site psvn log-edit pcvs-util add-log diff-mode htmlize-hack
htmlize muse-colors muse-docbook muse-texinfo texnfo-upd texinfo
muse-latex muse-html muse-xml-common muse-wiki cus-edit cus-start
cus-load muse-publish muse-project muse-protocols muse-regexps muse
muse-nested-tags muse-mode muse-autoloads org-config-thierry org-crypt
cal-china lunar solar cal-dst cal-bahai cal-islam cal-hebrew holidays
hol-loaddefs vc-hg org-wl org-w3m org-vm org-rmail org-mhe org-mew
org-irc org-jsinfo org-infojs org-html org-exp ob-exp org-exp-blocks
org-info org-gnus org-docview org-bibtex org-bbdb org-agenda appt
diary-lib diary-loaddefs org-annotation-helper url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-util url-parse
url-vars mailcap org-capture org-mks remember org-remember org-datetree
org byte-opt warnings bytecomp byte-compile ob-emacs-lisp ob-keys
ob-comint comint ring ob-tangle ob-ref ob-lob ob-table ob org-footnote
org-src org-list org-faces org-compat org-entities org-macs noutline
outline cal-menu calendar cal-loaddefs config-w3m w3m browse-url
doc-view jka-compr image-mode timezone w3m-hist w3m-fb w3m-ems w3m-ccl
ccl w3m-favicon w3m-image w3m-proc w3m-util mime-w3m w3m-load recentf
tree-widget savehist epa-file epa derived epg epg-config auth-source
dired gnus-async nntp gnus-sum nnoo gnus-group time-date gnus-undo
nnmail mail-source format-spec gnus-start gnus-spec gnus-int gnus-range
message sendmail regexp-opt rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader gnus-win gnus gnus-ems nnheader gnus-util
mail-utils mm-util mail-prsvr wid-edit info easymenu usage-memo desktop
punycode idna basic-theme edmacro kmacro eev-thierry iterator eev-all
eev-mini-steps eev-browse-url eev-langs eev-compose eev-glyphs
disp-table eev-insert eev-steps eev-bounded eev easy-mmode advice
help-fns advice-preload cl cl-19 site-gentoo w3m-wget preview-latex
tex-site auto-loads tooltip ediff-hook vc-hooks lisp-float-type mwheel
x-win x-dnd tool-bar dnd fontset image fringe lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

-- 
Thierry Volpiatto
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Tue, 07 Sep 2010 20:35:02 GMT) Full text and rfc822 format available.

Message #8 received at 6995 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Cc: 6995 <at> debbugs.gnu.org
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Tue, 07 Sep 2010 16:36:01 -0400
Thierry Volpiatto wrote:

> The version of get-free-disk-space doesn't show available space in
> dired, please fix it or revert to 23.2 version.
>
> Actually it show:
> total 10120
>
> instead of:
> total used in directory 9,9M available 24G

Allow me to offer more details:

On my system, where my home directory is NFS mounted,

   df -Pk /home/user

returns

  Filesystem         1024-blocks      Used Available Capacity Mounted on
  /real_directory/home/user 461097104 333392304 127704800      73% /home/user

Because the filesystem name is long, the numerical values do not line
up with the column headings. The current code seems to assume that
they do line up. Thus, running dired on "~" gets wrong values for the
total size. 




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Mon, 13 Sep 2010 06:55:02 GMT) Full text and rfc822 format available.

Message #11 received at 6995 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 6995 <at> debbugs.gnu.org, thierry.volpiatto <at> gmail.com
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Mon, 13 Sep 2010 08:56:19 +0200
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Tue, 07 Sep 2010 16:36:01 -0400
> Cc: 6995 <at> debbugs.gnu.org
> 
>    df -Pk /home/user
> 
> returns
> 
>   Filesystem         1024-blocks      Used Available Capacity Mounted on
>   /real_directory/home/user 461097104 333392304 127704800      73% /home/user
> 
> Because the filesystem name is long, the numerical values do not line
> up with the column headings. The current code seems to assume that
> they do line up. Thus, running dired on "~" gets wrong values for the
> total size. 

How about dropping the use of `df', at least on GNU/Linux?  It's IMO
ridiculous to invoke an external program for a single system call.  I
know that this system call is notoriously non-portable, and that doing
in Emacs all that system-dependent stuff that `df' does is not a good
idea.  But at least on the most popular free system (and perhaps on a
few compatible ones) we could do it right without all that labor, and
gain stability and reliability that depending on `df' will never
achieve.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Mon, 13 Sep 2010 10:13:02 GMT) Full text and rfc822 format available.

Message #14 received at 6995 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Glenn Morris <rgm <at> gnu.org>, 6995 <at> debbugs.gnu.org,
	thierry.volpiatto <at> gmail.com
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Mon, 13 Sep 2010 12:14:56 +0200
> How about dropping the use of `df', at least on GNU/Linux?  It's IMO
> ridiculous to invoke an external program for a single system call.  I
> know that this system call is notoriously non-portable, and that doing
> in Emacs all that system-dependent stuff that `df' does is not a good
> idea.  But at least on the most popular free system (and perhaps on a
> few compatible ones) we could do it right without all that labor, and
> gain stability and reliability that depending on `df' will never
> achieve.

That would make a lot of sense, yes,


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Mon, 13 Sep 2010 13:23:02 GMT) Full text and rfc822 format available.

Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Mon, 13 Sep 2010 15:22:17 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> How about dropping the use of `df', at least on GNU/Linux?  It's IMO
>> ridiculous to invoke an external program for a single system call.  I
>> know that this system call is notoriously non-portable, and that doing
>> in Emacs all that system-dependent stuff that `df' does is not a good
>> idea.  But at least on the most popular free system (and perhaps on a
>> few compatible ones) we could do it right without all that labor, and
>> gain stability and reliability that depending on `df' will never
>> achieve.
>
> That would make a lot of sense, yes,

I agree too, but waiting such a change, you should rewrite
`get-free-disk-space' as it can't work correctly on the output of df.

,----
| 	    ;; Usual format is as follows:
| 	    ;; Filesystem ...    Used  Available  Capacity ...
| 	    ;; /dev/sda6  ...48106535   35481255  10669850 ...
| 	    (goto-char (point-min))
| 	    (when (re-search-forward " +Avail[^ \n]*"
`----

But usual format is not the same on all locales:
Here it is:

,----
| Sys. de fichiers    1024-blocs   Utilisé    Dispo. Capacité Monté sur
| /dev/sda7             48947688  21618816  24842416      47% /home
`----

So (re-search-forward " +Avail[^ \n]*" is not portable here.

I use this simplified version of get-free-disk-space if it can help:

,----
| (defun get-free-disk-space (dir)
|   (let* ((data   (with-temp-buffer
|                    (call-process directory-free-space-program
|                                  nil t nil
|                                  directory-free-space-args
|                                  dir)
|                    (split-string (buffer-string) "\n" t)))
|          (values (cdr (split-string (second data)))))
|     (nth 2 values)))
`----

Tough the version on 23.2 work also.

Note that the value of "total used in directory" is always wrong.
How do you get this value?

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Wed, 15 Sep 2010 18:40:02 GMT) Full text and rfc822 format available.

Message #20 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Wed, 15 Sep 2010 20:39:39 +0200
Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:

> Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
>>> How about dropping the use of `df', at least on GNU/Linux?  It's IMO
>>> ridiculous to invoke an external program for a single system call.  I
>>> know that this system call is notoriously non-portable, and that doing
>>> in Emacs all that system-dependent stuff that `df' does is not a good
>>> idea.  But at least on the most popular free system (and perhaps on a
>>> few compatible ones) we could do it right without all that labor, and
>>> gain stability and reliability that depending on `df' will never
>>> achieve.
>>
>> That would make a lot of sense, yes,
>
> I agree too, but waiting such a change, you should rewrite
> `get-free-disk-space' as it can't work correctly on the output of df.
>
> ,----
> | 	    ;; Usual format is as follows:
> | 	    ;; Filesystem ...    Used  Available  Capacity ...
> | 	    ;; /dev/sda6  ...48106535   35481255  10669850 ...
> | 	    (goto-char (point-min))
> | 	    (when (re-search-forward " +Avail[^ \n]*"
> `----
>
> But usual format is not the same on all locales:
> Here it is:
>
> ,----
> | Sys. de fichiers    1024-blocs   Utilisé    Dispo. Capacité Monté sur
> | /dev/sda7             48947688  21618816  24842416      47% /home
> `----
>
> So (re-search-forward " +Avail[^ \n]*" is not portable here.
>
> I use this simplified version of get-free-disk-space if it can help:
>
> ,----
> | (defun get-free-disk-space (dir)
> |   (let* ((data   (with-temp-buffer
> |                    (call-process directory-free-space-program
> |                                  nil t nil
> |                                  directory-free-space-args
> |                                  dir)
> |                    (split-string (buffer-string) "\n" t)))
> |          (values (cdr (split-string (second data)))))
> |     (nth 2 values)))
> `----

With the windows stuff and no call when remote:

(defun get-free-disk-space (dir)
  (unless (file-remote-p dir)
    ;; Try to find the number of free blocks.  Non-Posix systems don't
    ;; always have df, but might have an equivalent system call.
    (if (fboundp 'file-system-info)
	(let ((fsinfo (file-system-info dir)))
	  (if fsinfo
	      (format "%.0f" (/ (nth 2 fsinfo) 1024))))
        (when (executable-find directory-free-space-program)
          (let* ((data   (with-temp-buffer
                           (call-process directory-free-space-program
                                         nil t nil
                                         directory-free-space-args
                                         dir)
                           (split-string (buffer-string) "\n" t)))
                 (values (cdr (split-string (second data)))))
            (when data (nth 2 values)))))))


> Tough the version on 23.2 work also.
>
> Note that the value of "total used in directory" is always wrong.
> How do you get this value?

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Sat, 18 Sep 2010 13:55:01 GMT) Full text and rfc822 format available.

Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Sat, 18 Sep 2010 15:54:45 +0200
Thierry Volpiatto <thierry.volpiatto <at> gmail.com> writes:

> With the windows stuff and no call when remote:
>
> (defun get-free-disk-space (dir)
>   (unless (file-remote-p dir)
>     ;; Try to find the number of free blocks.  Non-Posix systems don't
>     ;; always have df, but might have an equivalent system call.
>     (if (fboundp 'file-system-info)
> 	(let ((fsinfo (file-system-info dir)))
> 	  (if fsinfo
> 	      (format "%.0f" (/ (nth 2 fsinfo) 1024))))
>         (when (executable-find directory-free-space-program)
>           (let* ((data   (with-temp-buffer
>                            (call-process directory-free-space-program
>                                          nil t nil
>                                          directory-free-space-args
>                                          dir)
>                            (split-string (buffer-string) "\n" t)))
>                  (values (cdr (split-string (second data)))))
>             (when data (nth 2 values)))))))
>

But may be it's better to have other infos from output of df available:

(defun get-free-disk-space (dir &optional human)
  (unless (file-remote-p dir)
    ;; That is for windows.
    (if (fboundp 'file-system-info)
	(let ((fsinfo (file-system-info dir)))
	  (if fsinfo
	      (format "%.0f" (/ (nth 2 fsinfo) 1024))))
        ;; And this is for Unix/GNULinux.
        (when (executable-find directory-free-space-program)
          (getf (tv-get-disk-info dir human) :available)))))

(defun tv-get-disk-info (dir &optional human)
  (let* (args    (if human
                     (concat directory-free-space-args "h")
                     directory-free-space-args)
         (data   (with-temp-buffer
                   (call-process directory-free-space-program
                                 nil t nil args dir)
                   (split-string (buffer-string) "\n" t)))
         (values (split-string (second data))))
    (loop for i in '(:device :blocks :used :available :capacity :mount-point)
       for j in values
       append (list i j))))

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Sat, 25 Sep 2010 20:15:04 GMT) Full text and rfc822 format available.

Message #26 received at 6995 <at> debbugs.gnu.org (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 6995 <at> debbugs.gnu.org, Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Sat, 25 Sep 2010 16:17:42 -0400
Glenn Morris <rgm <at> gnu.org> writes:

> Because the filesystem name is long, the numerical values do not line
> up with the column headings. The current code seems to assume that
> they do line up. Thus, running dired on "~" gets wrong values for the
> total size.

I've just checked in a change to use the "%" as an anchor for finding
the available space, instead of assuming the columns line up.  Patches
to avoid using `df' welcome...




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6995; Package emacs. (Mon, 27 Sep 2010 08:45:02 GMT) Full text and rfc822 format available.

Message #29 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thierry Volpiatto <thierry.volpiatto <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#6995: 24.0.50;
	get-free-disk-space doesn't return available space in dired
Date: Mon, 27 Sep 2010 10:37:14 +0200
Chong Yidong <cyd <at> stupidchicken.com> writes:

> Glenn Morris <rgm <at> gnu.org> writes:
>
>> Because the filesystem name is long, the numerical values do not line
>> up with the column headings. The current code seems to assume that
>> they do line up. Thus, running dired on "~" gets wrong values for the
>> total size.
>
> I've just checked in a change to use the "%" as an anchor for finding
> the available space, instead of assuming the columns line up.  Patches
> to avoid using `df' welcome...
I don't understand why you want to use regexp searching here...
But well, it work...and you can get only one info from the output of df.
Seem you didn't look at what i sent here...

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





bug closed, send any further explanations to Thierry Volpiatto <thierry.volpiatto <at> gmail.com> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 12 Oct 2010 00:34:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 09 Nov 2010 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 281 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.