From patchwork Mon May 21 14:45:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Borowski X-Patchwork-Id: 10415589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9749E6053B for ; Mon, 21 May 2018 14:46:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8889E2843B for ; Mon, 21 May 2018 14:46:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D849288AE; Mon, 21 May 2018 14:46:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3883B2843B for ; Mon, 21 May 2018 14:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752720AbeEUOp5 (ORCPT ); Mon, 21 May 2018 10:45:57 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:41986 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752247AbeEUOpx (ORCPT ); Mon, 21 May 2018 10:45:53 -0400 Received: from 89-71-158-145.dynamic.chello.pl ([89.71.158.145] helo=umbar.angband.pl) by tartarus.angband.pl with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fKm4I-0004Z1-Uy; Mon, 21 May 2018 16:45:50 +0200 Received: from kilobyte by umbar.angband.pl with local (Exim 4.91) (envelope-from ) id 1fKm4I-0004JL-KE; Mon, 21 May 2018 16:45:46 +0200 From: Adam Borowski To: linux-btrfs@vger.kernel.org, David Sterba Cc: Adam Borowski Date: Mon, 21 May 2018 16:45:15 +0200 Message-Id: <20180521144515.16501-2-kilobyte@angband.pl> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521144515.16501-1-kilobyte@angband.pl> References: <20180521144254.4zdxt6jtxoeca26o@angband.pl> <20180521144515.16501-1-kilobyte@angband.pl> X-SA-Exim-Connect-IP: 89.71.158.145 X-SA-Exim-Mail-From: kilobyte@angband.pl Subject: [PATCH 2/2] btrfs: defrag: return EPERM not EINVAL when only permissions fail X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on tartarus.angband.pl) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We give EINVAL when the request is invalid; here it's ok but merely the user has insufficient privileges. Thus, this return value reflects the error better -- as discussed in the identical case for dedupe. According to codesearch.debian.net, no userspace program distinguishes these values beyond strerror(). Signed-off-by: Adam Borowski --- fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index b75db9d72106..ae6a110987a7 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2563,7 +2563,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp) case S_IFREG: if (!capable(CAP_SYS_ADMIN) && inode_permission(inode, MAY_WRITE)) { - ret = -EINVAL; + ret = -EPERM; goto out; }