Bug 4784

Summary: read-only loop mount should use a read-only losetup
Product: Busybox Reporter: Maxim Kammerer <mk>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: enhancement CC: busybox-cvs
Priority: P5    
Version: 1.19.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description Maxim Kammerer 2012-02-21 09:17:37 UTC
util-linux's mount -r uses the equivalent of losetup -r (opening the image with O_RDONLY). This is convenient when one wants to later remount the (read-write) filesystem hosting the image read-only. Busybox doesn't do that, so the remount attempt returns a "busy" error. E.g.:

mkdir z mnt
mount -t tmpfs tmpfs z
truncate -s 10M z/aaa
mkfs.ext2 z/aaa
mount -r -o loop -t ext2 z/aaa mnt
mount -o remount,ro z

A workaround in Busybox is temporarily remounting the image-hosting filesystem read-only before the loop mount (blockdev --setro /dev/loopX after mounting does not produce the desired effect).

Incidentally, losetup could support -r option in Busybox, too.
Comment 1 Denys Vlasenko 2012-06-21 10:09:50 UTC
Fixed in git:

commit 9ee426649006c4a0db7b4784f2ebb96865d4c705
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Thu Jun 21 12:08:56 2012 +0200

    mount: set up RO loop device if mount -o ro. Closes 4784