From patchwork Wed Oct 16 14:05:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11193409 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4503314ED for ; Wed, 16 Oct 2019 14:05:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 25C6D2168B for ; Wed, 16 Oct 2019 14:05:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389096AbfJPOFh (ORCPT ); Wed, 16 Oct 2019 10:05:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:53660 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726824AbfJPOFh (ORCPT ); Wed, 16 Oct 2019 10:05:37 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A0C60B038; Wed, 16 Oct 2019 14:05:35 +0000 (UTC) From: Johannes Thumshirn To: David Sterba Cc: Linux BTRFS Mailinglist , rbrown@suse.de, Johannes Thumshirn Subject: [PATCH] btrfs-progs: warn users about the possible dangers of check --repair Date: Wed, 16 Oct 2019 16:05:33 +0200 Message-Id: <20191016140533.10583-1-jthumshirn@suse.de> X-Mailer: git-send-email 2.16.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The manual page of btrfsck clearly states 'btrfs check --repair' is a dangerous operation. Although this warning is in place users do not read the manual page and/or are used to the behaviour of fsck utilities which repair the filesystem, and thus potentially cause harm. Similar to 'btrfs balance' without any filters, add a warning and a countdown, so users can bail out before eventual corrupting the filesystem more than it already is. Signed-off-by: Johannes Thumshirn --- check/main.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/check/main.c b/check/main.c index fd05430c1f51..acded927281a 100644 --- a/check/main.c +++ b/check/main.c @@ -9970,6 +9970,23 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv) exit(1); } + if (repair) { + int delay = 10; + printf("WARNING:\n\n"); + printf("\tDo not use --repair unless you are advised to do so by a developer\n"); + printf("\tor an experienced user, and then only after having accepted that no\n"); + printf("\tfsck successfully repair all types of filesystem corruption. Eg.\n"); + printf("\tsome other software or hardware bugs can fatally damage a volume.\n"); + printf("\tThe operation will start in %d seconds.\n", delay); + printf("\tUse Ctrl-C to stop it.\n"); + while (delay) { + printf("%2d", delay--); + fflush(stdout); + sleep(1); + } + printf("\nStarting repair.\n"); + } + /* * experimental and dangerous */