From patchwork Thu Feb 28 15:25:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 2199051 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 9E31A3FD4E for ; Thu, 28 Feb 2013 15:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755690Ab3B1PYF (ORCPT ); Thu, 28 Feb 2013 10:24:05 -0500 Received: from mail-la0-f54.google.com ([209.85.215.54]:47610 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760655Ab3B1PW6 (ORCPT ); Thu, 28 Feb 2013 10:22:58 -0500 Received: by mail-la0-f54.google.com with SMTP id gw10so1855500lab.41 for ; Thu, 28 Feb 2013 07:22:56 -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=mMld1gISifKmo/mC/yUIGC6e2U2Nibr//wbH0rKl5/8=; b=gVymjjlB8JNpkZ7IiF55CLtgtlyO5mAcnXYjq43lw+EdVVjUZv9AYTiSQM5Lu7xCh7 n9dSBZDsPI+ddxoDvMrh9UuWUiyMcbzwDOh93mp4IRes9HeqGjSeDA0vVrkvggNHfCic +ewUcaGOWwYIN8xGd6oXTQAy0JDxKiacSZnDjP+tVvLD8NfoRb66A9T/shXyIEQ8zGyj 1p5QEZlaGlSvwMIQ0fDqebSah6y0I9SqZUQNZSWAaa7GQoOlH1db2aM8n/w24I1+bU8h FFc0unBdypT3sB1E5Ld3tvksUSkuDcCOJfLV5pzmbVqCif3Ivt+WHfAI1BC1DDSdyADr LGvA== X-Received: by 10.112.36.2 with SMTP id m2mr3710000lbj.100.1362064976534; Thu, 28 Feb 2013 07:22:56 -0800 (PST) Received: from workstation.localdomain ([79.126.96.201]) by mx.google.com with ESMTPS id f4sm3055511lbo.4.2013.02.28.07.22.54 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 07:22:55 -0800 (PST) From: Pavel Shilovsky To: linux-kernel@vger.kernel.org Cc: linux-cifs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, wine-devel@winehq.org Subject: [PATCH v3 6/7] NFSv4: Add O_DENY* open flags support Date: Thu, 28 Feb 2013 19:25:32 +0400 Message-Id: <1362065133-9490-7-git-send-email-piastry@etersoft.ru> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1362065133-9490-1-git-send-email-piastry@etersoft.ru> References: <1362065133-9490-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 Acked-by: Jeff Layton --- 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 26b1439..58ddc74 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1325,7 +1325,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; @@ -1343,7 +1344,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) @@ -1354,7 +1370,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); @@ -1491,7 +1507,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