actually, the attached (using CFG_TOYBOX_ON_ANDROID) is probably
preferable to either...

On Wed, Nov 29, 2017 at 6:50 PM, enh <e...@google.com> 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.)
>
> On Wed, Nov 29, 2017 at 6:49 PM, enh <e...@google.com> wrote:
>> By reason of historical accident, Android uses "/dev/block/loopX" rather
>> than "/dev/loopX" (though the control file is in the usual place). Work
>> around that.
>> ---
>>  toys/other/losetup.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>
>
>
> --
> Elliott Hughes - http://who/enh - http://jessies.org/~enh/
> Android native code/tools questions? Mail me/drop by/add me as a reviewer.



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.
From 7eeab4b2f4c23b5cb6f0201ae9335045f135c666 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Wed, 29 Nov 2017 18:47:15 -0800
Subject: [PATCH] Fix losetup for Android.

By reason of historical accident, Android uses "/dev/block/loopX" rather
than "/dev/loopX" (though the control file is in the usual place). Work
around that.
---
 toys/other/losetup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/toys/other/losetup.c b/toys/other/losetup.c
index 4e467a9..fae9867 100644
--- a/toys/other/losetup.c
+++ b/toys/other/losetup.c
@@ -76,7 +76,8 @@ static void loopback_setup(char *device, char *file)
     // mount -o loop depends on found device being at the start of toybuf.
     if (cfd != -1) {
       if (0 <= (i = ioctl(cfd, 0x4C82))) // LOOP_CTL_GET_FREE
-        sprintf(device = toybuf, "/dev/loop%d", i);
+        sprintf(device = toybuf,
+                CFG_TOYBOX_ON_ANDROID ? "/dev/block/loop%d" : "/dev/loop%d", i);
       close(cfd);
     }
   }
-- 
2.15.0.531.g2ccb3012c9-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to