hosted: Fix USB mounting code to work with HAVE_MULTIDRIVE enabled

Change-Id: I48944c28903db117d3d883a5e777cafe5d055600
This commit is contained in:
Solomon Peachy 2020-10-17 17:25:38 -04:00
parent f3ec58c05b
commit 6f9a157fca
3 changed files with 50 additions and 9 deletions

View file

@ -27,8 +27,16 @@
#include "sysfs.h"
#include "power.h"
//#define LOGF_ENABLE
#include "logf.h"
static bool adb_mode = false;
#ifdef HAVE_MULTIDRIVE
void cleanup_rbhome(void);
void startup_rbhome(void);
#endif
/* TODO: implement usb detection properly */
int usb_detect(void)
{
@ -37,6 +45,8 @@ int usb_detect(void)
void usb_enable(bool on)
{
logf("usb enable %d %d\n", on, adb_mode);
/* Ignore usb enable/disable when ADB is enabled so we can fireup adb shell
* without entering ums mode
*/
@ -65,11 +75,16 @@ int disk_mount_all(void)
int rval = mount(dev[i], PIVOT_ROOT, fs[j], 0, NULL);
if (rval == 0 || errno == -EBUSY)
{
logf("mount good! %d/%d %d %d", i, j, rval, errno);
#ifdef HAVE_MULTIDRIVE
startup_rbhome();
#endif
return 1;
}
}
}
logf("mount failed! %d", errno);
return 0;
}
@ -79,12 +94,22 @@ int disk_mount_all(void)
*/
int disk_unmount_all(void)
{
if (umount("/mnt/sd_0") == 0)
#ifdef HAVE_MULTIDRIVE
cleanup_rbhome();
#endif
if (umount(PIVOT_ROOT) == 0)
{
sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0");
logf("umount_all good");
return 1;
}
logf("umount_all failed! %d", errno);
#ifdef HAVE_MULTIDRIVE
startup_rbhome();
#endif
return 0;
}