hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dhr...@apache.org
Subject svn commit: r678080 - in /hadoop/core/trunk: CHANGES.txt src/c++/libhdfs/hdfs.c src/c++/libhdfs/hdfs_test.c
Date Sat, 19 Jul 2008 00:13:34 GMT
Author: dhruba
Date: Fri Jul 18 17:13:34 2008
New Revision: 678080

URL: http://svn.apache.org/viewvc?rev=678080&view=rev
Log:
HADOOP-3485. Allow writing to files over fuse.
(Pete Wyckoff via dhruba)


Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/c++/libhdfs/hdfs.c
    hadoop/core/trunk/src/c++/libhdfs/hdfs_test.c

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=678080&r1=678079&r2=678080&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Fri Jul 18 17:13:34 2008
@@ -134,6 +134,9 @@
     HADOOP-3485. Allow writing to files over fuse.
     (Pete Wyckoff via dhruba)
 
+    HADOOP-3723. The flags to the libhdfs.create call can be treated as
+    a bitmask. (Pete Wyckoff via dhruba)
+
 Release 0.18.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/c++/libhdfs/hdfs.c
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/c%2B%2B/libhdfs/hdfs.c?rev=678080&r1=678079&r2=678080&view=diff
==============================================================================
--- hadoop/core/trunk/src/c++/libhdfs/hdfs.c (original)
+++ hadoop/core/trunk/src/c++/libhdfs/hdfs.c Fri Jul 18 17:13:34 2008
@@ -253,9 +253,16 @@
 
     jobject jFS = (jobject)fs;
 
+    if(flags & O_RDWR) {
+      fprintf(stderr, "ERROR: cannot open an hdfs file in O_RDWR mode\n");
+      errno = ENOTSUP;
+      return NULL;
+    }
+
+
     /* The hadoop java api/signature */
-    const char* method = (flags == O_RDONLY) ? "open" : "create";
-    const char* signature = (flags == O_RDONLY) ?
+    const char* method = ((flags & O_WRONLY) == 0) ? "open" : "create";
+    const char* signature = ((flags & O_WRONLY) == 0) ?
         JMETHOD2(JPARAM(HADOOP_PATH), "I", JPARAM(HADOOP_ISTRM)) :
         JMETHOD2(JPARAM(HADOOP_PATH), "ZISJ", JPARAM(HADOOP_OSTRM));
 
@@ -302,7 +309,7 @@
         jBufferSize = jVal.i;
     }
 
-    if (flags == O_WRONLY) {
+    if (flags & O_WRONLY) {
         //replication
 
         if (!replication) {
@@ -334,7 +341,7 @@
     /* Create and return either the FSDataInputStream or
        FSDataOutputStream references jobject jStream */
 
-    if (flags == O_RDONLY) {
+    if ((flags & O_WRONLY) == 0) {
         if (invokeMethod(env, &jVal, INSTANCE, jFS, HADOOP_FS,
                          method, signature, jPath, jBufferSize)) {
             fprintf(stderr, "Call to org.apache.hadoop.fs."
@@ -361,7 +368,7 @@
         return NULL;
     }
     file->file = (*env)->NewGlobalRef(env, jVal.l);
-    file->type = ((flags == O_RDONLY) ? INPUT : OUTPUT);
+    file->type = (((flags & O_WRONLY) == 0) ? INPUT : OUTPUT);
 
     destroyLocalReference(env, jVal.l);
 

Modified: hadoop/core/trunk/src/c++/libhdfs/hdfs_test.c
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/c%2B%2B/libhdfs/hdfs_test.c?rev=678080&r1=678079&r2=678080&view=diff
==============================================================================
--- hadoop/core/trunk/src/c++/libhdfs/hdfs_test.c (original)
+++ hadoop/core/trunk/src/c++/libhdfs/hdfs_test.c Fri Jul 18 17:13:34 2008
@@ -37,7 +37,7 @@
         
         const char* writePath = "/tmp/testfile.txt";
         
-        hdfsFile writeFile = hdfsOpenFile(fs, writePath, O_WRONLY, 0, 0, 0);
+        hdfsFile writeFile = hdfsOpenFile(fs, writePath, O_WRONLY|O_CREAT, 0, 0, 0);
         if(!writeFile) {
             fprintf(stderr, "Failed to open %s for writing!\n", writePath);
             exit(-1);



Mime
View raw message