From patchwork Mon Mar 21 07:21:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 8629861 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 611E19F372 for ; Mon, 21 Mar 2016 07:21:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EB3D20272 for ; Mon, 21 Mar 2016 07:21:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9722C20270 for ; Mon, 21 Mar 2016 07:21:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752647AbcCUHVa (ORCPT ); Mon, 21 Mar 2016 03:21:30 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:39021 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752593AbcCUHV0 (ORCPT ); Mon, 21 Mar 2016 03:21:26 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2L7LMKF030833 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 21 Mar 2016 07:21:23 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u2L7LMw1013923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 21 Mar 2016 07:21:22 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u2L7LIg7025997; Mon, 21 Mar 2016 07:21:22 GMT Received: from arch2.sg.oracle.com (/10.186.101.133) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 21 Mar 2016 00:21:17 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 3/6] btrfs-progs: remove duplicate function __is_subvol() Date: Mon, 21 Mar 2016 15:21:02 +0800 Message-Id: <1458544865-16467-4-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458544865-16467-1-git-send-email-anand.jain@oracle.com> References: <1458137673-464-1-git-send-email-anand.jain@oracle.com> <1458544865-16467-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function test_issubvolume() provides the same check, and has better logic. Signed-off-by: Anand Jain --- utils.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/utils.c b/utils.c index 046ddf8eef19..110a4badb764 100644 --- a/utils.c +++ b/utils.c @@ -1864,25 +1864,6 @@ int set_label(const char *btrfs_dev, const char *label) } /* - * Unsafe subvolume check. - * - * This only checks ino == BTRFS_FIRST_FREE_OBJECTID, even it is not in a - * btrfs mount point. - * Must use together with other reliable method like btrfs ioctl. - */ -static int __is_subvol(const char *path) -{ - struct stat st; - int ret; - - ret = lstat(path, &st); - if (ret < 0) - return ret; - - return st.st_ino == BTRFS_FIRST_FREE_OBJECTID; -} - -/* * A not-so-good version fls64. No fascinating optimization since * no one except parse_size use it */ @@ -2002,7 +1983,7 @@ u64 parse_qgroupid(const char *p) path: /* Path format like subv at 'my_subvol' is the fallback case */ - ret = __is_subvol(p); + ret = test_issubvolume(p); if (ret < 0 || !ret) goto err; fd = open(p, O_RDONLY);