Date: Tue, 16 Jan 2001 16:57:19 +0100 From: mouss <usebsd@free.fr> To: Peter Pentchev <roam@orbitel.bg> Cc: "W.H.Scholten" <whs@xs4all.nl>, Alfred Perlstein <bright@wintelcom.net>, freebsd-hackers@FreeBSD.ORG Subject: Re: pppd & mkdir diff Message-ID: <4.3.0.20010116164550.07174e40@pop.free.fr> In-Reply-To: <20010116145020.E364@ringworld.oblivion.bg> References: <4.3.0.20010116131322.03f23a80@pop.free.fr> <3A5C843C.794BDF32@xs4all.nl> <20010111132509.J7240@fw.wintelcom.net> <3A5EE6B1.41C67EA6@xs4all.nl> <20010112081422.U7240@fw.wintelcom.net> <3A6025F1.794BDF32@xs4all.nl> <4.3.0.20010116131322.03f23a80@pop.free.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
At 14:50 16/01/01 +0200, Peter Pentchev wrote: >As somebody already pointed out, there *is* a dirname(3) function, and even >a dirname(1) cmdline utility to invoke it. oops. I'll need to stay current:) >In a followup to Alfred's mkdir(1) commit, I sent a sample implementation >of a direxname() function, which calls dirname(3) in a loop, and returns >the longest existing path component. I'll get back to him shortly >with a patch to mkdir(1) using direxname() to report a meaningful error >message, something like "Cannot create /exists/nonex/foo/bar, nonexistent >path components after /exists". In the meantime, attached is my first >shot at direxname() implementation, using dirname(3)'s static buffer. I'm not convinced you really need to check which is the "largest" parent that exists. if /a doesn't exist, and I do a mkdir /a/b/c/d, just a "/a/b/c does not exist" is far sufficient. For me, if you ignore permissions and the like, the condition to create a directory is that its parent exists, whatever are his grand-parents. after the error is shown, one will anyway check which dirs exist. doing the stat() on all those just consumes time, with few benefits. on an NFS mounted fs, this would be just annoyiing sometimes. now if you really insist, I'd suggest doing the stat the other way: check the root, then its children, then the children of the latter... like in mkdir -p. at last, note that there might be race conditions while you stat(). but there is hardly a way to avoid'em. at least, a single stat() reduces the window of opportunity. regards, mouss To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4.3.0.20010116164550.07174e40>