Skip to content

Commit

Permalink
**v2021.11.15-beta (202111150)**
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
VR-25 committed Nov 15, 2021
1 parent 55e7959 commit 93bfc69
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 51 deletions.
8 changes: 8 additions & 0 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ <h2 id="latest-changes">LATEST CHANGES</h2>
<li>Fixed <code>umount</code> issues</li>
<li>General enhancements</li>
<li>Updated flashable zip generator</li>
</ul>
<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>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>

</body>
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,11 @@ If`/sbin` is missing (many Android 11 based systems lack it), use the `/dev/.vr2
- Fixed `umount` issues
- General enhancements
- Updated flashable zip generator

**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
22 changes: 2 additions & 20 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
Daemon to remount folders periodically?
Android 11 storage isolation support

~# bindfs -u $(stat -c %u /sdcard/Android/data/com.termux) -g 9997 -p a-rwx,ug+rw,ug+X /mnt/media_rw/[UUID]/Android/data/com.termux /mnt/runtime/write/emulated/0/Android/data/com.termux

bindfs approach
~# DIR=/mnt/media_rw/[UUID] # for Portable Storage
~# DIR=/mnt/expand/[UUID] # for Adoptable Storage
~# mkdir $DIR/WhatsApp
~# mv /sdcard/WhatsApp/* $DIR/WhatsApp/
~# bindfs -o nosuid,nodev,noexec,noatime,context=u:object_r:sdcardfs:s0 -u 0 -g 9997 -p a-rwx,ug+rw,ugo+X --create-with-perms=a-rwx,ug+rw,ugo+X --xattr-none --chown-ignore --chgrp-ignore --chmod-ignore $DIR/WhatsApp /mnt/runtime/write/emulated/0/WhatsApp

mount sdcard manually
~# mount -t exfat -o nosuid,nodev,noexec,noatime,context=u:object_r:sdcardfs:s0,uid=0,gid=9997,fmask=0117,dmask=0006 /dev/block/sda1 /mnt/runtime/write/emulated/0/WhatsApp
~# mv /data/media/0/WhatsApp/* /sdcard/WhatsApp/
~# mount -o bind /mnt/my_sdcard/WhatsApp /mnt/runtime/write/emulated/0/WhatsApp

sdcardfs approach
~# mkdir /mnt/expand/[UUID]/media/0/WhatsApp
~# mv /sdcard/WhatsApp/* /mnt/expand/[UUID]/media/0/WhatsApp/
~# restorecon -rv /mnt/expand/[UUID]/media/
~# mount -t sdcardfs -o nosuid,nodev,noexec,noatime,mask=7,gid=9997 /mnt/expand/[UUID]/media/0/WhatsApp /mnt/runtime/write/emulated/0/Whatsapp
Android 11 storage isolation support
# bindfs -o nosuid,nodev,noexec,noatime,context=u:object_r:sdcardfs:s0 -u $(stat -c %u /sdcard/Android/data/com.termux) -g 9997 -p a-rwx,ug+rw,ugo+X --create-with-perms=a-rwx,ug+rw,ugo+X --xattr-none --chown-ignore --chgrp-ignore --chmod-ignore /mnt/media_rw/[UUID]/Android/data/com.termux /mnt/runtime/write/emulated/0/Android/data/com.termux
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.14-beta
versionCode=202111140
version=v2021.11.15-beta
versionCode=202111150
author=VR25 @ xda-developers
description=fbind is a versatile mounting utility for folders, disk images, LUKS/LUKS2 encrypted volumes, regular partitions and more.
71 changes: 42 additions & 29 deletions system/bin/fbind
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,31 @@ apply_config() {
[ -f $config ] || touch $config
grep -iq '^permissive' $config && setenforce 0

# intsd in FUSE mode?
if grep -q '/storage/emulated fuse' /proc/mounts; then
intsd=/data/media/0
if ! is_mounted ${intsd%/*} && ! is_mounted $intsd; then
intsd=/mnt/pass_through/0/emulated/0
if ! is_mounted ${intsd%/*} && ! is_mounted $intsd; then
intsd=/data/media/0
fi
obb=$intsd/Android/obb
fi

# set default extsd if not defined in config so loop/part can use it
grep -q '^extsd_path ' $config || default_extsd

grep -E '^extsd_path |^intsd_path |^part |^loop ' $config > $tmpf
. $tmpf
rm $tmpf

# extsd in FUSE mode?
if grep -q "/mnt/media_rw/${extsd##*/} fuse" /proc/mounts; then
extsd0=$extsd
extobb0=$extobb
if ! is_mounted ${extsd%/*} && ! is_mounted $extsd; then
extsd=/mnt/media_rw/${extsd##*/}
if ! is_mounted ${extsd%/*} && ! is_mounted $extsd; then
extsd=/mnt/pass_through/0/${extsd##*/}
if ! is_mounted ${extsd%/*} && ! is_mounted $extsd; then
extsd=$intsd
fi
fi
extobb=$extsd/Android/obb
fi

grep -E '^extsd_path |^intsd_path |^part |^loop ' $config > $tmpf
. $tmpf
rm $tmpf
}


Expand All @@ -41,8 +46,8 @@ bind_mount() {
wait_storage "$@" || return 1
fi
mkdir -p "$1" "$2"
if [ -x $modDir/bin/bindfs ]; then
su -Mc $modDir/bin/bindfs -o nosuid,nodev,noexec,noatime -u 0 -g 9997 -p a-rwx,ug+rw,ugo+X \
if which bindfs >/dev/null; then
su -Mc bindfs -o nosuid,nodev,noexec,noatime,nonempty -u 0 -g 9997 -p a-rwx,ug+rw,ugo+X \
--create-with-perms=a-rwx,ug+rw,ugo+X --xattr-none --chown-ignore \
--chgrp-ignore --chmod-ignore \""$1"\" \""$2"\" || {
echo "(i) Trying \"mount -o bind\"..."
Expand Down Expand Up @@ -123,7 +128,7 @@ default_extsd() {
fi
done
fi
! is_mounted $extsd && exit 1 || {
is_mounted $extsd && {
extsd=$prefix/${extsd##*/}
extobb=$extsd/Android/obb
mount -o remount,mask=0 $extsd 2>/dev/null ###
Expand Down Expand Up @@ -160,13 +165,8 @@ exit_wizard() {
# alternate extsd path
extsd_path() {
altExtsd=true
if [ $1 = $intsd ]; then
extsd=$intsd
extobb=$obb
else
extsd=$1
extobb=$extsd/Android/obb
fi
extsd="$1"
extobb="$extsd/Android/obb"
wait_until_true is_mounted "$1"
}

Expand Down Expand Up @@ -201,6 +201,7 @@ force_fuse() {
# set alternate intsd path
intsd_path() {
intsd="$1"
obb="$intsd/Android/obb"
}


Expand Down Expand Up @@ -293,7 +294,8 @@ mv_data() {
if ! is_mounted "$1" && [ -n "$(ls -Ad "$1" 2>/dev/null)" ]; then
echo
echo "$1 --> $2"
rm -rf "$2" 2>/dev/null
#rm -rf "$2" 2>/dev/null
mv "$2" "$2".old 2>/dev/null
if cp -R "$@"; then
rm -rf "$1" 2>/dev/null
return 0
Expand Down Expand Up @@ -494,6 +496,11 @@ unmount() {
local pattern="$(echo "$1" | sed -e "s|$prefix||" -e "s|$intsd||")"
/system/bin/mount | grep "$pattern type " >/dev/null 2>&1 && {
echo "<${pattern#/}>"
/system/bin/mount | grep "$pattern type " | sed -E -e 's|^.* on /|/|' -e "s|($pattern) type .*|\1|" | \
while IFS= read line; do
umount -f "$line" 2>/dev/null
done
# reverse order
/system/bin/mount | grep "$pattern type " | tac | sed -E -e 's|^.* on /|/|' -e "s|($pattern) type .*|\1|" | \
while IFS= read line; do
umount -f "$line" 2>/dev/null
Expand Down Expand Up @@ -628,13 +635,19 @@ wait_storage() {
wait_until_true() {
(set +x

while :; do
grep /storage/emulated /proc/mounts | grep -Eiq ' sdcardfs | fuse ' && break || sleep 3
for _ in $(seq 30); do
grep -Eq ' /storage/emulated type (fuse|sdcardfs) ' /proc/mounts && break || {
$interactiveMode && return 1
sleep 3
}
done

if [ -n "$1" ]; then
while :; do
$* && break || sleep 3
for _ in $(seq 30); do
$* && break || {
$interactiveMode && return 1
sleep 3
}
done
fi)
}
Expand Down Expand Up @@ -706,7 +719,7 @@ fi

case $PATH in
/data/adb/vr25/bin:*) :;;
*) export PATH=/data/adb/vr25/bin:$busyboxDir:$PATH;;
*) export PATH=/data/adb/vr25/bin:$busyboxDir:$modDir/bin:$PATH;;
esac

service=false
Expand Down Expand Up @@ -773,8 +786,8 @@ case $1 in

# wait until data is decrypted
(set +x
while :; do
[ -d /sdcard/Documents ] && break || sleep 3
for _ in $(seq 30); do
[ -d /storage/emulated/0/Documents ] && break || sleep 3
done)

wait_until_true
Expand Down

0 comments on commit 93bfc69

Please sign in to comment.