[Toybox] [PATCH] losetup: fix the race.

Rob Landley rob at landley.net
Thu Aug 8 05:51:06 PDT 2019


On 8/6/19 5:08 PM, Ryan Prichard wrote:
> On Tue, Aug 6, 2019 at 1:56 PM Rob Landley <rob at landley.net
> <mailto:rob at landley.net>> wrote:
> 
>     On 8/5/19 7:40 PM, Ryan Prichard via Toybox wrote:
>     > I think this patch fixes a race I noticed, but in practice I was hitting a
>     > different race. After LOOP_CTL_GET_FREE had created a new loop device, losetup
>     > tried to open /dev/block/loopXXX before the device file existed,
> 
>     Why is the ioctl returning before the block device exists?
> 
> 
> I think the /dev/block/loopXXX file is created by a userspace daemon (probably
> ueventd in Android). The ioctl creates the kernel device, then sends an
> asynchronous uevent message to ueventd about the new device. ueventd and losetup
> then race each other to create the file and to open it.

So wait, you're _not_ using devtmpfs?
> Summarizing the util-linux workaround:
>  - Make 16 attempts to open the device file.
>  - If the open fails with EACCES or ENOENT, sleep for 25ms, then try again.

Add a workaround for not using devtmpfs. Right...

Rob



More information about the Toybox mailing list