diff options
-rw-r--r-- | firmware/target/hosted/fiio/usb-fiio.c | 12 | ||||
-rw-r--r-- | firmware/target/hosted/filesystem-app.c | 20 | ||||
-rw-r--r-- | firmware/target/hosted/usb-hiby.c | 27 |
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 | ||
32 | void cleanup_rbhome(void); | ||
33 | void startup_rbhome(void); | ||
34 | #endif | ||
35 | |||
31 | const char * const sysfs_usb_online = | 36 | const 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 | */ |
69 | int disk_mount_all(void) | 74 | int 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 | */ |
78 | int disk_unmount_all(void) | 86 | int 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 */ |
103 | static void cleanup_rbhome(void) | 103 | void 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 | } |
108 | void 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 | ||
110 | void paths_init(void) | 119 | void 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 | |||
30 | static bool adb_mode = false; | 33 | static bool adb_mode = false; |
31 | 34 | ||
35 | #ifdef HAVE_MULTIDRIVE | ||
36 | void cleanup_rbhome(void); | ||
37 | void startup_rbhome(void); | ||
38 | #endif | ||
39 | |||
32 | /* TODO: implement usb detection properly */ | 40 | /* TODO: implement usb detection properly */ |
33 | int usb_detect(void) | 41 | int usb_detect(void) |
34 | { | 42 | { |
@@ -37,6 +45,8 @@ int usb_detect(void) | |||
37 | 45 | ||
38 | void usb_enable(bool on) | 46 | void 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 | */ |
80 | int disk_unmount_all(void) | 95 | int 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 | ||