From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 5/6 v2] btrfs-progs: btrfs_scan_one_dir not to skip links when /dev/mapper is provided
Date: Thu, 30 May 2013 11:40:25 +0800 [thread overview]
Message-ID: <1369885226-3640-6-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1369885226-3640-1-git-send-email-anand.jain@oracle.com>
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 <anand.jain@oracle.com>
---
utils.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/utils.c b/utils.c
index f15136b..6ac7c73 100644
--- a/utils.c
+++ b/utils.c
@@ -1018,6 +1018,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);
@@ -1026,6 +1027,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);
@@ -1057,7 +1061,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));
@@ -1068,7 +1072,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);
--
1.8.1.227.g44fe835
next prev parent reply other threads:[~2013-05-30 3:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 10:54 [PATCH 0/4] a structure for the disks scan for btrfs Anand Jain
2013-05-17 10:54 ` [PATCH 1/4] btrfs-progs: replace filesystem show --all-devices with -d option Anand Jain
2013-05-17 10:54 ` [PATCH 2/4] btrfs-progs: label option in btrfs filesystem show is not coded Anand Jain
2013-05-17 10:54 ` [PATCH 3/4] btrfs-progs: use /dev/mapper to find the btrfs disks Anand Jain
2013-05-17 10:54 ` [PATCH 4/4] btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments Anand Jain
2013-05-17 11:21 ` [PATCH 0/4] a structure for the disks scan for btrfs Gabriel de Perthuis
2013-05-17 11:25 ` Gabriel de Perthuis
2013-05-18 4:35 ` anand jain
2013-05-30 3:40 ` [PATCH 0/6 v2] btrfs-progs: " Anand Jain
2013-05-30 3:40 ` [PATCH 1/6 v2] btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments Anand Jain
2013-05-30 3:40 ` [PATCH 2/6 v2] btrfs-progs: label option in btrfs filesystem show is not coded Anand Jain
2013-05-30 3:40 ` [PATCH 3/6 v2] btrfs-progs: update device scan usage Anand Jain
2013-05-30 3:40 ` [PATCH 4/6 v2] btrfs-progs: congregate dev scan Anand Jain
2013-05-31 8:17 ` [PATCH 4/6 v3] " Anand Jain
2013-05-30 3:40 ` Anand Jain [this message]
2013-05-30 3:40 ` [PATCH 6/6 v2] btrfs-progs: scan /dev/mapper in filesystem show and device scan Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369885226-3640-6-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).