Skip to content

Commit

Permalink
add vfat remounting script (#28)
Browse files Browse the repository at this point in the history
* add new mounting script

* update makefile
  • Loading branch information
master-hax authored Oct 31, 2024
1 parent b011738 commit c2e9e57
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ DEVICE_TEMP_DIRECTORY := /data/local/tmp

ALL_SCRIPTS := \
scripts/mount_ext4.sh \
scripts/remount_vfat.sh \
scripts/unmount.sh \
scripts/find_device.sh \
scripts/show_devices.sh \
Expand All @@ -29,10 +30,10 @@ mobile-install: pixel-backup-gang-$(PBG_VERSION).tar.gz
# copy the tarball containing scripts
$(HOST_ADB_COMMAND) push ./pixel-backup-gang-$(PBG_VERSION).tar.gz $(DEVICE_TEMP_DIRECTORY)
# extract the scripts
$(HOST_ADB_COMMAND) shell /sbin/su --command 'tar -xvf $(DEVICE_TEMP_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION).tar.gz -C $(DEVICE_INSTALL_DIRECTORY)'
$(HOST_ADB_COMMAND) shell su --command 'tar -xvf $(DEVICE_TEMP_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION).tar.gz -C $(DEVICE_INSTALL_DIRECTORY)'
# make the scripts executable
$(HOST_ADB_COMMAND) shell /sbin/su --command 'chmod +x $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION)/*.sh'
# done, installed scripts to $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION)
$(HOST_ADB_COMMAND) shell su --command 'chmod +x $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang/*.sh'
# done, installed scripts to $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang

.PHONY: clean
clean:
Expand Down
45 changes: 45 additions & 0 deletions scripts/remount_vfat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/sh -e

################################################################################
# Description: remounts /the_binding in the specified mounted vfat folder to the internal storage
# Author: Vivek Revankar <vivek@master-hax.com>
# Usage: ./remount_vfat.sh <DIRECTORY_PATH>
# Example: ./remount_vfat.sh /mnt/media_rw/2IDK-11F4
################################################################################

if [ "$(readlink /proc/self/ns/mnt)" != "$(readlink /proc/1/ns/mnt)" ]; then
echo "not running in global mount namespace, try elevating first"
exit 1
fi

if [ "$#" -ne 1 ]; then
echo "Usage: $0 /mnt/media_rw/<label>" >&2
exit 1
fi

mounted_drive_path=$1
if [ ! -e "$mounted_drive_path" ]; then
echo "directory was not found"
exit 1
fi
if [ ! -d "$mounted_drive_path" ]; then
echo "path was not a directory"
exit 1
fi

fs_type=$(stat -f -c %T $mounted_drive_path)
if [ "$fs_type" != "msdos" ]; then
echo "detected filesystem type was not 'msdos', found $fs_type"
exit 1
fi

drive_binding_dir="$mounted_drive_path/the_binding"
internal_binding_dir="/mnt/runtime/write/emulated/0/the_binding"
mkdir -p -v "$drive_binding_dir"
mkdir -p -v "$internal_binding_dir"
mount \
-t sdcardfs \
-o nosuid,nodev,noexec,noatime,gid=9997 \
"$drive_binding_dir" "$internal_binding_dir"

echo "vfat drive remounted succesfully"

0 comments on commit c2e9e57

Please sign in to comment.