GNU bug report logs - #6397
24.0.50; `make-directory' return value

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Thu, 10 Jun 2010 20:52:01 UTC

Severity: minor

Tags: fixed

Found in version 24.0.50

Fixed in version 24.1

Done: Lars Magne Ingebrigtsen <larsi <at> gnus.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 6397 in the body.
You can then email your comments to 6397 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#6397; Package emacs. (Thu, 10 Jun 2010 20:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Drew Adams" <drew.adams <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 10 Jun 2010 20:52:02 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: <bug-gnu-emacs <at> gnu.org>
Subject: 24.0.50; `make-directory' return value
Date: Thu, 10 Jun 2010 13:49:23 -0700
The doc for `make-directory' doesn't mention its return value, and the
code doesn't seem to do anything special about it.
 
I think it should return non-nil (e.g. the directory name) if the
creation succeeds and nil if it fails without error.  And that should be
documented.  Or if it always raises an error when it does not create a
directory, that's OK too, but that should then be documented.
 
Yes, you can always determine whether it succeeded by checking
`file-accessible-directory-p' or `file-exists-p' afterward (and
beforehand, and comparing), but reasonable creation functions let you
know whether they succeed.
 
 
 
In GNU Emacs 24.0.50.1 (i386-mingw-nt5.1.2600)
 of 2010-06-07 on 3249CTO
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4) --no-opt --cflags -Ic:/xpm/include'
 





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Fri, 11 Jun 2010 08:19:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 6397 <at> debbugs.gnu.org
Subject: Re: bug#6397: 24.0.50; `make-directory' return value
Date: Fri, 11 Jun 2010 11:12:51 +0300
> The doc for `make-directory' doesn't mention its return value, and the
> code doesn't seem to do anything special about it.

There is also a related bug#6363.

> I think it should return non-nil (e.g. the directory name) if the
> creation succeeds and nil if it fails without error.  And that should be
> documented.  Or if it always raises an error when it does not create a
> directory, that's OK too, but that should then be documented.

What should it return when the creation of some parents succeeds,
and fails for the rest?

-- 
Juri Linkov
http://www.jurta.org/emacs/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Fri, 11 Jun 2010 13:35:01 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Juri Linkov'" <juri <at> jurta.org>
Cc: 6397 <at> debbugs.gnu.org
Subject: RE: bug#6397: 24.0.50; `make-directory' return value
Date: Fri, 11 Jun 2010 06:33:17 -0700
> > The doc for `make-directory' doesn't mention its return 
> > value, and the code doesn't seem to do anything special
> > about it.
> 
> There is also a related bug#6363.
>
> > I think it should return non-nil (e.g. the directory name) if the
> > creation succeeds and nil if it fails without error.  And 
> > should be documented.  Or if it always raises an error when it
> > does not create a directory, that's OK too, but that should then
> > be documented.
> 
> What should it return when the creation of some parents succeeds,
> and fails for the rest?

Why do we let that happen? That seems like a bug. Is there some use case for
that? If not, can we fix it, to make the creation all-or-nothing (e.g. delete
any created unless all are)?

If the aim of the function is to create directory /a/lot/of/parents/foo, then
what sense does it make to create only some of the parents?





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Wed, 13 Jul 2011 22:24:03 GMT) Full text and rfc822 format available.

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

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 6397 <at> debbugs.gnu.org
Subject: Re: 24.0.50; `make-directory' return value
Date: Thu, 14 Jul 2011 00:22:54 +0200
"Drew Adams" <drew.adams <at> oracle.com> writes:

> I think it should return non-nil (e.g. the directory name) if the
> creation succeeds and nil if it fails without error.  And that should be
> documented.  Or if it always raises an error when it does not create a
> directory, that's OK too, but that should then be documented.

So you want the doc string to say that it will raise an error if there's
an error?  Ok, I've now done that.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Added tag(s) fixed. Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 13 Jul 2011 22:24:03 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.1, send any further explanations to 6397 <at> debbugs.gnu.org and "Drew Adams" <drew.adams <at> oracle.com> Request was from Lars Magne Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 13 Jul 2011 22:24:03 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Wed, 13 Jul 2011 22:48:03 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Lars Magne Ingebrigtsen'" <larsi <at> gnus.org>
Cc: 6397 <at> debbugs.gnu.org
Subject: RE: 24.0.50; `make-directory' return value
Date: Wed, 13 Jul 2011 15:47:46 -0700
> So you want the doc string to say that it will raise an error 
> if there's an error?  Ok, I've now done that.

Thanks.

But it sounds like there might still be a bug if the creation of the directory
and any missing parents is not an atomic transaction.  See the rest of the
thread.





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Wed, 13 Jul 2011 23:21:02 GMT) Full text and rfc822 format available.

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

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 6397 <at> debbugs.gnu.org
Subject: Re: 24.0.50; `make-directory' return value
Date: Thu, 14 Jul 2011 01:19:50 +0200
"Drew Adams" <drew.adams <at> oracle.com> writes:

> But it sounds like there might still be a bug if the creation of the directory
> and any missing parents is not an atomic transaction.  See the rest of the
> thread.

I don't think there's anything that can be done about that.  Creating a
full path isn't atomic, and deleting the directories we've already made
is bad, too.  Some other process may have wanted the directories at the
same time, and would bug out if we started deleting them.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Wed, 13 Jul 2011 23:47:02 GMT) Full text and rfc822 format available.

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

From: "Drew Adams" <drew.adams <at> oracle.com>
To: "'Lars Magne Ingebrigtsen'" <larsi <at> gnus.org>
Cc: 6397 <at> debbugs.gnu.org
Subject: RE: 24.0.50; `make-directory' return value
Date: Wed, 13 Jul 2011 16:45:56 -0700
> I don't think there's anything that can be done about that.  
> Creating a full path isn't atomic,

We know we're trying to create a hierachy of directories, and we know that it
must be an all-or-nothing transaction.  Why can't we make this atomic in this
particular case?

There's nothing magic about transactions.  In this case the rollback would be
simple: delete any directories created if for some reason we cannot create them
all.

> and deleting the directories we've already made
> is bad, too.

Why?  That's a normal rollback for this.  There's not a lot going on here: just
directory creation.

> Some other process may have wanted the directories at the
> same time, and would bug out if we started deleting them.

I suppose that's a legitimate point in the abstract, but highly unlikely in
practice.  And there is probably some way (file attributes? permissions?) of
making any created directories invisible/inaccessible during the transaction.

I don't see why Emacs Dev wouldn't try to fix this correctly.  Unless I'm
missing something.





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6397; Package emacs. (Wed, 13 Jul 2011 23:57:02 GMT) Full text and rfc822 format available.

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

From: Lars Magne Ingebrigtsen <larsi <at> gnus.org>
To: "Drew Adams" <drew.adams <at> oracle.com>
Cc: 6397 <at> debbugs.gnu.org
Subject: Re: 24.0.50; `make-directory' return value
Date: Thu, 14 Jul 2011 01:54:17 +0200
"Drew Adams" <drew.adams <at> oracle.com> writes:

> I suppose that's a legitimate point in the abstract, but highly unlikely in
> practice.  And there is probably some way (file attributes? permissions?) of
> making any created directories invisible/inaccessible during the transaction.

Nope.  There isn't.

You often see this sort of problem in web server caches, where you have
a gazillion processes all trying to create variants on the same
directory structures.  This may fail because two processes tries to
create /var/tmp/cache/foo/bar/zot at the same time, for instance.
Trying to unwind this in a general fashion is impossible, and must be
left to a higher level to determine what to do.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 11 Aug 2011 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 314 days ago.

Previous Next


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