Browse Source

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/branches/branch-2@1358811 13f79535-47bb-0310-9956-ffa450edef68
Eli Collins 13 years ago
parent
commit
9f79f45b8c

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -274,6 +274,9 @@ Release 2.0.1-alpha - UNRELEASED
 
     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)

+ 3 - 2
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;

+ 2 - 2
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);