]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix O_APPEND file mode calculation
authorSage Weil <sage@newdream.net>
Tue, 19 Jul 2011 15:33:29 +0000 (08:33 -0700)
committerSage Weil <sage@newdream.net>
Tue, 19 Jul 2011 15:33:37 +0000 (08:33 -0700)
Currently

  fd = open("aaa",O_RDWR|O_CREAT|O_APPEND,0666);

gives us fmode of 1 instead of 3.  We should only infer O_WRONLY if no
other mode is explicitly specified.

Reported-by: Fyodor Ustinov <ufm@ufm.su>
Signed-off-by: Sage Weil <sage@newdream.net>
src/include/ceph_fs.cc

index 4457190b909939f8a801bc26d9d48da54c0eef77..933488b70c4e2b4ab74f9507c780520535222f01 100644 (file)
@@ -41,7 +41,8 @@ int ceph_flags_to_mode(int flags)
        if ((flags & O_DIRECTORY) == O_DIRECTORY)
                return CEPH_FILE_MODE_PIN;
 #endif
-       if ((flags & O_APPEND) == O_APPEND)
+       if ((flags & O_APPEND) &&
+           (flags & O_ACCMODE) == 0)
                flags |= O_WRONLY;
 
        if ((flags & O_ACCMODE) == O_RDWR)