login
Header Space

 
 

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

Previous thread: [PATCH] ext4: Fix synchronization of quota files in journal=data mode by Jan Kara on Wednesday, April 30, 2008 - 11:06 am. (21 messages)

Next thread: [PATCH] x86: ioremap ram check fix by Andres Salomon on Wednesday, April 30, 2008 - 11:30 am. (5 messages)
To: <linux-kernel@...>
Date: Wednesday, April 30, 2008 - 10:50 am

Hi,

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.

This was tested with the latest git-tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6

The last kernel I know of this has been working was 2.6.22.

E.g.:
|root@triton1:/# mount
|rootfs on / type rootfs (rw)
|/dev/root on / type jffs2 (ro)
|proc on /proc type proc (rw)
|sysfs on /sys type sysfs (rw)
|/dev/root on /dev/.static/dev type jffs2 (ro)
|tmpfs on /dev type tmpfs (rw,size=10240k,mode=755)
|tmpfs on /var type tmpfs (rw)
|tmpfs on /tmp type tmpfs (rw)
|devpts on /dev/pts type devpts (rw,gid=5,mode=620)
|tmpfs on /dev/shm type tmpfs (rw)
|root@triton1:/# mkdir -p /dev/.udev/db
|mkdir: Cannot create directory `/dev/': Read-only file system

While:
|root@triton1:/# cd /dev
|root@triton1:/# mkdir -p .udev/db
works as expected...

Has anyone else encountered this problem already?
I've searched the archives but could not find anything related to this
problem.



Lothar Wa
To: Lothar <LW@...>
Cc: <linux-kernel@...>
Date: Friday, May 2, 2008 - 12:52 am

(y'know that ~4000 people read your email and hit 'n'?  Except for me?

I had a shot at scripting this, but for me, everything works OK.

#!/bin/sh
dd if=/dev/zero of=file1 bs=1M count=32
dd if=/dev/zero of=file2 bs=1M count=32
yes | mkfs -t ext2 file1
yes | mkfs -t ext2 file2
mkdir -p mountpoint
mount -o loop file1 mountpoint
mkdir mountpoint/dir
umount mountpoint
mount -o loop,ro file1 mountpoint
mount -o loop file2 mountpoint/dir
mkdir -p $(/bin/pwd)/mountpoint/dir/subdir


are you able to modify the above so that it demonstrates the failure?

Thanks.
--
To: Andrew Morton <akpm@...>
Cc: Lothar Waßmann <LW@...>, <linux-kernel@...>
Date: Friday, May 2, 2008 - 7:32 am

Hmmm.  The thing you are doing differently is that the reporter's root 
filesystem is mounted read only but in your case (and the quick try I 
had at it) the read only file system is mounted below root.

However, I tried reproducing that scenario with a chroot and I still 
couldn't get it to happen.  No time to try a real root mount ro this 
morning but perhaps others can.

Cheers,
Dan

-- 
                     /--------------- - -  -  -   -   -
                     |  Dan Noé
                     |  http://isomerica.net/~dpn/
--
To: Andrew Morton <akpm@...>
Cc: Lothar <lw@...>, <linux-kernel@...>
Date: Friday, May 2, 2008 - 2:55 am

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...

What does

   strace mkdir -p /dev/.udev/db

show ???

NeilBrown


--
To: NeilBrown <neilb@...>
Cc: Andrew Morton <akpm@...>, Lothar <lw@...>, <linux-kernel@...>
Date: Saturday, May 3, 2008 - 2:32 am

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: Willy Tarreau <w@...>
Cc: NeilBrown <neilb@...>, Andrew Morton <akpm@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 2:27 am

Hi,

This is what strace shows in my case:
mkdir("/", 0777)                        = -1 EEXIST (File exists)
stat64("/", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
mkdir("/dev/", 0777)                    = -1 EROFS (Read-only file system)
umask(022)                              = 022
write(2, "mkdir: ", 7mkdir: )                  = 7
write(2, "Cannot create directory `/dev/\'", 31Cannot create directory `/dev/') = 31
write(2, ": Read-only file system\n", 24: Read-only file system
) = 24
io_submit(0x1, 0x1, 0xfbad2088 &lt;unfinished ... exit status 1&gt;


Lothar Wa
To: Lothar <LW@...>
Cc: NeilBrown <neilb@...>, Andrew Morton <akpm@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 3:02 am

So you should send this trace to the busybox maintainer. It
obviously exhibits a small but easily fixable bug in the
program ; it should check whether the directory exists in
case of error. It seems it only checks for EEXIST.

What puzzles me is why you have this problem only with a new kernel.
I suspect that previous ones did report EEXIST and now we report
EROFS for an existing directory on an ro fs.

Willy

--
To: Willy Tarreau <w@...>
Cc: NeilBrown <neilb@...>, Andrew Morton <akpm@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 3:08 am

Hi,

                                                   ^^^^^^
Interestingly your strace output showed a return value of EEXIST where
mine had EROFS.


Lothar Wa
To: Lothar <LW@...>
Cc: NeilBrown <neilb@...>, Andrew Morton <akpm@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 3:28 am

Oh you're right! I did not notice. There's something odd here.
And I can reproduce it right now (2.6.25.1). I really have
EEXIST.

Willy

--
To: Willy Tarreau <w@...>
Cc: NeilBrown <neilb@...>, Andrew Morton <akpm@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 3:38 am

Hi,

As I noted in my first message I have this problem with the kernel
from git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
which is currently 2.6.26-rc1 and still exhibits this behaviour.

So, this problem obviously does not exist in the 2.6.25 release kernel
but would probably hit mainline in the 2.6.26 release.


Lothar Wa
To: Lothar Wa?mann <LW@...>
Cc: Willy Tarreau <w@...>, NeilBrown <neilb@...>, Andrew Morton <akpm@...>, <linux-kernel@...>, <hch@...>
Date: Monday, May 5, 2008 - 8:02 am

Aye.  That's ro-bind fallout we'd not noticed; will fix...

And a fine example of the reasons why
	* relying on which particular errno value you get when several
are applicable is a Bad Idea(tm) and
	* changing the choice of the errno value in such situation might
be legal, but is to be done with care; sometimes it really has impact...
--
Previous thread: [PATCH] ext4: Fix synchronization of quota files in journal=data mode by Jan Kara on Wednesday, April 30, 2008 - 11:06 am. (21 messages)

Next thread: [PATCH] x86: ioremap ram check fix by Andres Salomon on Wednesday, April 30, 2008 - 11:30 am. (5 messages)
speck-geostationary