Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/libbb/loop.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/libbb/loop.c
r2725 r3232 85 85 file/offset if it finds one. 86 86 */ 87 int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offset )87 int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offset, int ro) 88 88 { 89 89 char dev[LOOP_NAMESIZE]; … … 94 94 95 95 /* Open the file. Barf if this doesn't work. */ 96 mode = O_RDWR;96 mode = ro ? O_RDONLY : O_RDWR; 97 97 ffd = open(file, mode); 98 98 if (ffd < 0) { 99 mode = O_RDONLY; 100 ffd = open(file, mode); 99 if (mode != O_RDONLY) { 100 mode = O_RDONLY; 101 ffd = open(file, mode); 102 } 101 103 if (ffd < 0) 102 104 return -errno; … … 149 151 150 152 /* If this block device already set up right, re-use it. 151 152 153 153 * (Yes this is racy, but associating two loop devices with the same 154 * file isn't pretty either. In general, mounting the same file twice 155 * without using losetup manually is problematic.) 154 156 */ 155 157 } else
Note:
See TracChangeset
for help on using the changeset viewer.