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.h54
1 files changed, 27 insertions, 27 deletions
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h
index a781d6ee76..c8905455f9 100644
--- a/firmware/include/dircache_redirect.h
+++ b/firmware/include/dircache_redirect.h
@@ -138,49 +138,49 @@ static inline void fileop_onsync_internal(struct filestr_base *stream)
138 138
139static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) 139static inline void volume_onmount_internal(IF_MV_NONVOID(int volume))
140{ 140{
141#ifdef HAVE_MULTIVOLUME 141#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER)
142 char path[VOL_MAX_LEN+2]; 142 char path[VOL_MAX_LEN+2];
143 char rtpath[MAX_PATH / 2];
143 make_volume_root(volume, path); 144 make_volume_root(volume, path);
144#else
145 const char *path = PATH_ROOTSTR;
146#endif
147 145
148#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER) 146 unsigned int crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff);
149 static char rtpath[VOL_MAX_LEN+2] = RB_ROOT_CONTENTS_DIR; 147 if (crc > 0 && crc == boot_data.crc)
150 static bool redirected = false;
151 int boot_volume = 0;
152 unsigned int crc = 0;
153 crc = crc_32(boot_data.payload, boot_data.length, 0xffffffff);
154 if (crc == boot_data.crc)
155 { 148 {
156 root_mount_path(path, 0); /*root could be different folder don't hide*/ 149 /* we need to mount the drive before we can access it */
157 boot_volume = boot_data.boot_volume; /* boot volume contained in uint8_t payload */ 150 root_mount_path(path, 0); /* root could be different folder don't hide */
158 //root_mount_path(path, volume == boot_volume ? NSITEM_HIDDEN : 0); 151
159 if (!redirected && volume == boot_volume) 152 if (volume == boot_data.boot_volume) /* boot volume contained in uint8_t payload */
160 { 153 {
161 if (get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "") < 0) 154 int rtlen = get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "");
162 { /* Error occurred, card removed? Set root to default */ 155 while (rtlen > 0 && rtpath[--rtlen] == PATH_SEPCH)
163 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); 156 rtpath[rtlen] = '\0'; /* remove extra separators */
164 } 157
165 else 158 if (rtlen <= 0 || rtpath[rtlen] == VOL_END_TOK)
166 redirected = true; 159 root_unmount_volume(volume); /* unmount so root can be hidden*/
167 } 160
168 if (redirected && volume == boot_volume) 161 if (rtlen <= 0) /* Error occurred, card removed? Set root to default */
162 goto standard_redirect;
169 root_mount_path(rtpath, NSITEM_CONTENTS); 163 root_mount_path(rtpath, NSITEM_CONTENTS);
164 }
165
170 } /*CRC OK*/ 166 } /*CRC OK*/
171 else 167 else
172 { 168 {
169standard_redirect:
173 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); 170 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
174 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) 171 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false))
175 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); 172 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
176 } 173 }
177#else /*ndef HAVE_MULTIBOOT */ 174#elif defined(HAVE_MULTIVOLUME)
178 175 char path[VOL_MAX_LEN+2];
176 make_volume_root(volume, path);
179 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); 177 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
180#ifdef HAVE_MULTIVOLUME
181 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) 178 if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false))
182#endif
183 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); 179 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
180#else
181 const char *path = PATH_ROOTSTR;
182 root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0);
183 root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS);
184#endif /* HAVE_MULTIBOOT */ 184#endif /* HAVE_MULTIBOOT */
185 185
186#ifdef HAVE_DIRCACHE 186#ifdef HAVE_DIRCACHE