From 650f9f315bed2417394b7f43290b88701f933b89 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 19 Jul 2011 08:33:29 -0700 Subject: [PATCH] mds: fix O_APPEND file mode calculation 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 Signed-off-by: Sage Weil --- src/include/ceph_fs.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/include/ceph_fs.cc b/src/include/ceph_fs.cc index 4457190b90993..933488b70c4e2 100644 --- a/src/include/ceph_fs.cc +++ b/src/include/ceph_fs.cc @@ -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) -- 2.39.5