Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/loop.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/libbb/loop.c
r3232 r3621 95 95 /* Open the file. Barf if this doesn't work. */ 96 96 mode = ro ? O_RDONLY : O_RDWR; 97 open_ffd: 97 98 ffd = open(file, mode); 98 99 if (ffd < 0) { 99 100 if (mode != O_RDONLY) { 100 101 mode = O_RDONLY; 101 ffd = open(file, mode);102 goto open_ffd; 102 103 } 103 if (ffd < 0) 104 return -errno; 104 return -errno; 105 105 } 106 106 107 107 /* Find a loop device. */ 108 108 try = *device ? *device : dev; 109 /* 1048575 is a max possible minor number in Linux circa 2010 */109 /* 1048575 (0xfffff) is a max possible minor number in Linux circa 2010 */ 110 110 for (i = 0; rc && i < 1048576; i++) { 111 111 sprintf(dev, LOOP_FORMAT, i); … … 122 122 } 123 123 /* Ran out of block devices, return failure. */ 124 rc = - ENOENT;124 rc = -1; 125 125 break; 126 126 } … … 132 132 dfd = open(try, mode); 133 133 } 134 if (dfd < 0) 134 if (dfd < 0) { 135 if (errno == ENXIO) { 136 /* Happens if loop module is not loaded */ 137 rc = -1; 138 break; 139 } 135 140 goto try_again; 141 } 136 142 137 143 rc = ioctl(dfd, BB_LOOP_GET_STATUS, &loopinfo); … … 149 155 ioctl(dfd, LOOP_CLR_FD, 0); 150 156 } 151 152 /* If this block device already set up right, re-use it. 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.) 156 */ 157 } else 158 if (strcmp(file, (char *)loopinfo.lo_file_name) != 0 159 || offset != loopinfo.lo_offset 160 ) { 157 } else { 161 158 rc = -1; 162 159 }
Note:
See TracChangeset
for help on using the changeset viewer.