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