diff options
author | Rob Landley <rob@landley.net> | 2017-12-02 21:18:52 -0600 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2018-10-07 18:04:43 +0300 |
commit | 8276aea646189d4204153f4c6614859ae9145c19 (patch) | |
tree | 82fde0a33529cd3c073f803807db2f48ff01804c | |
parent | 4841a344c3ca18193b655dc529587ba80a11d8b6 (diff) | |
download | android_external_toybox-lineage-15.1.tar.gz android_external_toybox-lineage-15.1.tar.bz2 android_external_toybox-lineage-15.1.zip |
Android has its loop devices under "block" as Elliott says "by reason oflineage-15.1
historical accident", so fall back to check there.
Also remove an obsolete comment TODO block, check !parent for dirtree
top of tree instead of '/' in the filename, and typecast some printf
arguments for 32-bit systems.
Change-Id: I121327367b5da0bf94c1d16f0ab0602ea263e729
-rw-r--r-- | toys/other/losetup.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/toys/other/losetup.c b/toys/other/losetup.c index 4e467a9c..e8f02aa9 100644 --- a/toys/other/losetup.c +++ b/toys/other/losetup.c @@ -45,16 +45,6 @@ GLOBALS( ino_t jino; ) -/* -todo: basic /dev file association - associate DEV FILE - #-a - cdfjosS - allocate new loop device: - /dev/loop-control - https://lkml.org/lkml/2011/7/26/148 -*/ - // -f: *device is NULL // Perform requested operation on one device. Returns 1 if handled, 0 if error @@ -75,8 +65,11 @@ 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 + 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); + } close(cfd); } } @@ -119,8 +112,8 @@ static void loopback_setup(char *device, char *file) free(s); } else if (flags & FLAG_f) printf("%s", device); else { - xprintf("%s: [%04llx]:%llu (%s)", device, loop->lo_device, loop->lo_inode, - loop->lo_file_name); + xprintf("%s: [%04llx]:%llu (%s)", device, (long long)loop->lo_device, + (long long)loop->lo_inode, loop->lo_file_name); if (loop->lo_offset) xprintf(", offset %llu", loop->lo_offset); if (loop->lo_sizelimit) xprintf(", sizelimit %llu", loop->lo_sizelimit); xputc('\n'); @@ -137,7 +130,7 @@ static int dash_a(struct dirtree *node) char *s = node->name; // Initial /dev node needs to recurse down one level, then only loop[0-9]* - if (*s == '/') return DIRTREE_RECURSE; + if (!node->parent) return DIRTREE_RECURSE; if (strncmp(s, "loop", 4) || !isdigit(s[4])) return 0; s = dirtree_path(node, 0); |