From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: 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 Organization: ThierryVolpiatto Message-ID: <87hbhq97h0.fsf@tux.homenetwork> References: <87d3sp5olh.fsf@tux.homenetwork> <83aanm5dyk.fsf@gnu.org> <87pqwh3hiu.fsf@tux.homenetwork> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1284577849 7750 80.91.229.12 (15 Sep 2010 19:10:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 15 Sep 2010 19:10:49 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 15 21:10:48 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OvxNU-00083f-PE for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Sep 2010 21:10:45 +0200 Original-Received: from localhost ([127.0.0.1]:41616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvxNU-0005hX-21 for geb-bug-gnu-emacs@m.gmane.org; Wed, 15 Sep 2010 15:10:44 -0400 Original-Received: from [140.186.70.92] (port=33964 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvxNM-0005fF-7R for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 15:10:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvxNL-0002QO-6l for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 15:10:36 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46541) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvxNL-0002QI-47 for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 15:10:35 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Ovwtm-0004gF-Oc; Wed, 15 Sep 2010 14:40:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87d3sp5olh.fsf@tux.homenetwork> Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 15 Sep 2010 18:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6995 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.128457598117981 (code B ref -1); Wed, 15 Sep 2010 18:40:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Sep 2010 18:39:41 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvwtR-0004fy-85 for submit@debbugs.gnu.org; Wed, 15 Sep 2010 14:39:41 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvwtO-0004ft-Rv for submit@debbugs.gnu.org; Wed, 15 Sep 2010 14:39:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvwvX-0006Db-LA for submit@debbugs.gnu.org; Wed, 15 Sep 2010 14:41:56 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:60963) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvwvW-0006DA-WD for submit@debbugs.gnu.org; Wed, 15 Sep 2010 14:41:51 -0400 Original-Received: from [140.186.70.92] (port=56494 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OvwvS-0005o8-Ta for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 14:41:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OvwvR-0006Ca-1Y for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 14:41:46 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:58417) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OvwvQ-0006CP-Jr for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 14:41:45 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1OvwvN-0000s3-OK for bug-gnu-emacs@gnu.org; Wed, 15 Sep 2010 20:41:41 +0200 Original-Received: from 2.77.197-77.rev.gaoland.net ([77.197.77.2]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Sep 2010 20:41:41 +0200 Original-Received: from thierry.volpiatto by 2.77.197-77.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 15 Sep 2010 20:41:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 80 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 2.77.197-77.rev.gaoland.net User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:bb4oUXK5uKaxI26VVzN6+3CIzsk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Wed, 15 Sep 2010 14:40:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40185 Archived-At: Thierry Volpiatto writes: > Stefan Monnier 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