From f850bbbbc4b7345bebde241f651bad1c5c28df66 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Thu, 20 Aug 2020 21:54:00 -0400 Subject: Revert root_redirect :( This reverts commit 31fc46ded69be7438cca2ba2c2b93c1f200165a6. Change-Id: Ia78618c0e8b25ca65f7c8ae0db1cb9c9b321bad9 --- firmware/common/pathfuncs.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) (limited to 'firmware/common/pathfuncs.c') diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c index 078c0b6938..0935a9a6e3 100644 --- a/firmware/common/pathfuncs.c +++ b/firmware/common/pathfuncs.c @@ -105,7 +105,7 @@ static const unsigned char storage_dec_indexes[STORAGE_NUM_TYPES+1] = */ int path_strip_volume(const char *name, const char **nameptr, bool greedy) { - int volume = ROOT_VOLUME; + int volume = 0; const char *t = name; int c, v = 0; @@ -114,16 +114,9 @@ int path_strip_volume(const char *name, const char **nameptr, bool greedy) * digits within the brackets is parsed as the volume number and of * those, only the last ones VOL_MUM_MAX allows. */ - t = GOBBLE_PATH_SEPCH(t); /* skip all leading slashes */ - if (t == name) - { - volume = -1; /* relative path; don't know */ - goto psv_out; - } - - c = *t; + c = *(t = GOBBLE_PATH_SEPCH(t)); /* skip all leading slashes */ if (c != VOL_START_TOK) /* missing start token? no volume */ - goto psv_out; + goto volume0; do { @@ -134,7 +127,7 @@ int path_strip_volume(const char *name, const char **nameptr, bool greedy) break; case '\0': case PATH_SEPCH: /* no closing bracket; no volume */ - goto psv_out; + goto volume0; default: /* something else; reset volume */ v = 0; } @@ -144,7 +137,7 @@ int path_strip_volume(const char *name, const char **nameptr, bool greedy) if (!(c = *++t)) /* no more path and no '/' is ok */ ; else if (c != PATH_SEPCH) /* more path and no separator after end */ - goto psv_out; + goto volume0; else if (greedy) t = GOBBLE_PATH_SEPCH(++t); /* strip remaining separators */ @@ -153,7 +146,7 @@ int path_strip_volume(const char *name, const char **nameptr, bool greedy) volume = v; name = t; -psv_out: +volume0: if (nameptr) *nameptr = name; return volume; @@ -164,14 +157,10 @@ psv_out: */ int get_volume_name(int volume, char *buffer) { - if (volume < 0 || volume == ROOT_VOLUME) + if (volume < 0) { - char *t = buffer; - if (volume == ROOT_VOLUME) - *t++ = PATH_ROOTCHR; - - *t = '\0'; - return t - buffer; + *buffer = '\0'; + return 0; } volume %= VOL_NUM_MAX; /* as path parser would have it */ @@ -184,20 +173,6 @@ int get_volume_name(int volume, char *buffer) return snprintf(buffer, VOL_MAX_LEN + 1, "%c%s%d%c", VOL_START_TOK, voldec, volume, VOL_END_TOK); } - -/* Returns volume name formatted with the root. Assumes buffer size is at - * least {VOL_MAX_LEN}+2 */ -int make_volume_root(int volume, char *buffer) -{ - char *t = buffer; - - if (volume >= 0 && volume != ROOT_VOLUME) - *t++ = PATH_ROOTCHR; - - t += get_volume_name(volume, t); - - return t - buffer; -} #endif /* HAVE_MULTIVOLUME */ /* Just like path_strip_volume() but strips a leading drive specifier and -- cgit v1.2.3