this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Build gnumake, several fixes in virtual prefix implementation

+54 -20
+4
.gitmodules
··· 57 57 path = src/external/bash 58 58 url = ../darling-bash.git 59 59 branch = darling 60 + [submodule "src/external/gnumake"] 61 + path = src/external/gnumake 62 + url = ../darling-gnumake.git 63 + branch = darling
+1
src/CMakeLists.txt
··· 111 111 add_subdirectory(external/shell_cmds) 112 112 add_subdirectory(external/file_cmds) 113 113 add_subdirectory(external/bash) 114 + add_subdirectory(external/gnumake) 114 115 115 116 ###################### 116 117 # libc++ & libc++abi #
+2 -1
src/dyld/darling
··· 24 24 25 25 SYSTEM_ROOT_NAME="system-root" 26 26 BIND_DIRECTORIES="dev etc home tmp" 27 - MAKE_DIRECTORIES="Applications Volumes" 27 + MAKE_DIRECTORIES="Applications Volumes usr" 28 28 29 29 setup_prefix() { 30 30 >&2 echo "Setting up prefix at $1" ··· 45 45 46 46 # TODO: install bash and coreutils 47 47 ln -s "${SYSTEM_ROOT_NAME}${DARLING_PREFIX}/libexec/darling/bin" "bin" 48 + ln -s "../${SYSTEM_ROOT_NAME}${DARLING_PREFIX}/libexec/darling/usr/bin" "usr/bin" 48 49 49 50 popd >/dev/null 50 51 }
+1 -1
src/kernel/emulation/linux/fcntl/fcntl.c
··· 75 75 if (len >= 0) 76 76 ((char*) arg)[len] = '\0'; 77 77 78 - return len; 78 + return 0; 79 79 } 80 80 // TODO: implement remaining commands 81 81 default:
+4 -4
src/kernel/emulation/linux/stat/lstat.c
··· 11 11 struct linux_stat lstat; 12 12 13 13 #ifdef __NR_lstat64 14 - ret = LINUX_SYSCALL(__NR_lstat64, __prefix_translate_path(path), &lstat); 14 + ret = LINUX_SYSCALL(__NR_lstat64, __prefix_translate_path_link(path), &lstat); 15 15 #else 16 - ret = LINUX_SYSCALL(__NR_lstat, __prefix_translate_path(path), &lstat); 16 + ret = LINUX_SYSCALL(__NR_lstat, __prefix_translate_path_link(path), &lstat); 17 17 #endif 18 18 19 19 if (ret < 0) ··· 32 32 struct linux_stat lstat; 33 33 34 34 #ifdef __NR_lstat64 35 - ret = LINUX_SYSCALL(__NR_lstat64, __prefix_translate_path(path), &lstat); 35 + ret = LINUX_SYSCALL(__NR_lstat64, __prefix_translate_path_link(path), &lstat); 36 36 #else 37 - ret = LINUX_SYSCALL(__NR_lstat, __prefix_translate_path(path), &lstat); 37 + ret = LINUX_SYSCALL(__NR_lstat, __prefix_translate_path_link(path), &lstat); 38 38 #endif 39 39 40 40 if (ret < 0)
+4 -3
src/kernel/emulation/linux/unistd/chdir.c
··· 4 4 #include <asm/unistd.h> 5 5 #include <libdyld/VirtualPrefix.h> 6 6 7 - long sys_chdir(const char* path) 7 + long sys_chdir(const char* in_path) 8 8 { 9 9 int ret; 10 + const char* path; 10 11 11 - path = __prefix_translate_path(path); 12 + path = __prefix_translate_path(in_path); 12 13 ret = LINUX_SYSCALL(__NR_chdir, path); 13 14 if (ret < 0) 14 15 ret = errno_linux_to_bsd(ret); 15 16 else 16 - __prefix_cwd(path); 17 + __prefix_cwd(in_path); 17 18 18 19 return ret; 19 20 }
+2 -2
src/kernel/emulation/linux/unistd/lchown.c
··· 9 9 int ret; 10 10 11 11 #ifdef __NR_chown32 12 - ret = LINUX_SYSCALL(__NR_lchown32, __prefix_translate_path(path), uid, gid); 12 + ret = LINUX_SYSCALL(__NR_lchown32, __prefix_translate_path_link(path), uid, gid); 13 13 #else 14 - ret = LINUX_SYSCALL(__NR_lchown, __prefix_translate_path(path), uid, gid); 14 + ret = LINUX_SYSCALL(__NR_lchown, __prefix_translate_path_link(path), uid, gid); 15 15 #endif 16 16 if (ret < 0) 17 17 ret = errno_linux_to_bsd(ret);
+1 -1
src/kernel/emulation/linux/unistd/readlink.c
··· 10 10 { 11 11 int ret; 12 12 13 - ret = LINUX_SYSCALL(__NR_readlink, __prefix_translate_path(path), 13 + ret = LINUX_SYSCALL(__NR_readlink, __prefix_translate_path_link(path), 14 14 buf, count); 15 15 if (ret < 0) 16 16 ret = errno_linux_to_bsd(ret);
+31 -8
src/libdyld/VirtualPrefix.cpp
··· 39 39 static std::string join_path(const std::list<std::string>& path_components); 40 40 41 41 static std::list<std::string>& canonicalize_path(std::list<std::string>& path_components); 42 - static std::string resolve_path(std::list<std::string>& path_components); 42 + static std::string resolve_path(std::list<std::string>& path_components, bool symlink); 43 + static const char* translate_path_common(const char* path, bool symlink); 43 44 44 45 void __prefix_set(const char* path) 45 46 { ··· 49 50 getcwd(cwd, sizeof(cwd)); 50 51 51 52 assert(path[0] == '/'); 53 + assert(g_prefix.empty()); 52 54 53 55 g_prefix = path; 54 56 g_prefixComponents.clear(); ··· 68 70 69 71 if (strncmp(cwd, path, strlen(path)) == 0) 70 72 { 71 - g_cwd = path + strlen(path); 72 - if (g_cwd.empty()) 73 - g_cwd = "/"; 73 + g_cwd = cwd + strlen(path); 74 + if (g_cwd.empty() || g_cwd[g_cwd.length()-1] != '/') 75 + g_cwd += "/"; 74 76 } 75 77 else 76 78 { ··· 78 80 g_cwd += cwd; 79 81 g_cwd += '/'; 80 82 } 83 + 84 + // std::cout << "### Prefix initialized with cwd " << g_cwd << " from " << cwd << std::endl; 81 85 } 82 86 83 87 const char* __prefix_get(void) ··· 88 92 return g_prefix.c_str(); 89 93 } 90 94 91 - const char* __prefix_translate_path(const char* path) 95 + const char* translate_path_common(const char* path, bool symlink) 92 96 { 93 97 static thread_local char resolved_path[1024]; 94 98 std::string str; 95 99 std::list<std::string> path_components; 96 - std::list<std::string>::iterator root; 97 100 98 101 if (g_prefix.empty()) 99 102 return path; 100 103 104 + // std::cout << "\tCWD is " << g_cwd << std::endl; 105 + 101 106 if (path[0] != '/') 102 107 { 103 108 pthread_rwlock_rdlock(&g_cwdLock); ··· 105 110 pthread_rwlock_unlock(&g_cwdLock); 106 111 } 107 112 str += path; 113 + // std::cout << "*** Before explode: " << str << std::endl; 108 114 109 115 path_components = explode_path(str); 110 - str = resolve_path(path_components); 116 + str = resolve_path(path_components, symlink); 111 117 112 118 strncpy(resolved_path, str.c_str(), sizeof(resolved_path)-1); 113 119 resolved_path[sizeof(resolved_path)-1] = '\0'; ··· 117 123 return resolved_path; 118 124 } 119 125 126 + const char* __prefix_translate_path(const char* path) 127 + { 128 + return translate_path_common(path, false); 129 + } 130 + 131 + const char* __prefix_translate_path_link(const char* path) 132 + { 133 + return translate_path_common(path, true); 134 + } 135 + 120 136 const char* __prefix_untranslate_path(const char* path, unsigned long count) 121 137 { 122 138 static thread_local char resolved_path[1024]; ··· 156 172 resolved_path[len + sizeof(SYSTEM_ROOT)-1] = '\0'; 157 173 } 158 174 175 + // std::cout << "*** UNTRANSLATE: " << path << " -> " << resolved_path << std::endl; 176 + 159 177 return resolved_path; 160 178 } 161 179 ··· 183 201 184 202 if (g_cwd[g_cwd.length()-1] != '/') 185 203 g_cwd += '/'; 204 + 205 + // std::cout << "\t+++ CWD In: " << in_path << "; out: " << g_cwd << std::endl; 186 206 187 207 pthread_rwlock_unlock(&g_cwdLock); 188 208 } ··· 285 305 return path_components; 286 306 } 287 307 288 - std::string resolve_path(std::list<std::string>& path_components) 308 + std::string resolve_path(std::list<std::string>& path_components, bool symlink) 289 309 { 290 310 std::string path, real_path; 291 311 bool had_failure = false; ··· 376 396 else 377 397 had_failure = true; 378 398 } 399 + 400 + if (symlink && it == --path_components.end()) 401 + isLink = false; 379 402 380 403 // Perform symlink resolution 381 404 if (isLink && !is_system_root)
+4
src/libdyld/VirtualPrefix.h
··· 38 38 // Translate from path in prefix to physical path. 39 39 const char* __prefix_translate_path(const char* path); 40 40 41 + // Translate from path in prefix to physical path, treat the leaf node 42 + // as a symlink. 43 + const char* __prefix_translate_path_link(const char* path); 44 + 41 45 // Translate from physical path to path in prefix. 42 46 // The path is expected to be canonical. 43 47 const char* __prefix_untranslate_path(const char* path, unsigned long count);