summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/ffconf.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2016-02-10 16:32:57 +0000
committerDamien George <damien.p.george@gmail.com>2016-02-10 23:40:10 +0000
commitb33a7705966a743c5e4c0c3c3bb83e6d97b5e84d (patch)
tree2c62a5389a7f0189119b5fcbbb9b30f0ff5b9db5 /stmhal/ffconf.c
parent34023eb673d5356bb4eb6fc635d6d48eefb35135 (diff)
downloadmicropython-b33a7705966a743c5e4c0c3c3bb83e6d97b5e84d.tar.gz
micropython-b33a7705966a743c5e4c0c3c3bb83e6d97b5e84d.zip
extmod/fsusermount: Support mounting of multiple block devices.
This patch adds support to fsusermount for multiple block devices (instead of just one). The maximum allowed is fixed at compile time by the size of the fs_user_mount array accessed via MP_STATE_PORT, which in turn is set by MICROPY_FATFS_VOLUMES. With this patch, stmhal (which is still tightly coupled to fsusermount) is also modified to support mounting multiple devices And the flash and SD card are now just two block devices that are mounted at start up if they exist (and they have special native code to make them more efficient).
Diffstat (limited to 'stmhal/ffconf.c')
-rw-r--r--stmhal/ffconf.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/stmhal/ffconf.c b/stmhal/ffconf.c
index 74336310a7..6cd140f227 100644
--- a/stmhal/ffconf.c
+++ b/stmhal/ffconf.c
@@ -60,26 +60,18 @@ int ff_get_ldnumber (const TCHAR **path) {
#endif
}
- if (check_path(path, "/flash", 6)) {
- return PD_FLASH;
- } else if (check_path(path, "/sd", 3)) {
- return PD_SDCARD;
- } else if (MP_STATE_PORT(fs_user_mount) != NULL && check_path(path, MP_STATE_PORT(fs_user_mount)->str, MP_STATE_PORT(fs_user_mount)->len)) {
- return PD_USER;
- } else {
- return -1;
+ for (size_t i = 0; i < MP_ARRAY_SIZE(MP_STATE_PORT(fs_user_mount)); ++i) {
+ fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[i];
+ if (vfs != NULL && check_path(path, vfs->str, vfs->len)) {
+ return i;
+ }
}
+
+ return -1;
}
void ff_get_volname(BYTE vol, TCHAR **dest) {
- if (vol == PD_FLASH) {
- memcpy(*dest, "/flash", 6);
- *dest += 6;
- } else if (vol == PD_SDCARD) {
- memcpy(*dest, "/sd", 3);
- *dest += 3;
- } else {
- memcpy(*dest, MP_STATE_PORT(fs_user_mount)->str, MP_STATE_PORT(fs_user_mount)->len);
- *dest += MP_STATE_PORT(fs_user_mount)->len;
- }
+ fs_user_mount_t *vfs = MP_STATE_PORT(fs_user_mount)[vol];
+ memcpy(*dest, vfs->str, vfs->len);
+ *dest += vfs->len;
}