diff options
author | Anand V. Avati <avati@amp.gluster.com> | 2010-10-02 11:25:05 +0000 |
---|---|---|
committer | Vijay Bellur <vijay@dev.gluster.com> | 2010-10-02 22:18:56 -0700 |
commit | 99caede76b0ef312d622b2387bf9524724e7c6df (patch) | |
tree | 7b6c8cc969b5e8460e4ac4b67734422e3fad782c /xlators/storage/posix/src | |
parent | 5a4e1e69b2ec65dcefa6b37b8ac7d058f3a2c29f (diff) |
rmdir: introduce extra flags parameter in FOP prototype
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Signed-off-by: Vijay Bellur <vijay@dev.gluster.com>
BUG: 971 (dynamic volume management)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971
Diffstat (limited to 'xlators/storage/posix/src')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 398c1dd7e8b..d6874073bf1 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -54,6 +54,7 @@ #include "locking.h" #include "timer.h" #include "glusterfs3-xdr.h" +#include "hashfn.h" #undef HAVE_SET_FSID #ifdef HAVE_SET_FSID @@ -1480,9 +1481,10 @@ posix_unlink (call_frame_t *frame, xlator_t *this, return 0; } -int32_t + +int posix_rmdir (call_frame_t *frame, xlator_t *this, - loc_t *loc) + loc_t *loc, int flags) { int32_t op_ret = -1; int32_t op_errno = 0; @@ -1491,6 +1493,7 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, char * parentpath = NULL; struct iatt preparent = {0,}; struct iatt postparent = {0,}; + struct posix_private *priv = NULL; DECLARE_OLD_FS_ID_VAR; @@ -1498,6 +1501,8 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, VALIDATE_OR_GOTO (this, out); VALIDATE_OR_GOTO (loc, out); + priv = this->private; + SET_FS_ID (frame->root->uid, frame->root->gid); MAKE_REAL_PATH (real_path, this, loc->path); @@ -1515,7 +1520,17 @@ posix_rmdir (call_frame_t *frame, xlator_t *this, goto out; } - op_ret = rmdir (real_path); + if (flags) { + uint32_t hashval = 0; + char *tmp_path = alloca (strlen (priv->trash_path) + 16); + + mkdir (priv->trash_path, 0755); + hashval = gf_dm_hashfn (real_path, strlen (real_path)); + sprintf (tmp_path, "%s/%u", priv->trash_path, hashval); + op_ret = rename (real_path, tmp_path); + } else { + op_ret = rmdir (real_path); + } op_errno = errno; if (op_errno == EEXIST) |