kern/143834: mkdir(2) may set errno incorrectly

Mikhail T. mi at
Fri Feb 12 07:30:02 UTC 2010

>Number:         143834
>Category:       kern
>Synopsis:       mkdir(2) may set errno incorrectly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 12 07:30:01 UTC 2010
>Originator:     Mikhail T.
>Release:        FreeBSD 7.2-STABLE amd64
Virtual Estates, Inc. ( )
System: FreeBSD 7.2-STABLE FreeBSD 7.2-STABLE #3: Sun Dec 20 20:10:12 EST 2009 mi at amd64

	When the directory to be created is "/", mkdir(2) will set errno
	to EISDIR instead of EEXISTS.


	Compile and run this program:

		#include <err.h>
		#include <stdio.h>
		#include <sys/stat.h>

		main(int argc, char *argv[])
			mkdir("/", 0666);

			warn("mkdir /");

			mkdir("/tmp", 0666);

			warn("mkdir /tmp");

			return 0;

	You'll see the following inconsistency:

		t: mkdir /: Is a directory
		t: mkdir /tmp: File exists

	It should be "File exists" for both...

More information about the freebsd-bugs mailing list