Skip to content

Commit e6625fa

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: ceph: fix file mode calculation
2 parents 47126d8 + 38be7a7 commit e6625fa

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

net/ceph/ceph_fs.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ int ceph_flags_to_mode(int flags)
3636
if ((flags & O_DIRECTORY) == O_DIRECTORY)
3737
return CEPH_FILE_MODE_PIN;
3838
#endif
39-
if ((flags & O_APPEND) == O_APPEND)
40-
flags |= O_WRONLY;
4139

42-
if ((flags & O_ACCMODE) == O_RDWR)
43-
mode = CEPH_FILE_MODE_RDWR;
44-
else if ((flags & O_ACCMODE) == O_WRONLY)
40+
switch (flags & O_ACCMODE) {
41+
case O_WRONLY:
4542
mode = CEPH_FILE_MODE_WR;
46-
else
43+
break;
44+
case O_RDONLY:
4745
mode = CEPH_FILE_MODE_RD;
48-
46+
break;
47+
case O_RDWR:
48+
case O_ACCMODE: /* this is what the VFS does */
49+
mode = CEPH_FILE_MODE_RDWR;
50+
break;
51+
}
4952
#ifdef O_LAZY
5053
if (flags & O_LAZY)
5154
mode |= CEPH_FILE_MODE_LAZY;

0 commit comments

Comments
 (0)