From 548ec7045bc7c80eaf03e92f390d1da2c9e9cd86 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 28 Mar 2019 12:52:44 +0000 Subject: win32: interpret absolute paths as relative to %SYSTEMDRIVE% BusyBox contains hardcoded references to absolute paths which are unique in the *nix world but on Microsoft Windows are interpreted as being on the current drive. To make these unique again consider them to be relative to %SYSTEMDRIVE%. Support this by adding functions to: - determine the system drive (not using the environment variable); - change a process's current directory to the root of the system drive; - make relative paths absolute before changing directory (if needed). The following applications have been modified: - ash references /etc/profile from the system drive; - dpkg places its data store on and installs files to the system drive; - rpm installs files to the system drive; - man looks for configuration files and man pages on the system drive. See GitHub issue #158. --- miscutils/man.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'miscutils') diff --git a/miscutils/man.c b/miscutils/man.c index 3c1a79085..0bc11e623 100644 --- a/miscutils/man.c +++ b/miscutils/man.c @@ -253,11 +253,22 @@ int man_main(int argc UNUSED_PARAM, char **argv) int cur_mp; int opt, not_found; char *token[2]; +#if ENABLE_PLATFORM_MINGW32 + char **ptr; +#endif INIT_G(); opt = getopt32(argv, "^+" "aw" "\0" "-1"/*at least one arg*/); argv += optind; +#if ENABLE_PLATFORM_MINGW32 + /* add system drive prefix to filenames, if necessary */ + for (ptr = argv; *ptr; ++ptr) { + if (strchr(*ptr, '/') || strchr(*ptr, '\\')) + *ptr = xabsolute_path(*ptr); + } + chdir_system_drive(); +#endif sec_list = xstrdup("0p:1:1p:2:3:3p:4:5:6:7:8:9"); @@ -311,7 +322,8 @@ int man_main(int argc UNUSED_PARAM, char **argv) char *relpath = concat_path_file(dirname(exepath), "man"); if (count_mp == 0) { /* default must match path set above */ - man_path_list = add_MANPATH(man_path_list, &count_mp, "/usr/man"); + man_path_list = add_MANPATH(man_path_list, &count_mp, + (char *)"/usr/man"); } man_path_list = add_MANPATH(man_path_list, &count_mp, relpath); free(relpath); -- cgit v1.2.3-55-g6feb