From patchwork Mon Jul 15 05:30:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 2827295 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6635C0AB3 for ; Mon, 15 Jul 2013 05:26:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF11620131 for ; Mon, 15 Jul 2013 05:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 13F882012C for ; Mon, 15 Jul 2013 05:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753982Ab3GOF0Z (ORCPT ); Mon, 15 Jul 2013 01:26:25 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:38989 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753765Ab3GOF0M (ORCPT ); Mon, 15 Jul 2013 01:26:12 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r6F5Q9kN008931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Jul 2013 05:26:09 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6F5Q8uN017568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 15 Jul 2013 05:26:09 GMT Received: from abhmt105.oracle.com (abhmt105.oracle.com [141.146.116.57]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6F5Q8AO014735; Mon, 15 Jul 2013 05:26:08 GMT Received: from wish.sg.oracle.com (/10.186.101.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 14 Jul 2013 22:26:07 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org, dsterba@suse.cz Subject: [PATCH 05/11] btrfs-progs: btrfs_scan_one_dir not to skip links when /dev/mapper is provided Date: Mon, 15 Jul 2013 13:30:51 +0800 Message-Id: <1373866257-10519-6-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 1.8.1.164.g2d0029e In-Reply-To: <1373866257-10519-1-git-send-email-anand.jain@oracle.com> References: <1370876190-16520-1-git-send-email-anand.jain@oracle.com> <1373866257-10519-1-git-send-email-anand.jain@oracle.com> X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.3 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 we would need btrfs_scan_one_dir to san devs under /dev/mapper, but /dev/mapper has links to the actual devs and current implementation of btrfs_scan_one_dir skips links so it does not pick any links under /dev/mapper. skipping links is fine when scanning whole of /dev. But when we just want to scan /dev/mapper we want to avoid skipping links otherwise we would be left with nothing. This patch just adds the check if we are scanning devs ONLY under /dev/mapper if when so it will not skip links Thanks Signed-off-by: Anand Jain --- utils.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/utils.c b/utils.c index 345bfdc..59010c9 100644 --- a/utils.c +++ b/utils.c @@ -1040,6 +1040,7 @@ int btrfs_scan_one_dir(char *dirname, int run_ioctl) struct list_head pending_list; struct btrfs_fs_devices *tmp_devices; u64 num_devices; + int skip_link = 1; INIT_LIST_HEAD(&pending_list); @@ -1048,6 +1049,9 @@ int btrfs_scan_one_dir(char *dirname, int run_ioctl) return -ENOMEM; strcpy(pending->name, dirname); + if (!strncmp(dirname, "/dev/mapper", strlen("/dev/mapper"))) + skip_link = 0; + again: dirname_len = strlen(pending->name); fullpath = malloc(PATH_MAX); @@ -1079,7 +1083,7 @@ again: fprintf(stderr, "failed to stat %s\n", fullpath); continue; } - if (S_ISLNK(st.st_mode)) + if (skip_link && S_ISLNK(st.st_mode)) continue; if (S_ISDIR(st.st_mode)) { struct pending_dir *next = malloc(sizeof(*next)); @@ -1090,7 +1094,7 @@ again: strcpy(next->name, fullpath); list_add_tail(&next->list, &pending_list); } - if (!S_ISBLK(st.st_mode)) { + if (skip_link && !S_ISBLK(st.st_mode)) { continue; } fd = open(fullpath, O_RDONLY);