Subject: EISDIR for operations on "/"
To: None <tech-kern@netbsd.org>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 10/24/2005 19:05:26
--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
hi,
a while back christos added to the mkdir manpage that the error we return
for mkdir("/") is EISDIR, which is what we do but not what we should do.
the attached patch changes the errors we return for mkdir("/"), rmdir("/"),
rename("/", ...) and rename(..., "/") to EEXIST, EBUSY and EBUSY and EBUSY
respectively. this matches linux, AIX and HP-UX and appears to be the
closest match to what SUSv3 specifies. solaris returns EINVAL in all of the
EBUSY cases above, which is only supported by the spec in the rename("/", ...)
case.
any objections to this change?
-Chuck
--jI8keyz6grp/JLjh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="diff.eisdir"
Index: src/sys/kern/vfs_lookup.c
===================================================================
RCS file: /cvsroot/src/sys/kern/vfs_lookup.c,v
retrieving revision 1.63
diff -u -p -r1.63 vfs_lookup.c
--- src/sys/kern/vfs_lookup.c 6 Jul 2005 18:53:00 -0000 1.63
+++ src/sys/kern/vfs_lookup.c 23 Oct 2005 00:59:03 -0000
@@ -483,7 +483,17 @@ lookup(struct nameidata *ndp)
*/
if (cnp->cn_nameptr[0] == '\0') {
if (ndp->ni_dvp == NULL && wantparent) {
- error = EISDIR;
+ switch (cnp->cn_nameiop) {
+ case CREATE:
+ error = EEXIST;
+ break;
+ case DELETE:
+ case RENAME:
+ error = EBUSY;
+ break;
+ default:
+ KASSERT(0);
+ }
goto bad;
}
ndp->ni_vp = dp;
Index: src/lib/libc/sys/mkdir.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/mkdir.2,v
retrieving revision 1.22
diff -u -p -r1.22 mkdir.2
--- src/lib/libc/sys/mkdir.2 17 Sep 2005 06:08:03 -0000 1.22
+++ src/lib/libc/sys/mkdir.2 23 Oct 2005 00:59:03 -0000
@@ -29,7 +29,7 @@
.\"
.\" @(#)mkdir.2 8.2 (Berkeley) 12/11/93
.\"
-.Dd September 17, 2005
+.Dd October 19, 2005
.Dt MKDIR 2
.Os
.Sh NAME
@@ -79,9 +79,6 @@ Too many symbolic links were encountered
The named file resides on a read-only file system.
.It Bq Er EEXIST
The named file exists.
-.It Bq Er EISDIR
-Attempt to create
-.Dq / .
.It Bq Er ENOSPC
The new directory cannot be created because there is no space left
on the file system that will contain the directory.
Index: src/lib/libc/sys/rename.2
===================================================================
RCS file: /cvsroot/src/lib/libc/sys/rename.2,v
retrieving revision 1.21
diff -u -p -r1.21 rename.2
--- src/lib/libc/sys/rename.2 13 May 2004 10:20:58 -0000 1.21
+++ src/lib/libc/sys/rename.2 23 Oct 2005 00:59:03 -0000
@@ -29,7 +29,7 @@
.\"
.\" @(#)rename.2 8.1 (Berkeley) 6/4/93
.\"
-.Dd June 4, 1993
+.Dd October 19, 2005
.Dt RENAME 2
.Os
.Sh NAME
@@ -169,6 +169,11 @@ or
.It Bq Er ENOTEMPTY
.Fa to
is a directory and is not empty.
+.It Bq Er EBUSY
+.Fa from
+or
+.Fa to
+is the mount point for a mounted file system.
.El
.Sh SEE ALSO
.Xr open 2 ,
--jI8keyz6grp/JLjh--