diff options
-rw-r--r-- | libbb/loop.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libbb/loop.c b/libbb/loop.c index e930b1b1f..ffc8acd39 100644 --- a/libbb/loop.c +++ b/libbb/loop.c | |||
@@ -147,10 +147,8 @@ static int set_loopdev_params(int lfd, | |||
147 | loopinfo.lo_offset = offset; | 147 | loopinfo.lo_offset = offset; |
148 | loopinfo.lo_sizelimit = sizelimit; | 148 | loopinfo.lo_sizelimit = sizelimit; |
149 | /* | 149 | /* |
150 | * Used by mount to set LO_FLAGS_AUTOCLEAR. | 150 | * LO_FLAGS_READ_ONLY is not set because RO is controlled |
151 | * LO_FLAGS_READ_ONLY is not set because RO is controlled by open type of the file. | 151 | * by open type of the lfd. |
152 | * Note that closing LO_FLAGS_AUTOCLEARed lfd before mount | ||
153 | * is wrong (would free the loop device!) | ||
154 | */ | 152 | */ |
155 | loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); | 153 | loopinfo.lo_flags = (flags & ~BB_LO_FLAGS_READ_ONLY); |
156 | 154 | ||
@@ -266,6 +264,12 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse | |||
266 | /* SUCCESS! */ | 264 | /* SUCCESS! */ |
267 | if (!*device) | 265 | if (!*device) |
268 | *device = xstrdup(dev); | 266 | *device = xstrdup(dev); |
267 | /* Note: mount asks for LO_FLAGS_AUTOCLEAR loopdev. | ||
268 | * Closing LO_FLAGS_AUTOCLEARed lfd before mount | ||
269 | * is wrong (would free the loop device!), | ||
270 | * this is why we return without closing it. | ||
271 | */ | ||
272 | rc = lfd; /* return this */ | ||
269 | break; | 273 | break; |
270 | } | 274 | } |
271 | close(lfd); | 275 | close(lfd); |