]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: fix open flags calculation
authorYan, Zheng <zyan@redhat.com>
Wed, 10 May 2017 00:13:52 +0000 (08:13 +0800)
committerJan Fajerski <jfajerski@suse.com>
Wed, 14 Jun 2017 13:50:09 +0000 (15:50 +0200)
(O_WRONLY | O_RDWR) is invaild open flags

Fixes: http://tracker.ceph.com/issues/19890
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 2c25c99cb4572ffae97555a56b24a4c4097dcdec)

src/pybind/cephfs/cephfs.pyx

index b27e7976d0f9162d9a47b50e0f4343e3faeb0f36..cc18fc984357a445a4ba822e084651939494e3c2 100644 (file)
@@ -618,16 +618,26 @@ cdef class LibCephFS(object):
             if flags == '':
                 cephfs_flags = os.O_RDONLY
             else:
+                access_flags = 0;
                 for c in flags:
                     if c == 'r':
-                        cephfs_flags |= os.O_RDONLY
+                        access_flags = 1;
                     elif c == 'w':
-                        cephfs_flags |= os.O_WRONLY | os.O_TRUNC | os.O_CREAT
-                    elif c == '+':
-                        cephfs_flags |= os.O_RDWR
+                        access_flags = 2;
+                        cephfs_flags |= os.O_TRUNC | os.O_CREAT
+                    elif access_flags > 0 and c == '+':
+                        access_flags = 3;
                     else:
                         raise OperationNotSupported(
                             "open flags doesn't support %s" % c)
+
+                if access_flags == 1:
+                    cephfs_flags |= os.O_RDONLY;
+                elif access_flags == 2:
+                    cephfs_flags |= os.O_WRONLY;
+                else:
+                    cephfs_flags |= os.O_RDWR;
+
         elif isinstance(flags, int):
             cephfs_flags = flags
         else: