aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-06-26 15:57:25 -0700
committerRob Landley <rob@landley.net>2019-06-26 22:13:32 -0500
commit40e55eb40afab3bc978fb42b6ec009a108d8e0c3 (patch)
tree28d56739772d7ea8950345a2481c22632234f006 /toys/other
parentb75675297700e365cc8482b048ad9a7fc4946065 (diff)
downloadtoybox-40e55eb40afab3bc978fb42b6ec009a108d8e0c3.tar.gz
losetup: fix Android.
Use /dev/block/loop* more uniformly, and teach the tests which to expect.
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/losetup.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/toys/other/losetup.c b/toys/other/losetup.c
index 02856c27..8edc65ae 100644
--- a/toys/other/losetup.c
+++ b/toys/other/losetup.c
@@ -43,6 +43,7 @@ GLOBALS(
int openflags;
dev_t jdev;
ino_t jino;
+ char *dir;
)
// -f: *device is NULL
@@ -65,9 +66,7 @@ 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);
- // Fallback for Android
- if (access(toybuf, F_OK)) sprintf(toybuf, "/dev/block/loop%d", i);
+ sprintf(device = toybuf, "%s/loop%d", TT.dir, i);
}
close(cfd);
}
@@ -150,6 +149,7 @@ void losetup_main(void)
{
char **s;
+ TT.dir = CFG_TOYBOX_ON_ANDROID ? "/dev/block" : "/dev";
TT.openflags = FLAG(r) ? O_RDONLY : O_RDWR;
if (TT.j) {
@@ -176,7 +176,7 @@ void losetup_main(void)
loopback_setup(NULL, *toys.optargs);
} else if (FLAG(a) || FLAG(j)) {
if (toys.optc) error_exit("bad args");
- dirtree_read("/dev", dash_a);
+ dirtree_read(TT.dir, dash_a);
// Do we need one DEVICE argument?
} else {
char *file = (FLAG(c) || FLAG(d)) ? NULL : toys.optargs[1];