losetup: Wait for ueventd to create loop device on Android

Android doesn't use devtmpfs. Instead device nodes under /dev are
created by userspace daemon ueventd. There could be a noticeable delay
between LOOP_CTL_GET_FREE issued and loop device created, so we need to
wait until it is created and then continue.
The timeout (5s) and time quantum (20ms) is picked randomly, it bares no
special meaning but they worked fine empirically.

Bug: 243495405
Change-Id: Ia56d347bf52f5730e7f46c30bf4f3f4d117149f8
1 file changed