system/corennnnn
Revisión | bc7b0cbe156da639f0cbe17bf89725d87e86512a (tree) |
---|---|
Tiempo | 2008-11-16 22:28:23 |
Autor | Jay Freeman (saurik) <saurik@saur...> |
Commiter | Jay Freeman (saurik) |
Open file and loop device with O_RDONLY when -o loop,ro.
Otherwise: ioctl LOOP_SET_FD failed: Bad file number.
@@ -138,14 +138,17 @@ do_mount(char *dev, char *dir, char *type, unsigned long rwflag, void *data, int | ||
138 | 138 | |
139 | 139 | if (loop) { |
140 | 140 | int file_fd, device_fd; |
141 | + int flags; | |
142 | + | |
143 | + flags = (rwflag & MS_RDONLY) ? O_RDONLY : O_RDWR; | |
141 | 144 | |
142 | 145 | // FIXME - only one loop mount supported at a time |
143 | - file_fd = open(dev, O_RDWR); | |
146 | + file_fd = open(dev, flags); | |
144 | 147 | if (file_fd < -1) { |
145 | 148 | perror("open backing file failed"); |
146 | 149 | return 1; |
147 | 150 | } |
148 | - device_fd = open(LOOP_DEVICE, O_RDWR); | |
151 | + device_fd = open(LOOP_DEVICE, flags); | |
149 | 152 | if (device_fd < -1) { |
150 | 153 | perror("open loop device failed"); |
151 | 154 | close(file_fd); |