summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaoming Ni2022-12-12 18:57:09 +0100
committerDenys Vlasenko2022-12-12 19:03:06 +0100
commit7dc76c9f210b3c66a9c89e6690af7b49f6c540a8 (patch)
tree53aac486fb340ccda150184325d3e368fa63c594
parentddccf6cd2f519c46a6286a43ceaf680eb367301c (diff)
downloadbusybox-7dc76c9f210b3c66a9c89e6690af7b49f6c540a8.zip
busybox-7dc76c9f210b3c66a9c89e6690af7b49f6c540a8.tar.gz
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.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/libbb/loop.c b/libbb/loop.c
index 8e5c915..256b7ac 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
/* If device is free, try to claim it */
if (rc && errno == ENXIO) {
/* Associate free loop device with file */
- if (ioctl(lfd, LOOP_SET_FD, ffd)) {
- /* Ouch. Are we racing with other mount? */
- if (!*device) {
- close(lfd);
-//TODO: add "if (--failcount != 0) ..."?
- continue;
- }
+ rc = ioctl(lfd, LOOP_SET_FD, ffd);
+ if (rc != 0) {
+ /* Ouch... race: the device already has a fd */
goto close_and_try_next_loopN;
}
memset(&loopinfo, 0, sizeof(loopinfo));