Bug 4784 - read-only loop mount should use a read-only losetup
Summary: read-only loop mount should use a read-only losetup
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: 1.19.x
Hardware: PC Linux
: P5 enhancement
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-21 09:17 UTC by Maxim Kammerer
Modified: 2012-06-21 10:09 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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