GNU bug report logs -
#2631
get-free-disk-space when home dir also doesn't exist
Previous Next
Reported by: Kevin Ryde <user42 <at> zip.com.au>
Date: Tue, 10 Mar 2009 22:30:03 UTC
Severity: normal
Tags: patch
Merged with 3911
Done: Chong Yidong <cyd <at> stupidchicken.com>
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 2631 in the body.
You can then email your comments to 2631 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Tue, 10 Mar 2009 22:30:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
New bug report received and forwarded. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Tue, 10 Mar 2009 22:30:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
Evaluating
(with-temp-buffer
(setq default-directory "/no/such/dir")
(get-free-disk-space "/tmp"))
gets an error
(file-error "Setting current directory" "no such file or directory" "/no/such/dir")
where I hoped it wouldn't care about default-directory, only the given
directory argument. Perhaps a let-bind per below.
In GNU Emacs 22.2.1 (i486-pc-linux-gnu, GTK+ Version 2.12.11)
of 2008-11-10 on raven, modified by Debian
configured using `configure '--build=i486-linux-gnu' '--host=i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs22:/etc/emacs:/usr/local/share/emacs/22.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/22.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/22.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: en_AU
locale-coding-system: iso-8859-1
default-enable-multibyte-characters: t
[files.el.free-space.diff (text/x-diff, inline)]
*** files.el 11 Mar 2009 08:46:04 +1100 1.1038
--- files.el 11 Mar 2009 09:14:14 +1100
***************
*** 5336,5345 ****
(save-match-data
(with-temp-buffer
(when (and directory-free-space-program
! (eq 0 (call-process directory-free-space-program
! nil t nil
! directory-free-space-args
! dir)))
;; Usual format is a header line followed by a line of
;; numbers.
(goto-char (point-min))
--- 5336,5346 ----
(save-match-data
(with-temp-buffer
(when (and directory-free-space-program
! (let ((default-directory "/"))
! (eq 0 (call-process directory-free-space-program
! nil t nil
! directory-free-space-args
! dir))))
;; Usual format is a header line followed by a line of
;; numbers.
(goto-char (point-min))
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Wed, 11 Mar 2009 02:15:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 11 Mar 2009 02:15:03 GMT)
Full text and
rfc822 format available.
Message #10 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):
> *** files.el 11 Mar 2009 08:46:04 +1100 1.1038
> --- files.el 11 Mar 2009 09:14:14 +1100
> ***************
> *** 5336,5345 ****
> (save-match-data
> (with-temp-buffer
> (when (and directory-free-space-program
> ! (eq 0 (call-process directory-free-space-program
> ! nil t nil
> ! directory-free-space-args
> ! dir)))
> ;; Usual format is a header line followed by a line of
> ;; numbers.
> (goto-char (point-min))
> --- 5336,5346 ----
> (save-match-data
> (with-temp-buffer
> (when (and directory-free-space-program
> ! (let ((default-directory "/"))
> ! (eq 0 (call-process directory-free-space-program
> ! nil t nil
> ! directory-free-space-args
> ! dir))))
> ;; Usual format is a header line followed by a line of
> ;; numbers.
> (goto-char (point-min))
That would probably work OK, but why not bind default-directory to dir?
And even use process-file, while we're at it, so it has a chance to work
on Tramp.
Stefan
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Wed, 11 Mar 2009 02:15:06 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Stefan Monnier <monnier <at> iro.umontreal.ca>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 11 Mar 2009 02:15:06 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Wed, 11 Mar 2009 04:30:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 11 Mar 2009 04:30:05 GMT)
Full text and
rfc822 format available.
Message #20 received at 2631 <at> emacsbugs.donarmstrong.com (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Tue, 10 Mar 2009 22:10:13 -0400
> Cc: bug-gnu-emacs <at> gnu.org, 2631 <at> emacsbugs.donarmstrong.com
>
> > *** files.el 11 Mar 2009 08:46:04 +1100 1.1038
> > --- files.el 11 Mar 2009 09:14:14 +1100
> > ***************
> > *** 5336,5345 ****
> > (save-match-data
> > (with-temp-buffer
> > (when (and directory-free-space-program
> > ! (eq 0 (call-process directory-free-space-program
> > ! nil t nil
> > ! directory-free-space-args
> > ! dir)))
> > ;; Usual format is a header line followed by a line of
> > ;; numbers.
> > (goto-char (point-min))
> > --- 5336,5346 ----
> > (save-match-data
> > (with-temp-buffer
> > (when (and directory-free-space-program
> > ! (let ((default-directory "/"))
> > ! (eq 0 (call-process directory-free-space-program
> > ! nil t nil
> > ! directory-free-space-args
> > ! dir))))
> > ;; Usual format is a header line followed by a line of
> > ;; numbers.
> > (goto-char (point-min))
>
> That would probably work OK, but why not bind default-directory to dir?
Yes, this is much better, since "/" is not guaranteed to work
(accessibility and stuff).
> And even use process-file, while we're at it, so it has a chance to work
> on Tramp.
Even better.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Wed, 11 Mar 2009 21:10:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Wed, 11 Mar 2009 21:10:05 GMT)
Full text and
rfc822 format available.
Message #25 received at 2631 <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:
>
> why not bind default-directory to dir?
I think that'd make it error out on a non-existant dir argument, where
currently it returns nil (from the df parsing code, and it looks like
from file-system-info in dosfns.c).
There's a few other places binding to "/", like man.el and message.el,
if it ought to be something else ...
Reply sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
You have taken responsibility.
(Sun, 15 Mar 2009 02:40:05 GMT)
Full text and
rfc822 format available.
Notification sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
bug acknowledged by developer.
(Sun, 15 Mar 2009 02:40:05 GMT)
Full text and
rfc822 format available.
Message #30 received at 2631-done <at> emacsbugs.donarmstrong.com (full text, mbox):
Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
> That would probably work OK, but why not bind default-directory to
> dir? And even use process-file, while we're at it, so it has a chance
> to work on Tramp.
I don't think there's any chance to make get-free-disk-space to work on
remote files without major surgery (it currently returns nil immediately
if the file is remote).
I've checked in a modified version of Kevin's patch, which sets
default-directory to "~/" rather than "/", but only if the existing
default-directory is not usable.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Tue, 17 Mar 2009 00:10:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Tue, 17 Mar 2009 00:10:05 GMT)
Full text and
rfc822 format available.
Message #35 received at 2631 <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
Chong Yidong <cyd <at> stupidchicken.com> writes:
>
> default-directory to "~/" rather than "/"
What is it that's not good about "/"? It doesn't have to be readable or
anything I don't think, just somewhere capable of a chdir(). Wouldn't
it be the only thing certain to work with chdir()? As I mentioned
before there's other places using "/" for the same purpose if there's
something wrong with it.
Either way what I missed from my first post was that a change to
default-directory ought to absolutize the given dir argument, so that
say
(get-free-disk-space ".")
gives info about the original default-directory, not the mangled one.
[files.el.disk-space-expand.diff (text/x-diff, inline)]
*** files.el 17 Mar 2009 10:35:50 +1100 1.1040
--- files.el 17 Mar 2009 10:53:40 +1100
***************
*** 5341,5346 ****
--- 5341,5347 ----
(file-directory-p default-directory)
(file-readable-p default-directory))
default-directory
+ (setq dir (expand-file-name dir))
(expand-file-name "~/"))))
(eq (call-process directory-free-space-program
nil t nil
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Tue, 17 Mar 2009 04:15:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Eli Zaretskii <eliz <at> gnu.org>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Tue, 17 Mar 2009 04:15:05 GMT)
Full text and
rfc822 format available.
Message #40 received at 2631 <at> emacsbugs.donarmstrong.com (full text, mbox):
> From: Kevin Ryde <user42 <at> zip.com.au>
> Date: Tue, 17 Mar 2009 11:02:26 +1100
> Cc: 2631 <at> emacsbugs.donarmstrong.com
>
> > default-directory to "~/" rather than "/"
>
> What is it that's not good about "/"? It doesn't have to be readable or
> anything I don't think, just somewhere capable of a chdir().
Doesn't chdir need certain rights? what if the user doesn't have them?
> Either way what I missed from my first post was that a change to
> default-directory ought to absolutize the given dir argument, so that
> say
>
> (get-free-disk-space ".")
>
> gives info about the original default-directory, not the mangled one.
What "mangled one"?
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Fri, 27 Mar 2009 23:25:05 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 27 Mar 2009 23:25:05 GMT)
Full text and
rfc822 format available.
Message #45 received at 2631 <at> emacsbugs.donarmstrong.com (full text, mbox):
[Message part 1 (text/plain, inline)]
reopen 2631
retitle 2631 get-free-disk-space when home dir also doesn't exist
tags 2631 +patch
thanks
If both default-directory and home directory both don't exist
get-free-disk-space still gets an error
(progn
(setq default-directory "/no/such/dir")
(setenv "HOME" "/another/no/such/dir")
(get-free-disk-space "/"))
=> (file-error "Setting current directory" "no such file or directory" "/another/no/such/dir/")
Although plenty of things probably depend on a home dir I don't think
get-free-disk-space needs to be one of them.
Change below is like what's also in the following funcs, I believe for
the same purpose, ie. just to make sure call-process will be happy, when
the program run doesn't care about the current directory.
Man-init-defvars,
mail-source-movemail
message-send-mail-with-sendmail
sendmail-send-it
gamegrid-add-score-with-update-game-score-1
[files.el.disk-space-root.diff (text/x-diff, inline)]
*** files.el 28 Mar 2009 09:50:47 +1100 1.1041
--- files.el 28 Mar 2009 09:56:48 +1100
***************
*** 5336,5352 ****
(save-match-data
(with-temp-buffer
(when (and directory-free-space-program
! (let ((default-directory
! (if (and (not (file-remote-p default-directory))
! (file-directory-p default-directory)
! (file-readable-p default-directory))
! default-directory
! (expand-file-name "~/"))))
! (eq (call-process directory-free-space-program
! nil t nil
! directory-free-space-args
! dir)
! 0)))
;; Usual format is a header line followed by a line of
;; numbers.
(goto-char (point-min))
--- 5336,5349 ----
(save-match-data
(with-temp-buffer
(when (and directory-free-space-program
! (progn
! (setq dir (expand-file-name dir)) ;; in case relative
! (let ((default-directory "/"))
! (eq (call-process directory-free-space-program
! nil t nil
! directory-free-space-args
! dir)
! 0))))
;; Usual format is a header line followed by a line of
;; numbers.
(goto-char (point-min))
bug reopened, originator not changed.
Request was from
Kevin Ryde <user42 <at> zip.com.au>
to
control <at> emacsbugs.donarmstrong.com
.
(Fri, 27 Mar 2009 23:25:06 GMT)
Full text and
rfc822 format available.
Changed bug title to `get-free-disk-space when home dir also doesn't exist' from `get-free-disk-space when default-directory doesn't exist'.
Request was from
Kevin Ryde <user42 <at> zip.com.au>
to
control <at> emacsbugs.donarmstrong.com
.
(Fri, 27 Mar 2009 23:25:06 GMT)
Full text and
rfc822 format available.
Tags added: patch
Request was from
Kevin Ryde <user42 <at> zip.com.au>
to
control <at> emacsbugs.donarmstrong.com
.
(Fri, 27 Mar 2009 23:25:06 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>
:
bug#2631
; Package
emacs
.
(Fri, 27 Mar 2009 23:40:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
Extra info received and forwarded to list. Copy sent to
Emacs Bugs <bug-gnu-emacs <at> gnu.org>
.
(Fri, 27 Mar 2009 23:40:04 GMT)
Full text and
rfc822 format available.
Message #56 received at 2631 <at> emacsbugs.donarmstrong.com (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>
> Doesn't chdir need certain rights?
Only search perms in the parent directories leading to a given dir, I
believe.
I suppose the root dir could be unreadable/unsearchable too. Dunno what
chdir would do in that case (I'm not brave enough to try it either!) but
certainly if the root dir is unsearchable then no subdir can work.
Reply sent
to
Chong Yidong <cyd <at> stupidchicken.com>
:
You have taken responsibility.
(Sun, 16 Aug 2009 00:40:11 GMT)
Full text and
rfc822 format available.
Notification sent
to
Kevin Ryde <user42 <at> zip.com.au>
:
bug acknowledged by developer.
(Sun, 16 Aug 2009 00:40:12 GMT)
Full text and
rfc822 format available.
Message #61 received at 2631-done <at> emacsbugs.donarmstrong.com (full text, mbox):
> What is it that's not good about "/"? It doesn't have to be readable
> or anything I don't think, just somewhere capable of a chdir()... If
> both default-directory and home directory both don't exist
> get-free-disk-space still gets an error
You're right; it's probably better to fall back on / instead of ~. I've
just checked in your suggested change.
> (let ((default-directory "/no/such/dir"))
> (get-free-disk-space "."))
> => 3705637
I checked in your suggestion to do expand-file-name before changing the
default-directory, as well. Thanks.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> emacsbugs.donarmstrong.com
.
(Sun, 13 Sep 2009 14:24:12 GMT)
Full text and
rfc822 format available.
bug unarchived.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 04 Mar 2011 09:22:01 GMT)
Full text and
rfc822 format available.
Merged 2631 3911.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 04 Mar 2011 09:22:02 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
.
(Fri, 01 Apr 2011 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 14 years and 84 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.