diff options
-rw-r--r-- | libbb/loop.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libbb/loop.c b/libbb/loop.c index cb8fa2442..750642ade 100644 --- a/libbb/loop.c +++ b/libbb/loop.c | |||
@@ -218,8 +218,17 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse | |||
218 | } | 218 | } |
219 | /* failure, undo LOOP_SET_FD */ | 219 | /* failure, undo LOOP_SET_FD */ |
220 | ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary | 220 | ioctl(lfd, LOOP_CLR_FD, 0); // actually, 0 param is unnecessary |
221 | } else { | ||
222 | /* device is not free (rc == 0), or error other than ENXIO */ | ||
223 | if (rc == 0 /* device is not free? */ | ||
224 | && !*device /* racing with other mount? */ | ||
225 | && try != dev /* tried a _kernel-offered_ loopN? */ | ||
226 | ) { | ||
227 | free(try); | ||
228 | close(lfd); | ||
229 | goto get_free_loopN; | ||
230 | } | ||
221 | } | 231 | } |
222 | /* else: device is not free (rc == 0) or error other than ENXIO */ | ||
223 | close_and_try_next_loopN: | 232 | close_and_try_next_loopN: |
224 | close(lfd); | 233 | close(lfd); |
225 | try_next_loopN: | 234 | try_next_loopN: |