From f44ada6cd9bcc5ab98ca66bedde4fe23dd1c3f05 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Sun, 14 Apr 2013 02:58:34 -0700 Subject: 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 Reviewed-on: http://review.gluster.org/5151 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- api/src/glfs-resolve.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'api/src/glfs-resolve.c') 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); @@ -334,13 +339,30 @@ 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; } -- cgit