[Toybox] [PATCH] Fix losetup for Android.

enh enh at google.com
Mon Dec 4 13:56:53 PST 2017


On Sat, Dec 2, 2017 at 11:15 PM, Rob Landley <rob at landley.net> wrote:
> On 11/29/2017 08:50 PM, enh wrote:
>> let me know if you'd rather have the #ifdef in portability.h --- i'm
>> not sure whether your aim is to have all #ifdefery in there, or
>> whether something should be needed in two places first.
>>
>> (the other alternative would be to always try both locations, but that
>> seemed even worse.)
>
> Trying both sounds right to me. I could see Red Hat Enterprise or
> similar doing this too.

yeah, the only possible downside i see is that error messages might be
mildly misleading (because losetup will only mention the last thing it
tried). but who doesn't decipher such things using strace anyway? :-)

thanks!

> Alas there isn't a real /dev spec since the Linux Foundation absorbed
> and destroyed the Linux Standards Base. There are entries in devtmpfs's
> block subdir but they're all symlinks ala 7:0 -> ../loop0
>
> Still, if you're using devtmpfs you get the top level entry, and if it's
> not there looking in the subdir as a fallback works for android and
> maybe elsewhere.
>
> Sigh, looking at my losetup I have pending changes to it, of course.
> Lemme check those in too... Ah right, I was adding losetup -A to set
> autoclear, but that can't work because you have to open the loopback
> device to call ioctls on it,and when you close the device's filehandle
> the association is cleared. So mount has to do it internally and then
> call mount() before closing the filehandle so it's pinned by the mount
> reference. And moving loopback_setup() into lib/ requires stripping the
> GLOBALS references out and turning them into function arguments...
>
> Right, break that part _out_ and check in the rest. (git --patch is
> lovely, athough it means you have to pull it to the "clean" directory
> and retest after committing.)
>
> Rob



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.



More information about the Toybox mailing list