summaryrefslogtreecommitdiff
path: root/firmware/target/hosted
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-11 08:26:53 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-11 17:47:34 -0400
commitdb6f21e2954db63cd04de73ed472c48f63b80a89 (patch)
tree252e2fccaef788141630ceeb67a03b69bd1654d1 /firmware/target/hosted
parenta5add3982bff6907d30942f614d5a471f75c018b (diff)
downloadrockbox-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')
-rw-r--r--firmware/target/hosted/filesystem-app.c35
-rw-r--r--firmware/target/hosted/rolo.c8
2 files changed, 25 insertions, 18 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 @@
36#include "rbpaths.h" 36#include "rbpaths.h"
37#include "logf.h" 37#include "logf.h"
38 38
39#if !(defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR)) 39/* PIVOT_ROOT adds a fixed prefix to all paths */
40#if defined(HIBY_LINUX) 40#if defined(BOOTLOADER) || defined(CHECKWPS) || defined(SIMULATOR) || defined(__PCTOOL__)
41#define PIVOT_ROOT "/mnt/sd_0" 41/* We don't want to use pivot root on these! */
42#elif defined(FIIO_M3K) 42#undef PIVOT_ROOT
43#define PIVOT_ROOT "/mnt" // XXX check this!
44#else
45#endif 43#endif
46#endif // !(BOOTLOADER|WPS|SIM)
47 44
45#if defined(HAVE_MULTIDRIVE) || defined(HAVE_SPECIAL_DIRS)
48#if (CONFIG_PLATFORM & PLATFORM_ANDROID) 46#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
49static const char rbhome[] = "/sdcard"; 47static const char rbhome[] = "/sdcard";
50#elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) \ 48#elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA)) \
@@ -54,15 +52,11 @@ static const char *rbhome;
54/* YPR0, YPR1, NWZ, etc */ 52/* YPR0, YPR1, NWZ, etc */
55static const char rbhome[] = HOME_DIR; 53static const char rbhome[] = HOME_DIR;
56#endif 54#endif
55#endif
57 56
58#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \ 57#if !defined(__PCTOOL__)
59 defined(SONY_NWZ_LINUX) || defined(DX90) || defined(HIBY_LINUX) || \ 58/* We don't want this for tools */
60 defined(FIIO_M3K)) && \ 59#undef HAVE_SPECIAL_DIRS
61 !defined(__PCTOOL__)
62/* Special dirs are user-accessible (and user-writable) dirs which take priority
63 * over the ones where Rockbox is installed to. Classic example would be
64 * $HOME/.config/rockbox.org vs /usr/share/rockbox */
65#define HAVE_SPECIAL_DIRS
66#endif 60#endif
67 61
68#ifdef HAVE_MULTIDRIVE 62#ifdef HAVE_MULTIDRIVE
@@ -202,6 +196,8 @@ const char * handle_special_dirs(const char *dir, unsigned flags,
202{ 196{
203 (void) flags; (void) buf; (void) bufsize; 197 (void) flags; (void) buf; (void) bufsize;
204#ifdef HAVE_SPECIAL_DIRS 198#ifdef HAVE_SPECIAL_DIRS
199#define HOME_DIR_LEN (sizeof(HOME_DIR)-1)
200 /* This replaces HOME_DIR (ie '<HOME'>') with runtime rbhome */
205 if (!strncmp(HOME_DIR, dir, HOME_DIR_LEN)) 201 if (!strncmp(HOME_DIR, dir, HOME_DIR_LEN))
206 { 202 {
207 const char *p = dir + HOME_DIR_LEN; 203 const char *p = dir + HOME_DIR_LEN;
@@ -216,8 +212,13 @@ const char * handle_special_dirs(const char *dir, unsigned flags,
216 dir = handle_special_links(dir, flags, buf, bufsize); 212 dir = handle_special_links(dir, flags, buf, bufsize);
217#endif 213#endif
218#ifdef PIVOT_ROOT 214#ifdef PIVOT_ROOT
219 snprintf(buf, bufsize, "%s/%s", PIVOT_ROOT, dir); 215#define PIVOT_ROOT_LEN (sizeof(PIVOT_ROOT)-1)
220 dir = buf; 216 /* Prepend root prefix to find actual path */
217 if (strncmp(PIVOT_ROOT, dir, PIVOT_ROOT_LEN))
218 {
219 snprintf(buf, bufsize, "%s/%s", PIVOT_ROOT, dir);
220 dir = buf;
221 }
221#endif 222#endif
222 return dir; 223 return dir;
223} 224}
diff --git a/firmware/target/hosted/rolo.c b/firmware/target/hosted/rolo.c
index 432d69c86e..2aa3071c9a 100644
--- a/firmware/target/hosted/rolo.c
+++ b/firmware/target/hosted/rolo.c
@@ -91,8 +91,14 @@ int rolo_load(const char* filename)
91 lcd_remote_update(); 91 lcd_remote_update();
92#endif 92#endif
93 93
94#ifdef PIVOT_ROOT
95#define EXECDIR PIVOT_ROOT
96#else
97#define EXECDIR ROOT_DIR
98#endif
99
94 char buf[256]; 100 char buf[256];
95 snprintf(buf, sizeof(buf), "%s/%s", HOME_DIR, filename); 101 snprintf(buf, sizeof(buf), "%s/%s", EXECDIR, filename);
96 execl(buf, BOOTFILE, NULL); 102 execl(buf, BOOTFILE, NULL);
97 103
98 rolo_error("Failed to launch!", strerror(errno)); 104 rolo_error("Failed to launch!", strerror(errno));