Skip to content

Commit

Permalink
ceph: fix file mode calculation
Browse files Browse the repository at this point in the history
open(2) must always include one of O_RDONLY, O_WRONLY, or O_RDWR.  No need
for any O_APPEND special case.

Passing O_WRONLY|O_RDWR is undefined according to the man page, but the
Linux VFS interprets this as O_RDWR, so we'll do the same.

This fixes open(2) with flags O_RDWR|O_APPEND, which was incorrectly being
translated to readonly.

Reported-by: Fyodor Ustinov <[email protected]>
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Jul 19, 2011
1 parent d7f124f commit 38be7a7
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions net/ceph/ceph_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ 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)
flags |= O_WRONLY;

if ((flags & O_ACCMODE) == O_RDWR)
mode = CEPH_FILE_MODE_RDWR;
else if ((flags & O_ACCMODE) == O_WRONLY)
switch (flags & O_ACCMODE) {
case O_WRONLY:
mode = CEPH_FILE_MODE_WR;
else
break;
case O_RDONLY:
mode = CEPH_FILE_MODE_RD;

break;
case O_RDWR:
case O_ACCMODE: /* this is what the VFS does */
mode = CEPH_FILE_MODE_RDWR;
break;
}
#ifdef O_LAZY
if (flags & O_LAZY)
mode |= CEPH_FILE_MODE_LAZY;
Expand Down

0 comments on commit 38be7a7

Please sign in to comment.