diff options
author | Xiaoming Ni <nixiaoming@huawei.com> | 2022-12-12 18:57:09 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2022-12-12 19:03:06 +0100 |
commit | 7dc76c9f210b3c66a9c89e6690af7b49f6c540a8 (patch) | |
tree | 53aac486fb340ccda150184325d3e368fa63c594 | |
parent | ddccf6cd2f519c46a6286a43ceaf680eb367301c (diff) | |
download | busybox-w32-7dc76c9f210b3c66a9c89e6690af7b49f6c540a8.tar.gz busybox-w32-7dc76c9f210b3c66a9c89e6690af7b49f6c540a8.tar.bz2 busybox-w32-7dc76c9f210b3c66a9c89e6690af7b49f6c540a8.zip |
loop: simplify code of LOOP_SET_FD failure
function old new delta
set_loop 790 760 -30
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | libbb/loop.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/libbb/loop.c b/libbb/loop.c index 8e5c915fc..256b7ac90 100644 --- a/libbb/loop.c +++ b/libbb/loop.c | |||
@@ -188,13 +188,9 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse | |||
188 | /* If device is free, try to claim it */ | 188 | /* If device is free, try to claim it */ |
189 | if (rc && errno == ENXIO) { | 189 | if (rc && errno == ENXIO) { |
190 | /* Associate free loop device with file */ | 190 | /* Associate free loop device with file */ |
191 | if (ioctl(lfd, LOOP_SET_FD, ffd)) { | 191 | rc = ioctl(lfd, LOOP_SET_FD, ffd); |
192 | /* Ouch. Are we racing with other mount? */ | 192 | if (rc != 0) { |
193 | if (!*device) { | 193 | /* Ouch... race: the device already has a fd */ |
194 | close(lfd); | ||
195 | //TODO: add "if (--failcount != 0) ..."? | ||
196 | continue; | ||
197 | } | ||
198 | goto close_and_try_next_loopN; | 194 | goto close_and_try_next_loopN; |
199 | } | 195 | } |
200 | memset(&loopinfo, 0, sizeof(loopinfo)); | 196 | memset(&loopinfo, 0, sizeof(loopinfo)); |