summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/disk.c18
-rw-r--r--firmware/include/dircache_redirect.h42
2 files changed, 59 insertions, 1 deletions
diff --git a/firmware/common/disk.c b/firmware/common/disk.c
index 3bd88f66a8..49137286a3 100644
--- a/firmware/common/disk.c
+++ b/firmware/common/disk.c
@@ -27,7 +27,7 @@
27#include "disk_cache.h" 27#include "disk_cache.h"
28#include "fileobj_mgr.h" 28#include "fileobj_mgr.h"
29#include "dir.h" 29#include "dir.h"
30#include "rb_namespace.h" 30#include "dircache_redirect.h"
31#include "disk.h" 31#include "disk.h"
32 32
33 33
@@ -249,7 +249,23 @@ int disk_mount_all(void)
249 for (int i = 0; i < NUM_VOLUMES; i++) 249 for (int i = 0; i < NUM_VOLUMES; i++)
250 vol_drive[i] = -1; /* mark all as unassigned */ 250 vol_drive[i] = -1; /* mark all as unassigned */
251 251
252#if defined(HAVE_BOOTDATA) && !defined(SIMULATOR) && !defined(BOOTLOADER)
253 unsigned int crc = 0;
254 int boot_volume = 0;
255 crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff);
256 if(crc == boot_data.crc)
257 {
258 boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */
259 }
260 #ifdef HAVE_HOTSWAP
261 if (storage_present(boot_volume))
262 #endif
263 mounted += disk_mount(boot_volume); /* mount boot volume first */
264 for (int i = 0; i < NUM_DRIVES; i++)
265 if (i != boot_volume)
266#else
252 for (int i = 0; i < NUM_DRIVES; i++) 267 for (int i = 0; i < NUM_DRIVES; i++)
268#endif
253 { 269 {
254 #ifdef HAVE_HOTSWAP 270 #ifdef HAVE_HOTSWAP
255 if (storage_present(i)) 271 if (storage_present(i))
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h
index 9a8de2fecd..e8cf8dc8f5 100644
--- a/firmware/include/dircache_redirect.h
+++ b/firmware/include/dircache_redirect.h
@@ -25,6 +25,12 @@
25#include "dir.h" 25#include "dir.h"
26#include "dircache.h" 26#include "dircache.h"
27 27
28#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR)
29#include "rb-loader.h"
30#include "bootdata.h"
31#include "crc32.h"
32#endif
33
28/*** 34/***
29 ** Internal redirects that depend upon whether or not dircache is made 35 ** Internal redirects that depend upon whether or not dircache is made
30 ** 36 **
@@ -132,11 +138,47 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume))
132#else 138#else
133 const char *path = PATH_ROOTSTR; 139 const char *path = PATH_ROOTSTR;
134#endif 140#endif
141
142#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR)
143 static char rtpath[VOL_MAX_LEN+2] = RB_ROOT_CONTENTS_DIR;
144 static bool redirected = false;
145 int boot_volume = 0;
146 unsigned int crc = 0;
147
148 crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff);
149 if (crc == boot_data.crc)
150 {
151 root_mount_path(path, 0); /*root could be different folder don't hide*/
152 boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */
153 //root_mount_path(path, volume == boot_volume ? NSITEM_HIDDEN : 0);
154 if (!redirected && volume == boot_volume)
155 {
156 if (get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "") < 0)
157 { /* Error occurred, card removed? Set root to default */
158 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
159 }
160 else
161 redirected = true;
162 }
163 if (redirected && volume == boot_volume)
164 root_mount_path(rtpath, NSITEM_CONTENTS);
165 } /*CRC OK*/
166 else
167 {
168 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
169 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false))
170 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
171 }
172#else
173
135 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); 174 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
136#ifdef HAVE_MULTIVOLUME 175#ifdef HAVE_MULTIVOLUME
137 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) 176 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false))
138#endif 177#endif
139 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); 178 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
179
180#endif /* HAVE_MULTIBOOT */
181
140#ifdef HAVE_DIRCACHE 182#ifdef HAVE_DIRCACHE
141 dircache_mount(); 183 dircache_mount();
142#endif 184#endif