diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2008-11-16 13:25:10 +0000 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2008-11-16 13:28:23 +0000 |
commit | bc7b0cbe156da639f0cbe17bf89725d87e86512a (patch) | |
tree | 99d28073cfa0940a9b911fde922f6bb1fdbe181e /toolbox | |
parent | abb9638e3696e393d6dc45439feda91073e52103 (diff) | |
download | system_core-bc7b0cbe156da639f0cbe17bf89725d87e86512a.zip system_core-bc7b0cbe156da639f0cbe17bf89725d87e86512a.tar.gz system_core-bc7b0cbe156da639f0cbe17bf89725d87e86512a.tar.bz2 |
Open file and loop device with O_RDONLY when -o loop,ro.
Otherwise: ioctl LOOP_SET_FD failed: Bad file number.
Diffstat (limited to 'toolbox')
-rw-r--r-- | toolbox/mount.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/toolbox/mount.c b/toolbox/mount.c index ef13e1f..395c943 100644 --- a/toolbox/mount.c +++ b/toolbox/mount.c @@ -138,14 +138,17 @@ do_mount(char *dev, char *dir, char *type, unsigned long rwflag, void *data, int if (loop) { int file_fd, device_fd; + int flags; + + flags = (rwflag & MS_RDONLY) ? O_RDONLY : O_RDWR; // FIXME - only one loop mount supported at a time - file_fd = open(dev, O_RDWR); + file_fd = open(dev, flags); if (file_fd < -1) { perror("open backing file failed"); return 1; } - device_fd = open(LOOP_DEVICE, O_RDWR); + device_fd = open(LOOP_DEVICE, flags); if (device_fd < -1) { perror("open loop device failed"); close(file_fd); |