From 34a5ec12eedbd13f47c92108e4fb27e08598219a Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 3 Feb 2015 09:48:57 -0500 Subject: Btrfs-progs: skip opening all devices with restore When we go to fixup the dev items after a restore we scan all existing devices. If you happen to be a btrfs developer you could possibly open up some random device that you didn't just restore onto, which gives you weird errors and makes you super cranky and waste a day trying to figure out what is failing. This will make it so that we use the fd we've already opened for opening our ctree. Thanks, Signed-off-by: Josef Bacik --- btrfs-image.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'btrfs-image.c') diff --git a/btrfs-image.c b/btrfs-image.c index 3c78388a..04ec4734 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -2557,16 +2557,19 @@ static int restore_metadump(const char *input, FILE *out, int old_restore, ret = wait_for_worker(&mdrestore); if (!ret && !multi_devices && !old_restore) { + struct btrfs_root *root; struct stat st; - info = open_ctree_fs_info(target, 0, 0, + root = open_ctree_fd(fileno(out), target, 0, OPEN_CTREE_PARTIAL | - OPEN_CTREE_WRITES); - if (!info) { + OPEN_CTREE_WRITES | + OPEN_CTREE_NO_DEVICES); + if (!root) { fprintf(stderr, "unable to open %s\n", target); ret = -EIO; goto out; } + info = root->fs_info; if (stat(target, &st)) { fprintf(stderr, "statting %s failed\n", target); -- cgit v1.2.3