瀏覽代碼

HDFS-859. fuse-dfs utime behavior causes issues with tar. Contributed by Brian Bockelman.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@921598 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 15 年之前
父節點
當前提交
b304a6a84e
共有 2 個文件被更改,包括 16 次插入5 次删除
  1. 3 0
      CHANGES.txt
  2. 13 5
      src/contrib/fuse-dfs/src/fuse_impls_utimens.c

+ 3 - 0
CHANGES.txt

@@ -185,6 +185,9 @@ Trunk (unreleased changes)
     HDFS-858. Incorrect return codes for fuse-dfs. (Brian Bockelman via
     tomwhite)
 
+    HDFS-859. fuse-dfs utime behavior causes issues with tar.
+    (Brian Bockelman via tomwhite)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 13 - 5
src/contrib/fuse-dfs/src/fuse_impls_utimens.c

@@ -20,7 +20,7 @@
 #include "fuse_impls.h"
 #include "fuse_connect.h"
 
- int dfs_utimens(const char *path, const struct timespec ts[2])
+int dfs_utimens(const char *path, const struct timespec ts[2])
 {
   TRACE1("utimens", path)
 #if PERMS
@@ -38,14 +38,22 @@
   hdfsFS userFS;
   // if not connected, try to connect and fail out if we can't.
   if ((userFS = doConnectAsUser(dfs->nn_hostname,dfs->nn_port))== NULL) {
-    syslog(LOG_ERR, "ERROR: could not connect to dfs %s:%d\n", __FILE__, __LINE__);
+    syslog(LOG_ERR, "ERROR: could not connect to dfs %s:%d\n",
+           __FILE__, __LINE__);
     return -EIO;
   }
 
   if (hdfsUtime(userFS, path, mTime, aTime)) {
-    syslog(LOG_ERR,"ERROR: hdfs trying to utime %s to %ld/%ld",path, (long)mTime, (long)aTime);
-    fprintf(stderr,"ERROR: could not set utime for path %s\n",path);
-    return -EIO;
+    hdfsFileInfo *info = hdfsGetPathInfo(dfs->fs,path);
+    if (info == NULL) {
+      return -EIO;
+    }
+    // Silently ignore utimens failure for directories, otherwise 
+    // some programs like tar will fail.
+    if (info->mKind == kObjectKindDirectory) {
+      return 0;
+    }
+    return -errno;
   }
 #endif  
   return 0;