Re: linux-2.6.25: 'mkdir -p' does not work with rootdir as mount point inside a read only filesystem

From: Willy Tarreau
Date: Sat May 03 2008 - 02:33:23 EST


On Fri, May 02, 2008 at 04:55:43PM +1000, NeilBrown wrote:
> On Fri, May 2, 2008 2:52 pm, Andrew Morton wrote:
> > On Wed, 30 Apr 2008 16:50:20 +0200 Lothar Wa__mann
> > <LW@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> >> Hi,
> >
> > (y'know that ~4000 people read your email and hit 'n'? Except for me?
> > That's one bug I'd like to get fixed)
>
> Tricky....
>
> >
> >> when trying to create a directory path with 'mkdir -p' with the root
> >> being a mount point of a writeable filesystem that exists inside a
> >> read-only file system, mkdir return -EROFS.
>
> My guess is that you have an old/buggy version of mkdir.
>
> What does
> mkdir --version
>
> say?
> Mine says:
> mkdir (GNU coreutils) 6.10
> Copyright (C) 2008 Free Software Foundation, Inc.
> etc...

I would bet this is the problem for the reporter.

I tried the same here, and cannot exhibit the problem. Just like the
reporter, my / is ro and /dev is rw :

# mkdir --version
mkdir (coreutils) 5.2.1
...

# uname -a
Linux alix-2C3 2.6.25-wt4-alix #3 Thu Apr 24 08:30:05 CEST 2008 i586 i586 i386 GNU/Linux

(this is essentially 2.6.25+squashfs+some geode patches)

# mount
/dev/sda4 on / type ext3 (ro,errors=continue,data=ordered)
/dev on /dev type tmpfs (rw,size=0k,nr_inodes=4096,mode=755)

# mkdir -p /dev/a/b/c
# ls -lad /dev/a/b/c
drwxr-xr-x 2 root root 40 Jan 3 00:49 /dev/a/b/c/

# rmdir -p /dev/a/b/c
rmdir: `/dev': Read-only file system
# strace mkdir -p /dev/a/b/c

stat64("/dev/a/b/c", 0xbf9175dc) = -1 ENOENT (No such file or directory)
umask(0) = 022
open(".", O_RDONLY|O_LARGEFILE|O_DIRECTORY) = 3
chdir("/") = 0
mkdir("dev", 0755) = -1 EEXIST (File exists)
stat64("dev", {st_mode=S_IFDIR|0755, st_size=17080, ...}) = 0
chdir("dev") = 0
mkdir("a", 0755) = 0
chdir("a") = 0
mkdir("b", 0755) = 0
chdir("b") = 0
umask(022) = 0
mkdir("c", 0777) = 0
fchdir(3) = 0
close(3) = 0

Regards,
Willy

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/