From 52f5c7033058b91ceb0c72b5430c8131e2ed3759 Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Sun, 8 Jul 2012 18:29:00 +0000 Subject: [PATCH] HDFS-711. hdfsUtime does not handle atime = 0 or mtime = 0 correctly. Contributed by Colin Patrick McCabe git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1358810 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c | 5 +++-- hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 5d7d09de985..94f6d9a71f4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -425,6 +425,9 @@ Branch-2 ( Unreleased changes ) HDFS-3603. Decouple TestHDFSTrash from TestTrash. (Jason Lowe via eli) + HDFS-711. hdfsUtime does not handle atime = 0 or mtime = 0 correctly. + (Colin Patrick McCabe via eli) + BREAKDOWN OF HDFS-3042 SUBTASKS HDFS-2185. HDFS portion of ZK-based FailoverController (todd) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c index 946b31252ab..5f627d38bc4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.c @@ -1710,8 +1710,9 @@ int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime) return -2; } - jlong jmtime = mtime * (jlong)1000; - jlong jatime = atime * (jlong)1000; + const tTime NO_CHANGE = -1; + jlong jmtime = (mtime == NO_CHANGE) ? -1 : (mtime * (jlong)1000); + jlong jatime = (atime == NO_CHANGE) ? -1 : (atime * (jlong)1000); int ret = 0; jthrowable jExc = NULL; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h index 67bd288e1bb..bd29e83e7c1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/hdfs.h @@ -468,8 +468,8 @@ extern "C" { * hdfsUtime * @param fs The configured filesystem handle. * @param path the path to the file or directory - * @param mtime new modification time or 0 for only set access time in seconds - * @param atime new access time or 0 for only set modification time in seconds + * @param mtime new modification time or -1 for no change + * @param atime new access time or -1 for no change * @return 0 on success else -1 */ int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime);