From 7771adf9fca9847af6603226de74946abc47165a Mon Sep 17 00:00:00 2001 From: huanwen ren Date: Wed, 21 Dec 2016 01:26:43 +0000 Subject: [PATCH] client: priority to verify the correctness of the "flag" Signed-off-by: huanwen ren --- src/client/Client.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 5de2b22cbbc2b..27135705e1ad3 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7994,17 +7994,17 @@ void Client::_put_fh(Fh *f) int Client::_open(Inode *in, int flags, mode_t mode, Fh **fhp, const UserPerm& perms) { + if (in->snapid != CEPH_NOSNAP && + (flags & (O_WRONLY | O_RDWR | O_CREAT | O_TRUNC | O_APPEND))) { + return -EROFS; + } + int cmode = ceph_flags_to_mode(flags); if (cmode < 0) return -EINVAL; int want = ceph_caps_for_mode(cmode); int result = 0; - if (in->snapid != CEPH_NOSNAP && - (flags & (O_WRONLY | O_RDWR | O_CREAT | O_TRUNC | O_APPEND))) { - return -EROFS; - } - in->get_open_ref(cmode); // make note of pending open, since it effects _wanted_ caps. if ((flags & O_TRUNC) == 0 && -- 2.39.5