summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorUri Simchoni <uri@samba.org>2016-01-18 23:34:06 +0200
committerJeremy Allison <jra@samba.org>2016-01-27 00:22:22 +0100
commitc6ed45fe710924f847f46d505ceabfec21e7cf38 (patch)
treebe56d9346c2bc51531269af078a4195246fd7af9 /source3/lib
parentf0c43ceec5185ef4bc429e201339f3eb3e7c094b (diff)
downloadsamba-c6ed45fe710924f847f46d505ceabfec21e7cf38.tar.gz
s3-lib: introduce sys_realpath()
Add sys_realpath() function that captures the OS variations on realpath(). Signed-off-by: Uri Simchoni <uri@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/system.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/source3/lib/system.c b/source3/lib/system.c
index e54b946d33c..0351e376265 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -1236,6 +1236,31 @@ uint32_t unix_dev_minor(SMB_DEV_T dev)
#endif
}
+/**************************************************************************
+ Wrapper for realpath.
+****************************************************************************/
+
+char *sys_realpath(const char *path)
+{
+ char *result;
+
+#ifdef REALPATH_TAKES_NULL
+ result = realpath(path, NULL);
+#else
+ result = SMB_MALLOC_ARRAY(char, PATH_MAX + 1);
+ if (result) {
+ char *resolved_path = realpath(path, result);
+ if (!resolved_path) {
+ SAFE_FREE(result);
+ } else {
+ /* SMB_ASSERT(result == resolved_path) ? */
+ result = resolved_path;
+ }
+ }
+#endif
+ return result;
+}
+
#if 0
/*******************************************************************
Return the number of CPUs.