bin/127932: mkdir -p PATH fails if a directory in PATH is on a read-only fs

Till Toenges tt at kyon.de
Wed Oct 8 00:10:05 UTC 2008


>Number:         127932
>Category:       bin
>Synopsis:       mkdir -p PATH fails if a directory in PATH is on a read-only fs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 08 00:10:04 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Till Toenges
>Release:        7.0
>Organization:
ky-on
>Environment:
FreeBSD deusexmachina.kyon.de 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Mon Oct  6 12:44:33 UTC 2008     root at dyn1-166.cicely.de:/usr/src/sys/amd64/compile/MAIL  amd64
>Description:
mkdir -p <path> fails if a directory in <path> is on a read-only fs. It tries to create every directory <subdir> in <path>, and ignores EEXIST and EISDIR errors, if <subdir> is a directory. But it treats EROFS as an error and exits.

Noticed it while trying to build a port in a jail, where the jails / was read-only union mounted in the directory containing the jails /var.
>How-To-Repeat:
Assuming a read-only root, and /var mounted writable:

mkdir -p /var/db/ports/openldap24

fails.
>Fix:
Treat EROFS like EISDIR and EEXIST.

Patch attached with submission follows:

--- /usr/src/bin/mkdir/mkdir.c	2006-10-10 22:18:20.000000000 +0200
+++ /root/mkdir/mkdir.c	2008-10-08 01:44:22.000000000 +0200
@@ -177,7 +177,7 @@
 		if (last)
 			(void)umask(oumask);
 		if (mkdir(path, last ? omode : S_IRWXU | S_IRWXG | S_IRWXO) < 0) {
-			if (errno == EEXIST || errno == EISDIR) {
+			if (errno == EEXIST || errno == EISDIR || errno == EROFS) {
 				if (stat(path, &sb) < 0) {
 					warn("%s", path);
 					retval = 0;


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list