← Commit list

a55bd1c48

Denys Vlasenko
Denys Vlasenko
2022-12-13
SUCCESS Duration: 298s

Subject

loop: restore the correct return vaule of set_loop()

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/loop.c+8 -4
@@ -147,10 +147,8 @@ static int set_loopdev_params(int lfd,
loopinfo.lo_offset = offset;
loopinfo.lo_sizelimit = sizelimit;
/*
- * Used by mount to set LO_FLAGS_AUTOCLEAR.
- * LO_FLAGS_READ_ONLY is not set because RO is controlled by open type of the file.
- * Note that closing LO_FLAGS_AUTOCLEARed lfd before mount
- * is wrong (would free the loop device!)
+ * LO_FLAGS_READ_ONLY is not set because RO is controlled
+ * by open type of the lfd.
*/
loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY);
@@ -266,6 +264,12 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
/* SUCCESS! */
if (!*device)
*device = xstrdup(dev);
+ /* Note: mount asks for LO_FLAGS_AUTOCLEAR loopdev.
+ * Closing LO_FLAGS_AUTOCLEARed lfd before mount
+ * is wrong (would free the loop device!),
+ * this is why we return without closing it.
+ */
+ rc = lfd; /* return this */
break;
}
close(lfd);