Skip to content

Commit

Permalink
v2021.12.2 (202112020)
Browse files Browse the repository at this point in the history
- Enhanced flashable zip generator;
- Implemented `losetup` wrapper for greater compatibility;
- Improved partition and image file mount logics;
- Preliminary work on the _appdata_ binding wizard;
- Reordered emulated storage prefix fallbacks to cover another Android 11+ quirk.
  • Loading branch information
VR-25 committed Dec 2, 2021
1 parent 9b29d07 commit 8a7f62f
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 83 deletions.
41 changes: 20 additions & 21 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ <h2 id="warning">WARNING</h2>
<hr>
<h2 id="pre-requisites">PRE-REQUISITES</h2>
<ul>
<li>Android or Android-based OS rooted with <a href="https://github.com/topjohnwu/Magisk/">Magisk</a></li>
<li><a href="https://forum.xda-developers.com/showpost.php?p=82561353&amp;postcount=207/">cryptsetup</a> (for encryption, optional)</li>
<li>Android or Android-based OS rooted with <a href="https://github.com/topjohnwu/Magisk">Magisk</a></li>
<li><a href="https://forum.xda-developers.com/showpost.php?p=82561353&amp;postcount=207">cryptsetup</a> (for encryption, optional)</li>
<li>Terminal emulator (or adb shell) and/or text editor</li>
</ul>
<p>Note: executables such as <code>cryptsetup</code> can be placed in <code>/data/adb/vr25/bin/</code> (with proper permissions) instead of being installed system-wide.</p>
Expand Down Expand Up @@ -263,28 +263,19 @@ <h2 id="notes">NOTES</h2>
<h2 id="links">LINKS</h2>
<ul>
<li><a href="https://app.airtm.com/send-or-request/send">Donate - Airtm, username: ivandro863auzqg</a></li>
<li><a href="https://liberapay.com/vr25/">Donate - Liberapay</a></li>
<li><a href="https://patreon.com/vr25/">Donate - Patreon</a></li>
<li><a href="https://liberapay.com/vr25">Donate - Liberapay</a></li>
<li><a href="https://patreon.com/vr25">Donate - Patreon</a></li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=iprj25@gmail.com&amp;lc=US&amp;item_name=VR25+is+creating+free+and+open+source+software.+Donate+to+suppport+their+work.&amp;no_note=0&amp;cn=&amp;currency_code=USD&amp;bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted">Donate - PayPal or Credit/Debit Card</a></li>
<li><a href="https://fb.me/vr25xda/">Facebook page</a></li>
<li><a href="https://github.com/vr-25/fbind/">Git repository</a></li>
<li><a href="https://t.me/vr25_xda/">Telegram channel</a></li>
<li><a href="https://t.me/fbind_group/">Telegram group</a></li>
<li><a href="https://t.me/vr25xda/">Telegram profile</a></li>
<li><a href="https://forum.xda-developers.com/apps/magisk/module-magic-folder-binder-t3621814/">XDA thread</a></li>
<li><a href="https://fb.me/vr25xda">Facebook Page</a></li>
<li><a href="https://t.me/vr25_xda">Telegram Channel</a></li>
<li><a href="https://t.me/fbind_group">Telegram Group</a></li>
<li><a href="https://t.me/vr25xda">Telegram Profile</a></li>
<li><a href="https://github.com/vr-25/fbind">Upstream Repository</a></li>
<li><a href="https://forum.xda-developers.com/apps/magisk/module-magic-folder-binder-t3621814">XDA Thread</a></li>
</ul>
<hr>
<h2 id="latest-changes">LATEST CHANGES</h2>
<p><strong>v2021.11.15-beta (202111150)</strong></p>
<ul>
<li>Added several fallback paths for intsd and extsd for greater out of the box experience</li>
<li>Enhanced unmount function</li>
<li>Fixed: fbind hangs when sdcard is unavailable</li>
<li>General fixes &amp; optimizations</li>
<li>More Android 11+ specific changes; already working at least on a handful of Android 11 devices</li>
<li>[Wizard] Rename existing destination directories instead of removing them</li>
</ul>
<p><strong>v2021.11.17-beta (202111170)</strong></p>
<p>v2021.11.17-beta (202111170)</p>
<ul>
<li>Enhanced storage paths fallbacks logic</li>
<li><code>fbind -v|--version</code> prints version code (integer)</li>
Expand All @@ -294,11 +285,19 @@ <h2 id="latest-changes">LATEST CHANGES</h2>
<li>Increased loop timeout to 5 minutes to accommodate long boot times</li>
<li>Updated documentation</li>
</ul>
<p><strong>v2021.11.22-beta (202111220)</strong></p>
<p>v2021.11.22-beta (202111220)</p>
<ul>
<li><code>-t|--test-prefixes</code>: test internal storage prefixes (views) and automatically update the config.</li>
<li>Changed the priorities of emulated storage views to better accommodate Android 11+.</li>
<li>General optimizations</li>
</ul>
<p>v2021.12.2 (202112020)</p>
<ul>
<li>Enhanced flashable zip generator;</li>
<li>Implemented <code>losetup</code> wrapper for greater compatibility;</li>
<li>Improved partition and image file mount logics;</li>
<li>Preliminary work on the <em>appdata</em> binding wizard;</li>
<li>Reordered emulated storage prefix fallbacks to cover another Android 11+ quirk.</li>
</ul>

</body>
Expand Down
39 changes: 19 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ By choosing to use/misuse it, you agree to do so at your own risk!
---
## PRE-REQUISITES

- Android or Android-based OS rooted with [Magisk](https://github.com/topjohnwu/Magisk/)
- [cryptsetup](https://forum.xda-developers.com/showpost.php?p=82561353&postcount=207/) (for encryption, optional)
- Android or Android-based OS rooted with [Magisk](https://github.com/topjohnwu/Magisk)
- [cryptsetup](https://forum.xda-developers.com/showpost.php?p=82561353&postcount=207) (for encryption, optional)
- Terminal emulator (or adb shell) and/or text editor

Note: executables such as `cryptsetup` can be placed in `/data/adb/vr25/bin/` (with proper permissions) instead of being installed system-wide.
Expand Down Expand Up @@ -269,29 +269,21 @@ If `/sbin` is missing (many Android 11 based systems lack it), use the `/dev/.vr
## LINKS

- [Donate - Airtm, username: ivandro863auzqg](https://app.airtm.com/send-or-request/send)
- [Donate - Liberapay](https://liberapay.com/vr25/)
- [Donate - Patreon](https://patreon.com/vr25/)
- [Donate - Liberapay](https://liberapay.com/vr25)
- [Donate - Patreon](https://patreon.com/vr25)
- [Donate - PayPal or Credit/Debit Card](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=iprj25@gmail.com&lc=US&item_name=VR25+is+creating+free+and+open+source+software.+Donate+to+suppport+their+work.&no_note=0&cn=&currency_code=USD&bn=PP-DonationsBF:btn_donateCC_LG.gif:NonHosted)
- [Facebook page](https://fb.me/vr25xda/)
- [Git repository](https://github.com/vr-25/fbind/)
- [Telegram channel](https://t.me/vr25_xda/)
- [Telegram group](https://t.me/fbind_group/)
- [Telegram profile](https://t.me/vr25xda/)
- [XDA thread](https://forum.xda-developers.com/apps/magisk/module-magic-folder-binder-t3621814/)
- [Facebook Page](https://fb.me/vr25xda)
- [Telegram Channel](https://t.me/vr25_xda)
- [Telegram Group](https://t.me/fbind_group)
- [Telegram Profile](https://t.me/vr25xda)
- [Upstream Repository](https://github.com/vr-25/fbind)
- [XDA Thread](https://forum.xda-developers.com/apps/magisk/module-magic-folder-binder-t3621814)


---
## LATEST CHANGES

**v2021.11.15-beta (202111150)**
- Added several fallback paths for intsd and extsd for greater out of the box experience
- Enhanced unmount function
- Fixed: fbind hangs when sdcard is unavailable
- General fixes & optimizations
- More Android 11+ specific changes; already working at least on a handful of Android 11 devices
- [Wizard] Rename existing destination directories instead of removing them

**v2021.11.17-beta (202111170)**
v2021.11.17-beta (202111170)
- Enhanced storage paths fallbacks logic
- `fbind -v|--version` prints version code (integer)
- Fixed auto-mount
Expand All @@ -300,7 +292,14 @@ If `/sbin` is missing (many Android 11 based systems lack it), use the `/dev/.vr
- Increased loop timeout to 5 minutes to accommodate long boot times
- Updated documentation

**v2021.11.22-beta (202111220)**
v2021.11.22-beta (202111220)
- `-t|--test-prefixes`: test internal storage prefixes (views) and automatically update the config.
- Changed the priorities of emulated storage views to better accommodate Android 11+.
- General optimizations

v2021.12.2 (202112020)
- Enhanced flashable zip generator;
- Implemented `losetup` wrapper for greater compatibility;
- Improved partition and image file mount logics;
- Preliminary work on the _appdata_ binding wizard;
- Reordered emulated storage prefix fallbacks to cover another Android 11+ quirk.
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=vr25.fbind
name=fbind
version=v2021.11.22-beta
versionCode=202111220
version=v2021.12.2
versionCode=202112020
author=VR25 @ xda-developers
description=fbind is a versatile mounting utility for folders, disk images, LUKS/LUKS2 encrypted volumes, regular partitions and more.
77 changes: 43 additions & 34 deletions system/bin/fbind
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
# License: GPLv3+


appdata() {
# appdata com.example.someapp
mkfs_ext2() {
local i=
for i in /*/*bin/mkfs.ext2 /sbin/mkfs.ext2 mkfs.ext2; do
if [ -x $i ] || which $i >/dev/null; then
eval $i "$@" && break || echo "(i) Trying alternative: $i..."
fi
done
}
#dd if=/dev/zero of="$extsd/.fbind/appdata/${1}.img" bs=1024 count=
}


apply_config() {

local i=
Expand All @@ -15,7 +29,7 @@ apply_config() {
grep -q '^extsd_path ' $config || default_extsd

# storage paths fallbacks
for i in $prefix /mnt/user/0 /mnt/runtime/write; do
for i in $prefix /mnt/runtime/write /mnt/user/0; do
is_mounted $i/emulated && prefix=$i && break || prefix=
done
[ -n "$prefix" ] && intsd=$prefix/emulated/0 || intsd=/data/media/0
Expand Down Expand Up @@ -194,8 +208,16 @@ intsd_path() {
is_mounted() { mountpoint -q "$1" 2>/dev/null; }


# mount loop device (loop <.img file> <mount point>)
# mount loop device (loop [-o mount_opts] <.img file> <mount point>)
loop() {
_losetup() {
local i=
for i in /*/*bin/losetup /sbin/losetup losetup; do
if [ -x $i ] || which $i >/dev/null; then
eval $i "$@" && break || echo "(i) Trying alternative: $i..."
fi
done
}
if echo "$1 $2" | grep -q '^\-o '; then # using extra mount options
local extraOpts="$1 $2"
shift 2
Expand All @@ -209,26 +231,21 @@ loop() {
if ! is_mounted "$2"; then
wait_storage "$@"
[ $? -ne 0 ] && return 1
wait_until_true [ -e $fPath ] || return 1
if ls /system/*bin/losetup >/dev/null 2>&1; then # magisk version of losetup seems not working, trying to use ROM's version
local pPath=$(/system/bin/losetup -fs "$fPath")
[ -e "$pPath" ] || return 1
if echo "$1" | grep -q '\-\-L'; then
if $interactiveMode || [ -n "$luksPass" ]; then
# open LUKS volume
if [ -n "$luksPass" ]; then
printf "$luksPass" | cryptsetup luksOpen $pPath $pName
else
cryptsetup luksOpen $pPath $pName
fi
pPath="/dev/mapper/$pName"
wait_until_true test -e $fPath || return 1
local pPath=$(_losetup -fs "$fPath")
[ -e "$pPath" ] || return 1
if echo "$1" | grep -q '\-\-L'; then
if $interactiveMode || [ -n "$luksPass" ]; then
# open LUKS volume
if [ -n "$luksPass" ]; then
printf "$luksPass" | cryptsetup luksOpen $pPath $pName
else
cryptsetup luksOpen $pPath $pName
fi
pPath="/dev/mapper/$pName"
fi
[ -e "$pPath" ] && mount_dev "$pPath" "$2" "$extraOpts"
else
$interactiveMode && echo "(!) Can't find program \"losetup\" to mount loop device."
return 1
fi
[ -e "$pPath" ] && mount_dev "$pPath" "$2" "$extraOpts"
fi
}

Expand Down Expand Up @@ -367,7 +384,7 @@ part() {
[ -z "$2" ] && return 1

if ! is_mounted "$2"; then
wait_storage "$@" && wait_until_true [ -e $pPath ] || return 1
wait_storage "$@" && wait_until_true test -e $pPath || return 1
if echo "$1" | grep -q '\-\-L'; then
if $interactiveMode || [ -n "$luksPass" ]; then
# open LUKS volume
Expand Down Expand Up @@ -662,23 +679,15 @@ wait_storage() {


wait_until_true() {
(set +x

local _=
([ -n "$1" ] || set -- grep -Eq ' /storage/emulated (fuse|sdcardfs) ' /proc/mounts
for _ in $(seq 100); do
grep -Eq ' /storage/emulated (fuse|sdcardfs) ' /proc/mounts && break || {
eval "$@" && break || {
$interactiveMode && return 1
sleep 3
}
done

if [ -n "$1" ]; then
for _ in $(seq 100); do
"$@" && break || {
$interactiveMode && return 1
sleep 3
}
done
fi)
set +x
done)
}


Expand Down Expand Up @@ -758,7 +767,7 @@ interactiveMode=true
dataDir=/data/adb/vr25/fbind-data
config=$dataDir/config.txt
: ${prefix:=$(sed -n 's/^prefix=//p' $config 2>/dev/null)}
: ${prefix:=/mnt/user/0}
: ${prefix:=/mnt/runtime/write}
intsd=$prefix/emulated/0
obb=$intsd/Android/obb

Expand Down
14 changes: 8 additions & 6 deletions zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ echo
trap 'e=$?; echo; exit $e' EXIT
cd "${0%/*}" 2>/dev/null

sh -n system/bin/fbind && {
filename=fbind-$(date +%Y.%m.%d.%H.%M.%S).zip
echo $filename
mkdir -p _builds
zip -r9 _builds/$filename * .git* -x \*.zip -x .git/\* -x '_*/*'
}
for i in system/bin/fbind *.sh; do
sh -n $i || exit
done

filename=fbind_magisk_$(date +%Y-%m-%d_%H:%M:%S).zip
echo _builds/$filename
mkdir -p _builds
zip -r9 _builds/$filename * .git* -x \*.zip -x .git/\* -x '_*/*'

0 comments on commit 8a7f62f

Please sign in to comment.