In ext_mountfs of sys/gnu/fs/ext2fs/ext2_vfsops.c it's checked errorneously whether mounter wants a read-only mount. Therefore this function will always act as in case of a writable mount which yields an EROFS if the media is actually read-only. This might also lead to unintended fs modification despite the "-o ro" option; I haven't made experiments of such type though, it's just a hypothetical problem at this point. This bug is present at least in RELENG6 and HEAD branches. Fix: Apply the follwing patch: Csaba--Sf3BVGoCl2Lwm3R65S2ZhnEwryVMOQQDGbO1fgiVp6dpYKDA Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" --- ext2_vfsops.c.orig Fri Nov 3 01:31:42 2006 +++ ext2_vfsops.c Fri Nov 3 01:34:10 2006 @@ -601,7 +601,7 @@ ext2_mountfs(devvp, mp, td) int error; int ronly; - ronly = vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0); + ronly = (mp->mnt_flag & MNT_RDONLY) ? : 1 : 0; /* XXX: use VOP_ACESS to check FS perms */ DROP_GIANT(); g_topology_lock(); How-To-Repeat: - Create a sparse file in some of your filesystems. - Format the sparse file as an ext2 filesystem by mke2fs(8). - Remount the host filesystem read-only. - Create an md node backed by the ext2 file using mdconfig(8). - Try to mount the resulting md node with ext2 type. You will get EROFS either you use "-o ro" or not.
There was a typo in the patch. Here is the fixed version. Csaba
I have tested this bug on 8.0-CURRENT and it seems to be fixed. I did the following to test the bug 1) Created a sparse file using dd 2) Then using mdconfig created a node 3) Formatted using mkfs.ext2 4) Remounted the host file system has ro 5) Then mounted the sparse file with -o ro The sparse file is getting mounted perfectly so I request to mark this bug has closed. Cheers, Aditya Sarawgi
Responsible Changed From-To: freebsd-bugs->freebsd-fs Over to maintainer(s).
State Changed From-To: open->feedback Apparently this has been fixed. Can you confirm?
Responsible Changed From-To: freebsd-fs->jh Track.
State Changed From-To: feedback->closed Submitter agreed that this has been likely fixed.