From patchwork Thu Jun 19 01:27:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 4380181 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E1729F26E for ; Thu, 19 Jun 2014 01:32:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA13420386 for ; Thu, 19 Jun 2014 01:32:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B2B0720380 for ; Thu, 19 Jun 2014 01:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756787AbaFSBb6 (ORCPT ); Wed, 18 Jun 2014 21:31:58 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:42711 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1755962AbaFSBb5 (ORCPT ); Wed, 18 Jun 2014 21:31:57 -0400 X-IronPort-AV: E=Sophos;i="5.00,735,1396972800"; d="scan'208";a="32121227" Received: from localhost (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Jun 2014 09:28:40 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s5J1VIxB019656 for ; Thu, 19 Jun 2014 09:31:18 +0800 Received: from wangs.fnst.cn.fujitsu.com (10.167.226.104) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Thu, 19 Jun 2014 09:31:18 +0800 From: Wang Shilong To: Subject: [PATCH 2/6] Btrfs-progs: btrfs-restore, check if specified root is fs/file tree firstly Date: Thu, 19 Jun 2014 09:27:05 +0800 Message-ID: <1403141229-25565-2-git-send-email-wangsl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1403141229-25565-1-git-send-email-wangsl.fnst@cn.fujitsu.com> References: <1403141229-25565-1-git-send-email-wangsl.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.104] 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, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Steps to reproduce: # mkfs.btrfs -f /dev/sda9 # mount /dev/sda9 /mnt # dd if=/dev/zero of=/mnt/data bs=1M count=1 # btrfs restore -r /dev/sda9 -r 2 -o /tmp If users don't input a valid fs/file root objectid, btrfs restore still continue and don't restore anything, this is unfriendly, we could check it firstly. Signed-off-by: Wang Shilong --- cmds-restore.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmds-restore.c b/cmds-restore.c index 96b97e1..934755a 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -1180,6 +1180,11 @@ int cmd_restore(int argc, char **argv) break; case 'r': root_objectid = arg_strtou64(optarg); + if (!is_fstree(root_objectid)) { + fprintf(stderr, "objectid %llu is not a valid fs/file tree\n", + root_objectid); + exit(1); + } break; case 'l': list_roots = 1;