From patchwork Thu Jan 17 16:53:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1997201 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2576D3FE1B for ; Thu, 17 Jan 2013 16:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757133Ab3AQQyC (ORCPT ); Thu, 17 Jan 2013 11:54:02 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:64839 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754680Ab3AQQx2 (ORCPT ); Thu, 17 Jan 2013 11:53:28 -0500 Received: by mail-lb0-f176.google.com with SMTP id k6so2016162lbo.7 for ; Thu, 17 Jan 2013 08:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=kcy+19st2t0L7z8WgOo4YhzopfjHAy9PM88YiKi0v2A=; b=V5fSz5X6SAEGUexVuSdSl8naqa1LaQYk2wp8PI1BZRdymwHW/l+jCK45+Y1RTK3XU3 jQLb+afls8uAwmWgwG72FOblyLXr8xX6Z1b5P4YYybcojWEB1Rr3bHrIv3uSszKL902g khsQKALJ1qsKueb+QpVsCXKmCMXKDscVUpjXeW9GD26+bppg0p3Fa6eQHdippLtIQj2a FxCyHEcV3nyCz9irPAgjRVTTXBFAYC9spTuZpOX/x3qB+NzBunbNBCeJrLK/4kJtMQlK AG7001GkNQuZmCU6cVnYrzvovpIiliWmJiPDk9M1SP8rPOq5kSuTC5rFIvaQH1buLQY4 LKRw== X-Received: by 10.112.44.229 with SMTP id h5mr2566514lbm.12.1358441606704; Thu, 17 Jan 2013 08:53:26 -0800 (PST) Received: from builder.office.etersoft.ru (pritvor.etersoft.ru. [91.232.225.2]) by mx.google.com with ESMTPS id z4sm1067635lbn.17.2013.01.17.08.53.24 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jan 2013 08:53:25 -0800 (PST) From: Pavel Shilovsky To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, wine-devel@winehq.org Subject: [PATCH v2 7/8] NFSv4: Add O_DENY* open flags support Date: Thu, 17 Jan 2013 20:53:03 +0400 Message-Id: <1358441584-8783-7-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.8.1.1 In-Reply-To: <1358441584-8783-1-git-send-email-piastry@etersoft.ru> References: <1358441584-8783-1-git-send-email-piastry@etersoft.ru> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org by passing these flags to NFSv4 open request. Signed-off-by: Pavel Shilovsky --- fs/nfs/nfs4xdr.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 40836ee..0a0cd1e 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1322,7 +1322,8 @@ static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struc encode_string(xdr, name->len, name->name); } -static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) +static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode, + int open_flags) { __be32 *p; @@ -1340,7 +1341,22 @@ static void encode_share_access(struct xdr_stream *xdr, fmode_t fmode) default: *p++ = cpu_to_be32(0); } - *p = cpu_to_be32(0); /* for linux, share_deny = 0 always */ + if (open_flags & O_DENYMAND) { + switch (open_flags & (O_DENYREAD|O_DENYWRITE)) { + case O_DENYREAD: + *p = cpu_to_be32(NFS4_SHARE_DENY_READ); + break; + case O_DENYWRITE: + *p = cpu_to_be32(NFS4_SHARE_DENY_WRITE); + break; + case O_DENYREAD|O_DENYWRITE: + *p = cpu_to_be32(NFS4_SHARE_DENY_BOTH); + break; + default: + *p = cpu_to_be32(0); + } + } else + *p = cpu_to_be32(0); } static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_openargs *arg) @@ -1351,7 +1367,7 @@ static inline void encode_openhdr(struct xdr_stream *xdr, const struct nfs_opena * owner 4 = 32 */ encode_nfs4_seqid(xdr, arg->seqid); - encode_share_access(xdr, arg->fmode); + encode_share_access(xdr, arg->fmode, arg->open_flags); p = reserve_space(xdr, 36); p = xdr_encode_hyper(p, arg->clientid); *p++ = cpu_to_be32(24); @@ -1489,7 +1505,7 @@ static void encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_close encode_op_hdr(xdr, OP_OPEN_DOWNGRADE, decode_open_downgrade_maxsz, hdr); encode_nfs4_stateid(xdr, arg->stateid); encode_nfs4_seqid(xdr, arg->seqid); - encode_share_access(xdr, arg->fmode); + encode_share_access(xdr, arg->fmode, 0); } static void