From ab7dc7aafa61ae66db4ce7aa5e33e3ee408fd878 Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Tue, 15 Feb 2011 03:09:02 +0000 Subject: Revert "features/marker: Use touch TimeStamp file instead of futimens, to avoid the dependency of newer libc" This reverts commit e045741f2bb75344a557cd618e1c7b1691238703. Signed-off-by: Kaushik BV Signed-off-by: Vijay Bellur BUG: 2354 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2354 --- xlators/features/marker/src/marker.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'xlators/features/marker/src/marker.c') diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 7111c7cd3..47ce20f86 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -978,12 +978,11 @@ call_from_sp_client_to_reset_tmfile (call_frame_t *frame, xlator_t *this, dict_t *dict) { - int32_t ret = 0; - int32_t op_ret = 0; - int32_t op_errno = 0; - data_t *data = NULL; - marker_conf_t *priv = NULL; - char cmd_str[8192] = {0,}; + int32_t fd = 0; + int32_t op_ret = 0; + int32_t op_errno = 0; + data_t *data = NULL; + marker_conf_t *priv = NULL; if (frame == NULL || this == NULL || dict == NULL) return -1; @@ -1003,18 +1002,24 @@ call_from_sp_client_to_reset_tmfile (call_frame_t *frame, if (data->len == 0 || (data->len == 5 && memcmp (data->data, "RESET", 5) == 0)) { + fd = open (priv->timestamp_file, O_WRONLY); + if (fd != -1) { + /* this call is needed because of the unsurity + * whether the O_TRUNC would update the timestamps + * on a zero length file as well. Hence updating it + * manually. + */ + futimens (fd, NULL); + close (fd); + } - snprintf (cmd_str, 8192,"touch %s", priv->timestamp_file); - ret = system (cmd_str); - - if (-1 == ret) { - gf_log (this->name, GF_LOG_ERROR, - "Could not touch TimeStamp file of marker"); + if (fd != -1 || errno == ENOENT) { + op_ret = 0; + op_errno = 0; + } else { op_ret = -1; op_errno = errno; - goto out; } - } else { op_ret = -1; op_errno = EINVAL; -- cgit