Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2366293imm; Tue, 10 Jul 2018 19:26:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe53CnsTnpK1r+UAxvVj2PW1ePUkFvCSrssEy+ps7rtFdABW6vjXfSItEwCfBwxEdYpnZfG X-Received: by 2002:a17:902:b944:: with SMTP id h4-v6mr12422521pls.157.1531275964807; Tue, 10 Jul 2018 19:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531275964; cv=none; d=google.com; s=arc-20160816; b=Q2w+fOP64Rx89gYFm/owkg0wM3O4s6jNY//ZJrQCq/cNR1+Z7cwYkF14AOgE0wUylw Rno42eKdw4TaxzREK43jwVPv9C7KFGPXttHDGGF2WbN3+UlBopXn+7lHYXVaAadFnE5Z wqWnZFnSLYHMobWDJ+hHeDtm5N53YSWIX0Zonm/ePcboNGYY91jbdlKNM+77EhRWjuDB XODIdy2NI5MzasLS4L2gAm126Nu5v4A29Y84N107rUzhIwMMOC7Io/08qjVClhHR2Kqw Cj6vi8+eoZ5ZjOGcAbCaZOnmq1RetHXbZRhp8XFKr7o9T3aSytz1qFXPrtGtEVGFNxyM 9PKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Vumpn7jyM4tXZzuu8IxvbUDntmgiYOBmJRdfosGgfV4=; b=zJ9ZdbBO28QjwkypMQDALFkXT1/eiU2I/nLi5rpPwhIx0HkF+XTEmxZDfKSIUPPdq+ 9gqO0BH/+tpo+85r8RN9elrgZM+3wgvU+1kmQxYJ7LS/8Kyw9xhHyCiK8yde0Nvbn3dc MliGRCRwHZCs9TFM1OeLxzTwZsmZV23l1RpM4O6gOd8+QulHMlGOL5n/fed0x8H+oJAj 1VTVoP48f/b6n/sx+wZsQYtHR1jLzD07gr/uD7vRm1shf7OREu/BkrD/dPwQnHA3/mWv HE4KTQCOylDJ5CK+zE9kRRkG93FkLwmdQzyVZMKV2dmAIY+dcUKD/rToRoBmr8iZ7SCd 5ijA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e125-v6si3303866pgc.424.2018.07.10.19.25.49; Tue, 10 Jul 2018 19:26:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732815AbeGKC0Y (ORCPT + 99 others); Tue, 10 Jul 2018 22:26:24 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:45628 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732372AbeGKCYG (ORCPT ); Tue, 10 Jul 2018 22:24:06 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fd4lc-0003Jw-On; Wed, 11 Jul 2018 02:22:08 +0000 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [RFC][PATCH 24/42] ->atomic_open(): return 0 in all success cases Date: Wed, 11 Jul 2018 03:21:48 +0100 Message-Id: <20180711022206.12571-24-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180711022206.12571-1-viro@ZenIV.linux.org.uk> References: <20180711021136.GN30522@ZenIV.linux.org.uk> <20180711022206.12571-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro FMODE_OPENED can be used to distingusish "successful open" from the "called finish_no_open(), do it yourself" cases. Since finish_no_open() has been adjusted, no changes in the instances were actually needed. The caller has been adjusted. Signed-off-by: Al Viro --- fs/namei.c | 30 +++++++++++++++--------------- fs/open.c | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 4ce780a8ebbc..8b1e5cb85f58 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3054,21 +3054,21 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, open_to_namei_flags(open_flag), mode); d_lookup_done(dentry); if (!error) { - /* - * We didn't have the inode before the open, so check open - * permission here. - */ - int acc_mode = op->acc_mode; - if (file->f_mode & FMODE_CREATED) { - WARN_ON(!(open_flag & O_CREAT)); - fsnotify_create(dir, dentry); - acc_mode = 0; - } - error = may_open(&file->f_path, acc_mode, open_flag); - if (WARN_ON(error > 0)) - error = -EINVAL; - } else if (error > 0) { - if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { + if (file->f_mode & FMODE_OPENED) { + /* + * We didn't have the inode before the open, so check open + * permission here. + */ + int acc_mode = op->acc_mode; + if (file->f_mode & FMODE_CREATED) { + WARN_ON(!(open_flag & O_CREAT)); + fsnotify_create(dir, dentry); + acc_mode = 0; + } + error = may_open(&file->f_path, acc_mode, open_flag); + if (WARN_ON(error > 0)) + error = -EINVAL; + } else if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { error = -EIO; } else { if (file->f_path.dentry) { diff --git a/fs/open.c b/fs/open.c index a46ba6647562..2649b6695f60 100644 --- a/fs/open.c +++ b/fs/open.c @@ -866,13 +866,13 @@ EXPORT_SYMBOL(finish_open); * NB: unlike finish_open() this function does consume the dentry reference and * the caller need not dput() it. * - * Returns "1" which must be the return value of ->atomic_open() after having + * Returns "0" which must be the return value of ->atomic_open() after having * called this function. */ int finish_no_open(struct file *file, struct dentry *dentry) { file->f_path.dentry = dentry; - return 1; + return 0; } EXPORT_SYMBOL(finish_no_open); -- 2.11.0