Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Nov 2009 16:32:22 +0100 (CET)
From:      Alexander Best <alexbestms@math.uni-muenster.de>
To:        Alex Dupre <ale@FreeBSD.org>, Alexander Best <alexbestms@math.uni-muenster.de>
Cc:        freebsd-hackers@FreeBSD.org
Subject:   Re: rmdir(2) and mkdir(2) both return EISDIR for argument "/"
Message-ID:  <permail-2009110615322280e26a0b00003ff9-a_best01@message-id.uni-muenster.de>
In-Reply-To: <4AF42D61.6050403@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
Alex Dupre schrieb am 2009-11-06:
> Alexander Best ha scritto:
> > i dug up this old pr
> > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/59739

> I think the EISDIR error is coming from kern/vfs_lookup.c, lookup()
> function with cn_nameptr = "":


>         /*
>          * Check for degenerate name (e.g. / or "")
>          * which is a way of talking about a directory,
>          * e.g. like "/." or ".".
>          */
>         if (cnp->cn_nameptr[0] == '\0') {
>                 ...
>                 if (cnp->cn_nameiop != LOOKUP) {
>                         error = EISDIR;
>                         goto bad;
>                 }
>                 ...

thanks a lot for finding the problem in the src. what do you think of the
patch attached to this message? after applying it the example code i posted in
my previous message returns the following output (instead of EISDIR):

rmdir errno: 16 (which is EBUSY)
mkdir errno: 17 (which is EEXIST)

i don't know if these really are the correct return values, but it's what the
originator of the PR requested.

alex

[-- Attachment #2 --]
--- vfs_lookup.c	2009-11-06 16:14:41.000000000 +0100
+++ /usr/src/sys/kern/vfs_lookup.c	2009-11-06 16:13:19.000000000 +0100
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/kern/vfs_lookup.c 195939 2009-07-29 07:44:43Z rwatson $");
 
 #include "opt_kdtrace.h"
 #include "opt_ktrace.h"
@@ -563,8 +563,12 @@
 			error = ENOTDIR;
 			goto bad;
 		}
-		if (cnp->cn_nameiop != LOOKUP) {
-			error = EISDIR;
+		if (cnp->cn_nameiop != LOOKUP && cnp->cn_nameiop == DELETE) {
+			error = EBUSY;
+			goto bad;
+		}
+		if (cnp->cn_nameiop != LOOKUP && cnp->cn_nameiop == CREATE) {
+			error = EEXIST;
 			goto bad;
 		}
 		if (wantparent) {
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-2009110615322280e26a0b00003ff9-a_best01>