summaryrefslogtreecommitdiffstats
path: root/api/src/glfs-resolve.c
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2013-04-14 02:58:34 -0700
committerVijay Bellur <vbellur@redhat.com>2013-06-08 14:38:33 -0700
commitf44ada6cd9bcc5ab98ca66bedde4fe23dd1c3f05 (patch)
treeb23b9ea26670e83ba0d04885616fab6f1f6db944 /api/src/glfs-resolve.c
parentb7ac8e415961c9e203ed3f56b4115b7eb215ab94 (diff)
gfapi: support for chdir() and family
Add support for chdir, fchdir, getcwd, realpath equivalents in GFAPI. These are required for the Samba VFS plugin. Change-Id: I91d2db9146994403c98961c489c7640c51d5add2 BUG: 953694 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/5151 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'api/src/glfs-resolve.c')
-rw-r--r--api/src/glfs-resolve.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/api/src/glfs-resolve.c b/api/src/glfs-resolve.c
index a9b93818637..8b654e4dbff 100644
--- a/api/src/glfs-resolve.c
+++ b/api/src/glfs-resolve.c
@@ -98,7 +98,7 @@ glfs_resolve_symlink (struct glfs *fs, xlator_t *subvol, inode_t *inode,
ret = syncop_readlink (subvol, &loc, &path, 4096);
- if (ret)
+ if (ret < 0)
goto out;
if (lpath)
@@ -161,7 +161,12 @@ glfs_resolve_component (struct glfs *fs, xlator_t *subvol, inode_t *parent,
goto out;
}
- loc.inode = inode_grep (parent->table, parent, component);
+ if (strcmp (component, ".") == 0)
+ loc.inode = inode_ref (parent);
+ else if (strcmp (component, "..") == 0)
+ loc.inode = inode_parent (parent, 0, 0);
+ else
+ loc.inode = inode_grep (parent->table, parent, component);
if (loc.inode) {
uuid_copy (loc.gfid, loc.inode->gfid);
@@ -335,12 +340,29 @@ out:
int
+glfs_resolve_path (struct glfs *fs, xlator_t *subvol, const char *origpath,
+ loc_t *loc, struct iatt *iatt, int follow)
+{
+ int ret = -1;
+
+ if (origpath[0] == '/')
+ ret = glfs_resolve_at (fs, subvol, NULL, origpath, loc, iatt,
+ follow);
+ else
+ ret = glfs_resolve_at (fs, subvol, fs->cwd, origpath, loc, iatt,
+ follow);
+
+ return ret;
+}
+
+
+int
glfs_resolve (struct glfs *fs, xlator_t *subvol, const char *origpath,
loc_t *loc, struct iatt *iatt)
{
int ret = -1;
- ret = glfs_resolve_at (fs, subvol, NULL, origpath, loc, iatt, 1);
+ ret = glfs_resolve_path (fs, subvol, origpath, loc, iatt, 1);
return ret;
}
@@ -352,7 +374,7 @@ glfs_lresolve (struct glfs *fs, xlator_t *subvol, const char *origpath,
{
int ret = -1;
- ret = glfs_resolve_at (fs, subvol, NULL, origpath, loc, iatt, 0);
+ ret = glfs_resolve_path (fs, subvol, origpath, loc, iatt, 0);
return ret;
}