diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-11 08:26:53 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-11 17:47:34 -0400 |
commit | db6f21e2954db63cd04de73ed472c48f63b80a89 (patch) | |
tree | 252e2fccaef788141630ceeb67a03b69bd1654d1 /firmware/target/hosted/filesystem-app.c | |
parent | a5add3982bff6907d30942f614d5a471f75c018b (diff) | |
download | rockbox-db6f21e2954db63cd04de73ed472c48f63b80a89.tar.gz rockbox-db6f21e2954db63cd04de73ed472c48f63b80a89.zip |
hosted: sanitize handling of HOME_DIR
* HOME_DIR is now either "/" or special "<HOME>"
* target-specific "home dir path" is defined solely by PIVOT_ROOT
* PIVOT_ROOT path is now defined in toplevel config files
* Make Samsung YP-R0/R1 and SONY_NWZ use PIVOT_ROOT too
* Do not prepend PIVOT_ROOT path if the path already has it!
* Do not play these games for __PCTOOL__ builds
Change-Id: I3d51ad902a5f9cafe45ba15ba654f30f1ec6113a
Diffstat (limited to 'firmware/target/hosted/filesystem-app.c')
-rw-r--r-- | firmware/target/hosted/filesystem-app.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c index 24c5a7e062..1d64a58677 100644 --- a/firmware/target/hosted/filesystem-app.c +++ b/firmware/target/hosted/filesystem-app.c @@ -36,15 +36,13 @@ #include "rbpaths.h" #include "logf.h" -#if !(defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR)) -#if defined(HIBY_LINUX) -#define PIVOT_ROOT "/mnt/sd_0" -#elif defined(FIIO_M3K) -#define PIVOT_ROOT "/mnt" // XXX check this! -#else +/* PIVOT_ROOT adds a fixed prefix to all paths */ +#if defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR) || defined(__PCTOOL__) +/* We don't want to use pivot root on these! */ +#undef PIVOT_ROOT #endif -#endif // !(BOOTLOADER|WPS|SIM) +#if defined(HAVE_MULTIDRIVE) || defined(HAVE_SPECIAL_DIRS) #if (CONFIG_PLATFORM & PLATFORM_ANDROID) static const char rbhome[] = "/sdcard"; #elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) \ @@ -54,15 +52,11 @@ static const char *rbhome; /* YPR0, YPR1, NWZ, etc */ static const char rbhome[] = HOME_DIR; #endif +#endif -#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ - defined(SONY_NWZ_LINUX) || defined(DX90) || defined(HIBY_LINUX) || \ - defined(FIIO_M3K)) && \ - !defined(__PCTOOL__) -/* Special dirs are user-accessible (and user-writable) dirs which take priority - * over the ones where Rockbox is installed to. Classic example would be - * $HOME/.config/rockbox.org vs /usr/share/rockbox */ -#define HAVE_SPECIAL_DIRS +#if !defined(__PCTOOL__) +/* We don't want this for tools */ +#undef HAVE_SPECIAL_DIRS #endif #ifdef HAVE_MULTIDRIVE @@ -202,6 +196,8 @@ const char * handle_special_dirs(const char *dir, unsigned flags, { (void) flags; (void) buf; (void) bufsize; #ifdef HAVE_SPECIAL_DIRS +#define HOME_DIR_LEN (sizeof(HOME_DIR)-1) + /* This replaces HOME_DIR (ie '<HOME'>') with runtime rbhome */ if (!strncmp(HOME_DIR, dir, HOME_DIR_LEN)) { const char *p = dir + HOME_DIR_LEN; @@ -216,8 +212,13 @@ const char * handle_special_dirs(const char *dir, unsigned flags, dir = handle_special_links(dir, flags, buf, bufsize); #endif #ifdef PIVOT_ROOT - snprintf(buf, bufsize, "%s/%s", PIVOT_ROOT, dir); - dir = buf; +#define PIVOT_ROOT_LEN (sizeof(PIVOT_ROOT)-1) + /* Prepend root prefix to find actual path */ + if (strncmp(PIVOT_ROOT, dir, PIVOT_ROOT_LEN)) + { + snprintf(buf, bufsize, "%s/%s", PIVOT_ROOT, dir); + dir = buf; + } #endif return dir; } |