Skip to content

Commit c2e9e57

Browse files
authored
add vfat remounting script (#28)
* add new mounting script * update makefile
1 parent b011738 commit c2e9e57

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DEVICE_TEMP_DIRECTORY := /data/local/tmp
1414

1515
ALL_SCRIPTS := \
1616
scripts/mount_ext4.sh \
17+
scripts/remount_vfat.sh \
1718
scripts/unmount.sh \
1819
scripts/find_device.sh \
1920
scripts/show_devices.sh \
@@ -29,10 +30,10 @@ mobile-install: pixel-backup-gang-$(PBG_VERSION).tar.gz
2930
# copy the tarball containing scripts
3031
$(HOST_ADB_COMMAND) push ./pixel-backup-gang-$(PBG_VERSION).tar.gz $(DEVICE_TEMP_DIRECTORY)
3132
# extract the scripts
32-
$(HOST_ADB_COMMAND) shell /sbin/su --command 'tar -xvf $(DEVICE_TEMP_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION).tar.gz -C $(DEVICE_INSTALL_DIRECTORY)'
33+
$(HOST_ADB_COMMAND) shell su --command 'tar -xvf $(DEVICE_TEMP_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION).tar.gz -C $(DEVICE_INSTALL_DIRECTORY)'
3334
# make the scripts executable
34-
$(HOST_ADB_COMMAND) shell /sbin/su --command 'chmod +x $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION)/*.sh'
35-
# done, installed scripts to $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang-$(PBG_VERSION)
35+
$(HOST_ADB_COMMAND) shell su --command 'chmod +x $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang/*.sh'
36+
# done, installed scripts to $(DEVICE_INSTALL_DIRECTORY)/pixel-backup-gang
3637

3738
.PHONY: clean
3839
clean:

scripts/remount_vfat.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh -e
2+
3+
################################################################################
4+
# Description: remounts /the_binding in the specified mounted vfat folder to the internal storage
5+
# Author: Vivek Revankar <vivek@master-hax.com>
6+
# Usage: ./remount_vfat.sh <DIRECTORY_PATH>
7+
# Example: ./remount_vfat.sh /mnt/media_rw/2IDK-11F4
8+
################################################################################
9+
10+
if [ "$(readlink /proc/self/ns/mnt)" != "$(readlink /proc/1/ns/mnt)" ]; then
11+
echo "not running in global mount namespace, try elevating first"
12+
exit 1
13+
fi
14+
15+
if [ "$#" -ne 1 ]; then
16+
echo "Usage: $0 /mnt/media_rw/<label>" >&2
17+
exit 1
18+
fi
19+
20+
mounted_drive_path=$1
21+
if [ ! -e "$mounted_drive_path" ]; then
22+
echo "directory was not found"
23+
exit 1
24+
fi
25+
if [ ! -d "$mounted_drive_path" ]; then
26+
echo "path was not a directory"
27+
exit 1
28+
fi
29+
30+
fs_type=$(stat -f -c %T $mounted_drive_path)
31+
if [ "$fs_type" != "msdos" ]; then
32+
echo "detected filesystem type was not 'msdos', found $fs_type"
33+
exit 1
34+
fi
35+
36+
drive_binding_dir="$mounted_drive_path/the_binding"
37+
internal_binding_dir="/mnt/runtime/write/emulated/0/the_binding"
38+
mkdir -p -v "$drive_binding_dir"
39+
mkdir -p -v "$internal_binding_dir"
40+
mount \
41+
-t sdcardfs \
42+
-o nosuid,nodev,noexec,noatime,gid=9997 \
43+
"$drive_binding_dir" "$internal_binding_dir"
44+
45+
echo "vfat drive remounted succesfully"

0 commit comments

Comments
 (0)