diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-06 12:00:50 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-03-06 12:00:50 +0000 |
commit | 585d17d262efabce4a9a87f33f531ef9ab7c0e36 (patch) | |
tree | e9b5d4bffaf1d8962d3c3d5e4529d7b87f831c7c /win32 | |
parent | 5c5197df8668ba58ec7799ccc418d124a6c6a49e (diff) | |
download | busybox-w32-585d17d262efabce4a9a87f33f531ef9ab7c0e36.tar.gz busybox-w32-585d17d262efabce4a9a87f33f531ef9ab7c0e36.tar.bz2 busybox-w32-585d17d262efabce4a9a87f33f531ef9ab7c0e36.zip |
win32: canonicalize path in chdir(2)
Provide an implementation of chdir(2) which canonicalizes the
path to resolve symlinks. Otherwise changing to a symlinked
directory confuses 'ls -l' because it thinks '.' is a link
rather than a directory.
OTOH, using 'cd' in the shell to change to a symlinked directory
now results in a mismatch between the shell's idea of where we are
and what's displayed in the prompt. But upstream BusyBox does
that too so it must be OK.
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index c42dbed97..b1a8b9711 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1159,6 +1159,19 @@ int mingw_mkdir(const char *path, int mode UNUSED_PARAM) | |||
1159 | return ret; | 1159 | return ret; |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | #undef chdir | ||
1163 | int mingw_chdir(const char *dirname) | ||
1164 | { | ||
1165 | int ret = -1; | ||
1166 | char *realdir = xmalloc_realpath(dirname); | ||
1167 | |||
1168 | if (realdir) { | ||
1169 | ret = chdir(realdir); | ||
1170 | free(realdir); | ||
1171 | } | ||
1172 | return ret; | ||
1173 | } | ||
1174 | |||
1162 | #undef chmod | 1175 | #undef chmod |
1163 | int mingw_chmod(const char *path, int mode) | 1176 | int mingw_chmod(const char *path, int mode) |
1164 | { | 1177 | { |