summaryrefslogtreecommitdiff
path: root/firmware/include/dircache_redirect.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/include/dircache_redirect.h')
-rw-r--r--firmware/include/dircache_redirect.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h
index ddd86c6d86..d7314cf3b1 100644
--- a/firmware/include/dircache_redirect.h
+++ b/firmware/include/dircache_redirect.h
@@ -24,6 +24,7 @@
24#include "pathfuncs.h" 24#include "pathfuncs.h"
25#include "dir.h" 25#include "dir.h"
26#include "dircache.h" 26#include "dircache.h"
27#include "file.h"
27 28
28#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER) 29#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER)
29#include "rb-loader.h" 30#include "rb-loader.h"
@@ -185,22 +186,33 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume))
185 186
186 if (multiboot_is_boot_volume(IF_MV_VOL(volume))) 187 if (multiboot_is_boot_volume(IF_MV_VOL(volume)))
187 { 188 {
188 int rtlen = get_redirect_dir(rtpath, sizeof(rtpath), volume, "", ""); 189 /* get the full path to the BOOTFILE
189 while (rtlen > 0 && rtpath[--rtlen] == PATH_SEPCH) 190 ie. /<0>/redirectdir/.rockbox/rockbox.ext */
190 rtpath[rtlen] = '\0'; /* remove extra separators */ 191 int rtlen = get_redirect_dir(rtpath, sizeof(rtpath),
192 volume, BOOTDIR, BOOTFILE);
193
194 if (rtlen <= 0 || rtlen >= (int) sizeof(rtpath))
195 rtlen = 0; /* path too long or sprintf error */
196 else if (file_exists(rtpath))
197 {
198 rtlen = get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "");
199 while (rtlen > 0 && rtpath[--rtlen] == PATH_SEPCH)
200 rtpath[rtlen] = '\0'; /* remove separators */
201 }
202 else
203 rtlen = 0; /* No BOOTFILE found */
191 204
192#if 0 /*removed, causes issues with playback for now?*/ 205#if 0 /*removed, causes issues with playback for now?*/
193 if (rtlen <= 0 || rtpath[rtlen] == VOL_END_TOK) 206 if (rtlen <= 0 || rtpath[rtlen] == VOL_END_TOK)
194 root_unmount_volume(volume); /* unmount so root can be hidden*/ 207 root_unmount_volume(volume); /* unmount so root can be hidden*/
195#endif 208#endif
196 if (rtlen <= 0) /* Error occurred, card removed? Set root to default */ 209 if (rtlen <= 0 || root_mount_path(rtpath, NSITEM_CONTENTS) != 0)
197 { 210 { /* Error occurred, card removed? Set root to default */
211 boot_data_valid = false;
198 root_unmount_volume(volume); /* unmount so root can be hidden*/ 212 root_unmount_volume(volume); /* unmount so root can be hidden*/
199 goto standard_redirect; 213 goto standard_redirect;
200 } 214 }
201 root_mount_path(rtpath, NSITEM_CONTENTS);
202 } 215 }
203
204 } 216 }
205 else 217 else
206 { 218 {