From a6d537bb6cec25eb27cf8884ca5e3362a86818b3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 1 Nov 2008 03:42:27 +0100 Subject: Move sys_realpath() to libreplace. --- lib/replace/README | 1 + lib/replace/libreplace.m4 | 2 +- lib/replace/replace.c | 11 +++++++++++ lib/replace/replace.h | 5 +++++ source3/include/proto.h | 1 - source3/lib/system.c | 15 --------------- source3/modules/vfs_default.c | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/replace/README b/lib/replace/README index 1005281a6b..c1cb2d0270 100644 --- a/lib/replace/README +++ b/lib/replace/README @@ -69,6 +69,7 @@ utimes link readlink symlink +realpath Types: bool diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4 index cc9be162ac..c67fa66f5c 100644 --- a/lib/replace/libreplace.m4 +++ b/lib/replace/libreplace.m4 @@ -108,7 +108,7 @@ AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror) AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename) AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup) AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp) -AC_CHECK_FUNCS(isatty chown lchown link readlink symlink) +AC_CHECK_FUNCS(isatty chown lchown link readlink symlink realpath) AC_HAVE_DECL(setresuid, [#include ]) AC_HAVE_DECL(setresgid, [#include ]) AC_HAVE_DECL(errno, [#include ]) diff --git a/lib/replace/replace.c b/lib/replace/replace.c index f4faef992a..d757a0154e 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -658,3 +658,14 @@ int rep_lchown(const char *fname,uid_t uid,gid_t gid) return -1; } #endif + +#ifndef HAVE_REALPATH +char *rep_realpath(const char *path, char *resolved_path) +{ + /* As realpath is not a system call we can't return ENOSYS. */ + errno = EINVAL; + return NULL; +} +#endif + + diff --git a/lib/replace/replace.h b/lib/replace/replace.h index b81bf5c576..8d0dd57064 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -235,6 +235,11 @@ int rep_readlink(const char *path, char *buf, size_t bufsize); int rep_symlink(const char *oldpath, const char *newpath); #endif +#ifndef HAVE_REALPATH +#define realpath rep_realpath +char *rep_realpath(const char *path, char *resolved_path); +#endif + #ifndef HAVE_LCHOWN #define lchown rep_lchown int rep_lchown(const char *fname,uid_t uid,gid_t gid); diff --git a/source3/include/proto.h b/source3/include/proto.h index 5104910e99..e8b25667ab 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -1000,7 +1000,6 @@ long sys_telldir(SMB_STRUCT_DIR *dirp); void sys_rewinddir(SMB_STRUCT_DIR *dirp); int sys_closedir(SMB_STRUCT_DIR *dirp); int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev); -char *sys_realpath(const char *path, char *resolved_path); int sys_waitpid(pid_t pid,int *status,int options); char *sys_getwd(char *s); int sys_chroot(const char *dname); diff --git a/source3/lib/system.c b/source3/lib/system.c index 27722fcab2..da2797322a 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -537,21 +537,6 @@ int sys_mknod(const char *path, mode_t mode, SMB_DEV_T dev) #endif } -/******************************************************************* - Wrapper for realpath. -********************************************************************/ - -char *sys_realpath(const char *path, char *resolved_path) -{ -#if defined(HAVE_REALPATH) - return realpath(path, resolved_path); -#else - /* As realpath is not a system call we can't return ENOSYS. */ - errno = EINVAL; - return NULL; -#endif -} - /******************************************************************* The wait() calls vary between systems ********************************************************************/ diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 13c2770208..d972828ba9 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -909,7 +909,7 @@ static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path, char char *result; START_PROFILE(syscall_realpath); - result = sys_realpath(path, resolved_path); + result = realpath(path, resolved_path); END_PROFILE(syscall_realpath); return result; } -- cgit