From b6fce99046a3677f27373f8c701e6f200e290236 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 11 Apr 2021 09:10:55 -0400 Subject: ibasso: Implement proper PIVOT_ROOT filesystem access Including direct use of the external SD card mount Known issue: If SD card is inserted at startup, it must be ejected and reinserted to be registered. Change-Id: I5f420160bda32135cbb088c1e8b04b6e3a73018e --- firmware/target/hosted/ibasso/system-ibasso.c | 55 +++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'firmware/target/hosted/ibasso/system-ibasso.c') diff --git a/firmware/target/hosted/ibasso/system-ibasso.c b/firmware/target/hosted/ibasso/system-ibasso.c index 45a6514aa2..401bb3c442 100644 --- a/firmware/target/hosted/ibasso/system-ibasso.c +++ b/firmware/target/hosted/ibasso/system-ibasso.c @@ -28,6 +28,7 @@ #include "config.h" #include "debug.h" +#include "mv.h" #include "button-ibasso.h" #include "debug-ibasso.h" @@ -39,6 +40,8 @@ uintptr_t* stackbegin; uintptr_t* stackend; +/* forward-declare */ +bool os_file_exists(const char *ospath); void system_init(void) { @@ -95,3 +98,55 @@ void system_exception_wait(void) while(1) {}; } + +bool hostfs_removable(IF_MD_NONVOID(int drive)) +{ +#ifdef HAVE_MULTIDRIVE + if (drive > 0) + return true; + else +#endif + return false; /* internal: always present */ +} + +#ifdef HAVE_MULTIDRIVE +int volume_drive(int drive) +{ + return drive; +} +#endif /* HAVE_MULTIDRIVE */ + +#ifdef CONFIG_STORAGE_MULTI +int hostfs_driver_type(int drive) +{ + return drive > 0 ? STORAGE_SD_NUM : STORAGE_HOSTFS_NUM; +} +#endif /* CONFIG_STORAGE_MULTI */ + +bool hostfs_present(IF_MD_NONVOID(int drive)) +{ +#ifdef HAVE_MULTIDRIVE + if (drive > 0) +#if defined(MULTIDRIVE_DEV) + return os_file_exists(MULTIDRIVE_DEV); +#else + return extsd_present; +#endif + else +#endif + return true; /* internal: always present */ +} + +#ifdef HAVE_HOTSWAP +bool volume_removable(int volume) +{ + /* don't support more than one partition yet, so volume == drive */ + return hostfs_removable(volume); +} + +bool volume_present(int volume) +{ + /* don't support more than one partition yet, so volume == drive */ + return hostfs_present(volume); +} +#endif -- cgit v1.2.3