From patchwork Tue Jul 29 00:03:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Maggard X-Patchwork-Id: 4637931 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 4D98EC0338 for ; Tue, 29 Jul 2014 00:03:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C49D20155 for ; Tue, 29 Jul 2014 00:03:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B64E420127 for ; Tue, 29 Jul 2014 00:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752146AbaG2ADk (ORCPT ); Mon, 28 Jul 2014 20:03:40 -0400 Received: from mail-pd0-f182.google.com ([209.85.192.182]:46898 "EHLO mail-pd0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726AbaG2ADk (ORCPT ); Mon, 28 Jul 2014 20:03:40 -0400 Received: by mail-pd0-f182.google.com with SMTP id fp1so10755127pdb.13 for ; Mon, 28 Jul 2014 17:03:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=D07zea380B8foY1yJXUCxEQeKYUPUGZD6ag5FvjYsBw=; b=ZHOLVeKxHVLVksVUFKh8W4mC+ZeBXd6IkMjzmjwntDXKpqpyOWy0v03ozkGyIWffxA QX17lfZCPYUBmWkqPjFYJCNjt9JQOS2IaN/4JteeN2cWkL/r8LUIbCWkMaXib0Ci9GU8 604Joc83yBiZLQxCbjLuiO8kdnAKrIEw5NhqDV8mk0RQlpIa9QSix+6dXuoiANa/USgb rhX3hwLX41oRnAQOujivFSZcmhcu4iODhd9xlW9KEMZtTTIQkXaLwppiHwKb5od374Im lW0NQpQLt+pNJVX8yvR9SNY8qpfd7s2MonEqmVIvvTWMXvbnHpGHnoyT5UFk/qoup7AY dwhQ== X-Received: by 10.68.222.136 with SMTP id qm8mr42267669pbc.92.1406592219697; Mon, 28 Jul 2014 17:03:39 -0700 (PDT) Received: from jmaggard-ThinkPad-W520.infrant-6.com ([209.249.181.1]) by mx.google.com with ESMTPSA id v12sm26192803pdi.30.2014.07.28.17.03.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jul 2014 17:03:38 -0700 (PDT) From: Justin Maggard To: linux-btrfs@vger.kernel.org Cc: Justin Maggard Subject: [PATCH] btrfs-progs: add always option to restore's looping prompt Date: Mon, 28 Jul 2014 17:03:31 -0700 Message-Id: <1406592211-7726-1-git-send-email-jmaggard10@gmail.com> X-Mailer: git-send-email 1.9.1 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.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 If you are using btrfs restore to try to recover a very large or fragmented file, you may encounter _lots_ of prompts requiring you to press 'y' to continue because we are looping a lot. Add the option to press 'a', to supress these prompts for the rest of the file. --- cmds-restore.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cmds-restore.c b/cmds-restore.c index 96b97e1..ae95d5a 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -410,17 +410,19 @@ static int ask_to_continue(const char *file) char *ret; printf("We seem to be looping a lot on %s, do you want to keep going " - "on ? (y/N): ", file); + "on ? (y/N/a): ", file); again: ret = fgets(buf, 2, stdin); if (*ret == '\n' || tolower(*ret) == 'n') - return 1; + return 0; + if (tolower(*ret) == 'a') + return 2; if (tolower(*ret) != 'y') { printf("Please enter either 'y' or 'n': "); goto again; } - return 0; + return 1; } @@ -588,11 +590,14 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, } while (1) { - if (loops++ >= 1024) { + if (loops >= 0 && loops++ >= 1024) { ret = ask_to_continue(file); - if (ret) + if (ret == 0) break; - loops = 0; + else if (ret == 1) + loops = 0; + else if (ret == 2) + loops = -1; } if (path->slots[0] >= btrfs_header_nritems(leaf)) { do {