From b1cb581424305592fac5394a578b307117b22fe7 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Wed, 17 Feb 2016 15:50:05 +0530 Subject: features/trash: Retain file permissions during truncate Consider the situation where directory path for a truncated file does not exists under trash directory. In this scenario after creating the required path we failed to create the orginal file with proper permissions. Eventhough we try to fetch permissions from local->origpath, it was never filled with required value in truncate and ftruncate call paths. This change will copy original location to local->origpath inside both fop handling functions. Change-Id: If5930b6d368d08e58f04db999f3f9edb9250bcb9 BUG: 1309342 Signed-off-by: Anoop C S Reviewed-on: http://review.gluster.org/13461 Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: jiffin tony Thottan Reviewed-by: Jeff Darcy --- xlators/features/trash/src/trash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'xlators/features/trash') diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index 964817ef9f1..1381e8b049d 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -1070,7 +1070,6 @@ trash_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflags, loc_copy (&local->loc, loc); /* rename new location of file as starting from trash directory */ - strcpy (local->origpath, pathbuf); copy_trash_path (priv->newtrash_dir, (frame->root->pid < 0), local->newpath); strcat (local->newpath, pathbuf); @@ -1722,6 +1721,8 @@ trash_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, goto out; } + strcpy (local->origpath, pathbuf); + loc_copy (&local->loc, loc); local->loc.path = pathbuf; local->fop_offset = offset; @@ -1816,6 +1817,8 @@ trash_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, goto out; } + strcpy (local->origpath, pathbuf); + /* To convert fd to location */ frame->local=local; -- cgit