From fdc3668a6a4d85fa6dde890ced7e9b850233bc0d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Thu, 21 Mar 2024 18:27:23 -0400 Subject: [BugFix] Multiboot Database duplicate files When the sd card is mounted into the root namespace the database picks up files through both paths previously we hid the mounted drive but this causes issues with users databases when the drive letter changes Adds a way to keep track of volumes mounted in the root namespace Hides the enumerated volume in root Database: we can just parse the root directory ('/') and get to any mounted volume but we can also enumerate a volume in the root directory when this occurs it leads to multiple entries since the files can be reached through multiple paths ex, /Foo could also be /SD1/Foo Instead we will attempt to rewrite the root with any non-hidden volumes failing that just leave the paths alone Change-Id: I7bdba8cfaf63902d2a3852d28484bcf8ca317ebd --- firmware/include/dir.h | 6 ++++++ firmware/include/dircache_redirect.h | 5 +++-- firmware/include/rb_namespace.h | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'firmware/include') diff --git a/firmware/include/dir.h b/firmware/include/dir.h index 2f78b11cf5..4599877ede 100644 --- a/firmware/include/dir.h +++ b/firmware/include/dir.h @@ -63,6 +63,9 @@ #ifndef dir_exists #define dir_exists FS_PREFIX(dir_exists) #endif +#ifndef root_realpath +#define root_realpath FS_PREFIX(root_realpath) +#endif #endif /* !DIRFUNCTIONS_DEFINED */ #ifndef DIRENT_DEFINED @@ -83,6 +86,9 @@ struct dirinfo #ifndef DIRFUNCTIONS_DECLARED /* TIP: set errno to zero before calling to see if anything failed */ struct dirinfo dir_get_info(DIR *dirp, struct DIRENT *entry); +const char* root_realpath(void); #endif /* !DIRFUNCTIONS_DECLARED */ + + #endif /* _DIR_H_ */ diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h index f51ce70690..36f68b7251 100644 --- a/firmware/include/dircache_redirect.h +++ b/firmware/include/dircache_redirect.h @@ -139,8 +139,10 @@ static inline void fileop_onsync_internal(struct filestr_base *stream) static inline void volume_onmount_internal(IF_MV_NONVOID(int volume)) { -#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER) +#if (defined(HAVE_MULTIVOLUME) || (defined(HAVE_MULTIBOOT) && !defined(BOOTLOADER))) char path[VOL_MAX_LEN+2]; +#endif +#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER) char rtpath[MAX_PATH / 2]; make_volume_root(volume, path); @@ -183,7 +185,6 @@ standard_redirect: root_mount_path(RB_ROOT_CONTENTS_DIR, NSITEM_CONTENTS); } #elif defined(HAVE_MULTIVOLUME) - char path[VOL_MAX_LEN+2]; make_volume_root(volume, path); root_mount_path(path, RB_ROOT_VOL_HIDDEN(volume) ? NSITEM_HIDDEN : 0); if (volume == path_strip_volume(RB_ROOT_CONTENTS_DIR, NULL, false)) diff --git a/firmware/include/rb_namespace.h b/firmware/include/rb_namespace.h index 7bc711b5a6..5cd8c2dd29 100644 --- a/firmware/include/rb_namespace.h +++ b/firmware/include/rb_namespace.h @@ -37,6 +37,8 @@ struct ns_scan_info }; /* root functions */ +#define ROOT_MAX_REALPATH 80 +const char* root_get_realpath(void); int root_mount_path(const char *path, unsigned int flags); void root_unmount_volume(IF_MV_NONVOID(int volume)); int root_readdir_dirent(struct filestr_base *stream, @@ -49,6 +51,7 @@ int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp, struct file_base_info *infop, uint16_t *attrp); int ns_open_stream(const char *path, unsigned int callflags, struct filestr_base *stream, struct ns_scan_info *scanp); +bool ns_volume_is_visible(IF_MV_NONVOID(int volume)); /* closes the namespace stream */ static inline int ns_close_stream(struct filestr_base *stream) -- cgit v1.2.3