Subject: Re: wierd behaviour of mkdir(2)
To: Yoav Cohen-Sivan <firstname.lastname@example.org>
From: Bert Driehuis <email@example.com>
Date: 10/19/2000 23:55:08
On Thu, 19 Oct 2000, Yoav Cohen-Sivan wrote:
> KDE is trying to do a mkdir("/home/yoavcs/.kde/share/",xxxxx) and mkdir
> is failing wih an errno of "no such file or directory". I compiled a
> small program of my own and discovered that when mkdir is called as
> above with the trailing '/' it fails. Call it without the trailing '/'
> ("/home/yoavcs/.kde/share") and all works peachy.
> Is this a fault of mkdir(2) or KDE?! It is a shame since once I manually
> created the entire dir structure under my home dir KDE 2 works
It is an old debate that has no Posixly correct answer, if I recall
right. It is very counterintuitive to allow mkdir to implicitly descend
into the directory it is about to create, and the only reason this
practice is so widespread is that historically System V allowed this
(due to a bug in their namei implementation, to add insult to injury).
It seems a lot of Unices these days cater for this programming error
just to avoid having to take the heat from their users when an app that
works on SysV doesn't work on their system.
The best thing is to fix the app, IMHO.
Incidentally, this same bug is the reason Netscape crashes when reading
news if the xover-cache directory doesn't exist prior to starting
Netscape. I identified the issue in an ancient Mozilla release, but have
been unsucessful in getting them to fix it in their mkdir wrapper
Bert Driehuis -- firstname.lastname@example.org -- +31-20-3116119
If the only tool you've got is an axe, every problem looks like fun!