On Sat, Aug 27, 2022 at 02:47:45PM -0700, Chris Torek wrote: > On Sat, Aug 27, 2022 at 6:05 AM Jeff King <peff@xxxxxxxx> wrote: > > Yeah, I saw that. It's a bit vague, and if the call returns ENOSYS or > > EISDIR, that would be perfectly fine. It's the "what happens on the > > implementations that do support it..." part that I'm more worried about. :) > > The history here is that pre-4.2BSD, Unix systems had no mkdir > system call. You used mknod() to make a truly empty directory and > the link() to create the "." and ".." entries within it, and all three of > these operations were restricted to the super-user. There was no > rmdir either, so again, unlink() as the super-user was permitted to > do the job (with three calls to unlink the "." and ".." entries first and > then remove the directory). > > Unlinking a directory when it still contains "." leaves the link count > at 1 and there's no GC, so it sits around occupying an inode. Thanks, that matches the sense of unease I had in the back of my mind. I seem to recall that maybe older versions of SunOS exhibited this, but that feels like a lifetime ago. At any rate, we should avoid that unlink() call, and René's patch neatly does so. -Peff