diff --git a/sys/kern/vfs_nlookup.c b/sys/kern/vfs_nlookup.c index ab7df39..4d7141b 100644 --- a/sys/kern/vfs_nlookup.c +++ b/sys/kern/vfs_nlookup.c @@ -469,14 +469,15 @@ nlookup(struct nlookupdata *nd) nd->nl_nch = nch; /* remains locked */ /* - * Fast-track termination. There is no parent directory of - * the root in the same mount from the point of view of - * the caller so return EPERM if NLC_REFDVP is specified. - * e.g. 'rmdir /' is not allowed. + * Fast-track termination. In the case of '/', there is no + * parent directory from the point of view of the caller + * so return either EPERM if NLC_REFDVP is specified. + * e.g. 'rmdir /' is not allowed, or return EEXIST + * for the case of 'mkdir /'. */ if (*ptr == 0) { if (nd->nl_flags & NLC_REFDVP) - error = EPERM; + error = (nd->nl_flags & NLC_CREATE) ? EEXIST : EPERM; else error = 0; break;