From 99caede76b0ef312d622b2387bf9524724e7c6df Mon Sep 17 00:00:00 2001 From: "Anand V. Avati" Date: Sat, 2 Oct 2010 11:25:05 +0000 Subject: rmdir: introduce extra flags parameter in FOP prototype Signed-off-by: Anand V. Avati Signed-off-by: Vijay Bellur BUG: 971 (dynamic volume management) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=971 --- xlators/storage/posix/src/posix.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'xlators/storage/posix/src') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 398c1dd7e..d6874073b 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) -- cgit