Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jun 2006 02:35:20 +0100
From:      "mal content" <artifact.one@googlemail.com>
To:        "Pieter de Goeje" <pieter@degoeje.nl>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Strange behaviour from mkdir()?
Message-ID:  <8e96a0b90606051835j363547e0q4d8a549837c27b74@mail.gmail.com>
In-Reply-To: <200606060208.28838.pieter@degoeje.nl>
References:  <8e96a0b90606041148g5674ca31r74be2e1f9c79b640@mail.gmail.com> <200606060208.28838.pieter@degoeje.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/06/06, Pieter de Goeje <pieter@degoeje.nl> wrote:
> Hi MC,
>
> On Sunday 04 June 2006 20:48, mal content wrote:
> > Is this expected behaviour (I'm using the mkdir utility
> > for the example, but the problem occurs using the system
> > call directly):
> >
> > # mkdir .
> > mkdir: .: File exists
> > # mkdir ..
> > mkdir: ..: File exists
> >
> > Now, the unusual one:
> >
> > # mkdir /
> > mkdir: /: Is a directory
> >
> > Shouldn't it say 'file exists'?
> In fact, the _only_ directory that I could find that shows this behaviour
> is /. (I am using 6-stable)
>
> >
> > The mkdir() man page doesn't say that the function can set
> > errno to EISDIR and yet that's what's happening here.
> >
>
> I did some research on it, and it seems the mkdir utility is aware of the
> EISDIR error. Kinda weird if you ask me, since it isn't documented.

I followed the kern_mkdir() function and ended up in /src/sys/kern/vfs_lookup.c
where this bit of code appears:

                    785:        /*
                    786:         * Check for degenerate name (e.g. / or "")
                    787:         * which is a way of talking about a directory,
                    788:         * e.g. like "/." or ".".
                    789:         */
                    790:        if (cnp->cn_nameptr[0] == '\0') {
                    791:                if (cnp->cn_nameiop != LOOKUP
|| wantparent) {
                    792:                        error = EISDIR;
                    793:                        goto bad;
                    794:                }
                    795:                if (dp->v_type != VDIR) {
                    796:                        error = ENOTDIR;
                    797:                        goto bad;
                    798:                }

Not sure if that code is completely correct, but what do I know...

MC



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8e96a0b90606051835j363547e0q4d8a549837c27b74>