diff options
author | Sage Weil <sage@newdream.net> | 2011-07-19 14:25:04 -0400 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2011-07-19 14:25:04 -0400 |
commit | 38be7a79f7c99dd01425f19ef6cf744878b6a94b (patch) | |
tree | 5f31b24e4ecca2564ed01b212e3193ba7b2ed4b6 /net | |
parent | d7f124f129a6aea99938e0d4172c741b56fefeda (diff) |
ceph: fix file mode calculation
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 <ufm@ufm.su>
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/ceph_fs.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/net/ceph/ceph_fs.c b/net/ceph/ceph_fs.c index a3a3a31d3c37..41466ccb972a 100644 --- a/net/ceph/ceph_fs.c +++ b/net/ceph/ceph_fs.c | |||
@@ -36,16 +36,19 @@ int ceph_flags_to_mode(int flags) | |||
36 | if ((flags & O_DIRECTORY) == O_DIRECTORY) | 36 | if ((flags & O_DIRECTORY) == O_DIRECTORY) |
37 | return CEPH_FILE_MODE_PIN; | 37 | return CEPH_FILE_MODE_PIN; |
38 | #endif | 38 | #endif |
39 | if ((flags & O_APPEND) == O_APPEND) | ||
40 | flags |= O_WRONLY; | ||
41 | 39 | ||
42 | if ((flags & O_ACCMODE) == O_RDWR) | 40 | switch (flags & O_ACCMODE) { |
43 | mode = CEPH_FILE_MODE_RDWR; | 41 | case O_WRONLY: |
44 | else if ((flags & O_ACCMODE) == O_WRONLY) | ||
45 | mode = CEPH_FILE_MODE_WR; | 42 | mode = CEPH_FILE_MODE_WR; |
46 | else | 43 | break; |
44 | case O_RDONLY: | ||
47 | mode = CEPH_FILE_MODE_RD; | 45 | 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 | } | ||
49 | #ifdef O_LAZY | 52 | #ifdef O_LAZY |
50 | if (flags & O_LAZY) | 53 | if (flags & O_LAZY) |
51 | mode |= CEPH_FILE_MODE_LAZY; | 54 | mode |= CEPH_FILE_MODE_LAZY; |