From 8e918cccc201f18a75abd605947f3aba14986ab1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 Mar 2003 12:59:41 +0100 Subject: [PATCH] cope with systems that don't have realpath() --- util.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index ff0c83cb8..d2a920a23 100644 --- a/util.c +++ b/util.c @@ -359,8 +359,22 @@ char *x_realpath(const char *path) if (maxlen < 4096) maxlen = 4096; ret = x_malloc(maxlen); - + +#if HAVE_REALPATH p = realpath(path, ret); +#else + /* yes, there are such systems. This replacement relies on + the fact that when we call x_realpath we only care about symlinks */ + { + int len = readlink(path, ret, maxlen-1); + if (len == -1) { + free(ret); + return NULL; + } + ret[len] = 0; + p = ret; + } +#endif if (p) { p = x_strdup(p); free(ret); -- 2.47.3