소스 검색

HDFS-861. fuse-dfs does not support O_RDWR. Contributed by Brian Bockelman.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@921617 13f79535-47bb-0310-9956-ffa450edef68
Thomas White 15 년 전
부모
커밋
a9b296f152
2개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      CHANGES.txt
  2. 15 0
      src/contrib/fuse-dfs/src/fuse_impls_open.c

+ 2 - 0
CHANGES.txt

@@ -188,6 +188,8 @@ Trunk (unreleased changes)
     HDFS-859. fuse-dfs utime behavior causes issues with tar.
     (Brian Bockelman via tomwhite)
 
+    HDFS-861. fuse-dfs does not support O_RDWR. (Brian Bockelman via tomwhite)
+
 Release 0.21.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 15 - 0
src/contrib/fuse-dfs/src/fuse_impls_open.c

@@ -50,6 +50,21 @@ int dfs_open(const char *path, struct fuse_file_info *fi)
     return -EIO;
   }
 
+  if (flags & O_RDWR) {
+    hdfsFileInfo *info = hdfsGetPathInfo(dfs->fs,path);
+    if (info == NULL) {
+      // File does not exist (maybe?); interpret it as a O_WRONLY
+      // If the actual error was something else, we'll get it again when
+      // we try to open the file.
+      flags ^= O_RDWR;
+      flags |= O_WRONLY;
+    } else {
+      // File exists; open this as read only.
+      flags ^= O_RDWR;
+      flags |= O_RDONLY;
+    }
+  }
+
   if ((fh->hdfsFH = hdfsOpenFile(fh->fs, path, flags,  0, 0, 0)) == NULL) {
     syslog(LOG_ERR, "ERROR: could not connect open file %s:%d\n", __FILE__, __LINE__);
     syslog(LOG_ERR, "ERROR: errno %d\n", errno);