summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/src/gfapi.aliases4
-rw-r--r--api/src/gfapi.map5
-rw-r--r--api/src/glfs-fops.c47
-rw-r--r--api/src/glfs-mem-types.h1
-rw-r--r--api/src/glfs.h4
5 files changed, 51 insertions, 10 deletions
diff --git a/api/src/gfapi.aliases b/api/src/gfapi.aliases
index b37665f0588..0dead255487 100644
--- a/api/src/gfapi.aliases
+++ b/api/src/gfapi.aliases
@@ -82,7 +82,7 @@ _pub_glfs_fremovexattr _glfs_fremovexattr$GFAPI_3.4.0
_pub_glfs_getcwd _glfs_getcwd$GFAPI_3.4.0
_pub_glfs_chdir _glfs_chdir$GFAPI_3.4.0
_pub_glfs_fchdir _glfs_fchdir$GFAPI_3.4.0
-_pub_glfs_realpath _glfs_realpath$GFAPI_3.4.0
+_pub_glfs_realpath34 _glfs_realpath$GFAPI_3.4.0
_pub_glfs_posix_lock _glfs_posix_lock$GFAPI_3.4.0
_pub_glfs_dup _glfs_dup$GFAPI_3.4.0
@@ -153,3 +153,5 @@ _pub_glfs_upcall_inode_get_pobject _glfs_upcall_inode_get_pobject$GFAPI_3.7.16
_pub_glfs_upcall_inode_get_pstat _glfs_upcall_inode_get_pstat$GFAPI_3.7.16
_pub_glfs_upcall_inode_get_oldpobject _glfs_upcall_inode_get_oldpobject$GFAPI_3.7.16
_pub_glfs_upcall_inode_get_oldpstat _glfs_upcall_inode_get_oldpstat$GFAPI_3.7.16
+
+_pub_glfs_realpath _glfs_realpath$GFAPI_3.7.17
diff --git a/api/src/gfapi.map b/api/src/gfapi.map
index f38ef024181..ca19baef896 100644
--- a/api/src/gfapi.map
+++ b/api/src/gfapi.map
@@ -186,3 +186,8 @@ GFAPI_3.7.16 {
glfs_upcall_inode_get_oldpobject;
glfs_upcall_inode_get_oldpstat;
} GFAPI_3.7.15;
+
+GFAPI_3.7.17 {
+ global:
+ glfs_realpath;
+} GFAPI_3.7.16;
diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c
index 0fbcde395ea..be1077a2760 100644
--- a/api/src/glfs-fops.c
+++ b/api/src/glfs-fops.c
@@ -4005,9 +4005,11 @@ invalid_fs:
GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_fchdir, 3.4.0);
+static gf_boolean_t warn_realpath = _gf_true; /* log once */
-char *
-pub_glfs_realpath (struct glfs *fs, const char *path, char *resolved_path)
+static char *
+glfs_realpath_common (struct glfs *fs, const char *path, char *resolved_path,
+ gf_boolean_t warn_deprecated)
{
int ret = -1;
char *retpath = NULL;
@@ -4022,8 +4024,20 @@ pub_glfs_realpath (struct glfs *fs, const char *path, char *resolved_path)
if (resolved_path)
retpath = resolved_path;
- else
- retpath = allocpath = malloc (PATH_MAX + 1);
+ else if (warn_deprecated) {
+ retpath = allocpath = malloc (PATH_MAX + 1);
+ if (warn_realpath) {
+ warn_realpath = _gf_false;
+ gf_log (THIS->name, GF_LOG_WARNING, "this application "
+ "is compiled against an old version of "
+ "libgfapi, it should use glfs_free() to "
+ "release the path returned by "
+ "glfs_realpath()");
+ }
+ } else {
+ retpath = allocpath = GF_CALLOC (1, PATH_MAX + 1,
+ glfs_mt_realpath_t);
+ }
if (!retpath) {
ret = -1;
@@ -4054,9 +4068,11 @@ out:
loc_wipe (&loc);
if (ret == -1) {
- if (allocpath)
- free (allocpath);
- retpath = NULL;
+ if (warn_deprecated && allocpath)
+ free (allocpath);
+ else if (allocpath)
+ GF_FREE (allocpath);
+ retpath = NULL;
}
glfs_subvol_done (fs, subvol);
@@ -4067,7 +4083,22 @@ invalid_fs:
return retpath;
}
-GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_realpath, 3.4.0);
+
+char *
+pub_glfs_realpath34 (struct glfs *fs, const char *path, char *resolved_path)
+{
+ return glfs_realpath_common (fs, path, resolved_path, _gf_true);
+}
+
+GFAPI_SYMVER_PUBLIC(glfs_realpath34, glfs_realpath, 3.4.0);
+
+char *
+pub_glfs_realpath (struct glfs *fs, const char *path, char *resolved_path)
+{
+ return glfs_realpath_common (fs, path, resolved_path, _gf_false);
+}
+
+GFAPI_SYMVER_PUBLIC_DEFAULT(glfs_realpath, 3.7.17);
char *
diff --git a/api/src/glfs-mem-types.h b/api/src/glfs-mem-types.h
index d32d63f0f13..52033360853 100644
--- a/api/src/glfs-mem-types.h
+++ b/api/src/glfs-mem-types.h
@@ -28,6 +28,7 @@ enum glfs_mem_types_ {
glfs_mt_upcall_entry_t,
glfs_mt_acl_t,
glfs_mt_upcall_inode_t,
+ glfs_mt_realpath_t,
glfs_mt_end
};
#endif
diff --git a/api/src/glfs.h b/api/src/glfs.h
index b53af35b158..79504e0e07e 100644
--- a/api/src/glfs.h
+++ b/api/src/glfs.h
@@ -757,9 +757,11 @@ int glfs_chdir (glfs_t *fs, const char *path) __THROW
int glfs_fchdir (glfs_fd_t *fd) __THROW
GFAPI_PUBLIC(glfs_fchdir, 3.4.0);
-char *glfs_realpath (glfs_t *fs, const char *path, char *resolved_path) __THROW
+char *glfs_realpath34 (glfs_t *fs, const char *path, char *resolved_path) __THROW
GFAPI_PUBLIC(glfs_realpath, 3.4.0);
+char *glfs_realpath (glfs_t *fs, const char *path, char *resolved_path) __THROW
+ GFAPI_PUBLIC(glfs_realpath, 3.7.17);
/*
* @cmd and @flock are as specified in man fcntl(2).
*/