summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-17 17:25:38 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-17 18:38:49 -0400
commit6f9a157fcac76466df8834eb73e04d7127e78b52 (patch)
treea40ab1aa102fae0c70feeed9b6f44c78d711d947
parentf3ec58c05b1f0044240cf5e95ff28e6966398958 (diff)
downloadrockbox-6f9a157fcac76466df8834eb73e04d7127e78b52.tar.gz
rockbox-6f9a157fcac76466df8834eb73e04d7127e78b52.zip
hosted: Fix USB mounting code to work with HAVE_MULTIDRIVE enabled
Change-Id: I48944c28903db117d3d883a5e777cafe5d055600
-rw-r--r--firmware/target/hosted/fiio/usb-fiio.c12
-rw-r--r--firmware/target/hosted/filesystem-app.c20
-rw-r--r--firmware/target/hosted/usb-hiby.c27
3 files changed, 50 insertions, 9 deletions
diff --git a/firmware/target/hosted/fiio/usb-fiio.c b/firmware/target/hosted/fiio/usb-fiio.c
index 3084ee0169..3b1a149eea 100644
--- a/firmware/target/hosted/fiio/usb-fiio.c
+++ b/firmware/target/hosted/fiio/usb-fiio.c
@@ -28,6 +28,11 @@
28#include "power.h" 28#include "power.h"
29#include "power-fiio.h" 29#include "power-fiio.h"
30 30
31#ifdef HAVE_MULTIDRIVE
32void cleanup_rbhome(void);
33void startup_rbhome(void);
34#endif
35
31const char * const sysfs_usb_online = 36const char * const sysfs_usb_online =
32 "/sys/class/power_supply/usb/online"; 37 "/sys/class/power_supply/usb/online";
33 38
@@ -68,6 +73,9 @@ void usb_enable(bool on)
68*/ 73*/
69int disk_mount_all(void) 74int disk_mount_all(void)
70{ 75{
76#ifdef HAVE_MULTIDRIVE
77 startup_rbhome();
78#endif
71 return 1; 79 return 1;
72} 80}
73 81
@@ -77,6 +85,10 @@ int disk_mount_all(void)
77 */ 85 */
78int disk_unmount_all(void) 86int disk_unmount_all(void)
79{ 87{
88#ifdef HAVE_MULTIDRIVE
89 cleanup_rbhome();
90#endif
91
80 return 1; 92 return 1;
81} 93}
82 94
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c
index 93057e7a83..2121af7752 100644
--- a/firmware/target/hosted/filesystem-app.c
+++ b/firmware/target/hosted/filesystem-app.c
@@ -100,11 +100,20 @@ static const char *handle_special_links(const char* link, unsigned flags,
100 100
101/* we keep an open descriptor of the home directory to detect when it has been 101/* we keep an open descriptor of the home directory to detect when it has been
102 opened by opendir() so that its "symlinks" may be enumerated */ 102 opened by opendir() so that its "symlinks" may be enumerated */
103static void cleanup_rbhome(void) 103void cleanup_rbhome(void)
104{ 104{
105 os_close(rbhome_fildes); 105 os_close(rbhome_fildes);
106 rbhome_fildes = -1; 106 rbhome_fildes = -1;
107} 107}
108void startup_rbhome(void)
109{
110 /* if this fails then alternate volumes will not work, but this function
111 cannot return that fact */
112 rbhome_fildes = os_opendirfd(rbhome);
113 if (rbhome_fildes >= 0)
114 atexit(cleanup_rbhome);
115}
116
108#endif /* HAVE_MULTIDRIVE */ 117#endif /* HAVE_MULTIDRIVE */
109 118
110void paths_init(void) 119void paths_init(void)
@@ -140,14 +149,9 @@ void paths_init(void)
140 os_mkdir(config_dir __MKDIR_MODE_ARG); 149 os_mkdir(config_dir __MKDIR_MODE_ARG);
141#endif 150#endif
142#endif /* HAVE_SPECIAL_DIRS */ 151#endif /* HAVE_SPECIAL_DIRS */
143
144#ifdef HAVE_MULTIDRIVE 152#ifdef HAVE_MULTIDRIVE
145 /* if this fails then alternate volumes will not work, but this function 153 startup_rbhome();
146 cannot return that fact */ 154#endif
147 rbhome_fildes = os_opendirfd(rbhome);
148 if (rbhome_fildes >= 0)
149 atexit(cleanup_rbhome);
150#endif /* HAVE_MULTIDRIVE */
151} 155}
152 156
153#ifdef HAVE_SPECIAL_DIRS 157#ifdef HAVE_SPECIAL_DIRS
diff --git a/firmware/target/hosted/usb-hiby.c b/firmware/target/hosted/usb-hiby.c
index 6c35e76e29..b82fa5c4ce 100644
--- a/firmware/target/hosted/usb-hiby.c
+++ b/firmware/target/hosted/usb-hiby.c
@@ -27,8 +27,16 @@
27#include "sysfs.h" 27#include "sysfs.h"
28#include "power.h" 28#include "power.h"
29 29
30//#define LOGF_ENABLE
31#include "logf.h"
32
30static bool adb_mode = false; 33static bool adb_mode = false;
31 34
35#ifdef HAVE_MULTIDRIVE
36void cleanup_rbhome(void);
37void startup_rbhome(void);
38#endif
39
32/* TODO: implement usb detection properly */ 40/* TODO: implement usb detection properly */
33int usb_detect(void) 41int usb_detect(void)
34{ 42{
@@ -37,6 +45,8 @@ int usb_detect(void)
37 45
38void usb_enable(bool on) 46void usb_enable(bool on)
39{ 47{
48 logf("usb enable %d %d\n", on, adb_mode);
49
40 /* Ignore usb enable/disable when ADB is enabled so we can fireup adb shell 50 /* Ignore usb enable/disable when ADB is enabled so we can fireup adb shell
41 * without entering ums mode 51 * without entering ums mode
42 */ 52 */
@@ -65,11 +75,16 @@ int disk_mount_all(void)
65 int rval = mount(dev[i], PIVOT_ROOT, fs[j], 0, NULL); 75 int rval = mount(dev[i], PIVOT_ROOT, fs[j], 0, NULL);
66 if (rval == 0 || errno == -EBUSY) 76 if (rval == 0 || errno == -EBUSY)
67 { 77 {
78 logf("mount good! %d/%d %d %d", i, j, rval, errno);
79#ifdef HAVE_MULTIDRIVE
80 startup_rbhome();
81#endif
68 return 1; 82 return 1;
69 } 83 }
70 } 84 }
71 } 85 }
72 86
87 logf("mount failed! %d", errno);
73 return 0; 88 return 0;
74} 89}
75 90
@@ -79,12 +94,22 @@ int disk_mount_all(void)
79 */ 94 */
80int disk_unmount_all(void) 95int disk_unmount_all(void)
81{ 96{
82 if (umount("/mnt/sd_0") == 0) 97#ifdef HAVE_MULTIDRIVE
98 cleanup_rbhome();
99#endif
100
101 if (umount(PIVOT_ROOT) == 0)
83 { 102 {
84 sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0"); 103 sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0");
104 logf("umount_all good");
85 return 1; 105 return 1;
86 } 106 }
87 107
108 logf("umount_all failed! %d", errno);
109#ifdef HAVE_MULTIDRIVE
110 startup_rbhome();
111#endif
112
88 return 0; 113 return 0;
89} 114}
90 115