From patchwork Sat Oct 29 20:28:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 122576 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3E6B2B6F92 for ; Sun, 30 Oct 2011 07:28:35 +1100 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RKFVx-0002kV-LN; Sat, 29 Oct 2011 20:28:25 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RKFVx-0007yu-C0; Sat, 29 Oct 2011 20:28:25 +0000 Received: from mail-bw0-f49.google.com ([209.85.214.49]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RKFVt-0007xt-QO for linux-mtd@lists.infradead.org; Sat, 29 Oct 2011 20:28:23 +0000 Received: by bke11 with SMTP id 11so2682649bke.36 for ; Sat, 29 Oct 2011 13:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=subject:from:reply-to:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:message-id :mime-version; bh=Daw1DEX7BSSW/ri4ktOGzXEsHJdaWpiarPXqvoPGckg=; b=M1bq7AIh1/jhFe6EeKlhOJKiPkqsyw/zIqaxH11uqV24g1VrUqsCUUOkkIMomeHCxK SVDmpt8cugdlMoisLzXVf/rrcAL7e7m8zRMkMNKDmQhhxwghPTAEYkMkQglGUz/rEOYH UZvDv7u9usZHgiQhdNY/zKyTe6ORpmd1Qjn1k= Received: by 10.204.29.8 with SMTP id o8mr6081281bkc.48.1319920100060; Sat, 29 Oct 2011 13:28:20 -0700 (PDT) Received: from [192.168.255.2] (host-94-101-1-70.igua.fi. [94.101.1.70]) by mx.google.com with ESMTPS id j9sm11741815bkd.2.2011.10.29.13.28.17 (version=SSLv3 cipher=OTHER); Sat, 29 Oct 2011 13:28:19 -0700 (PDT) Subject: Re: [PATCH 1/2] mtd: tests: don't use mtd0 as a default From: Artem Bityutskiy To: Wolfram Sang Date: Sat, 29 Oct 2011 23:28:14 +0300 In-Reply-To: <1319533791-32605-1-git-send-email-w.sang@pengutronix.de> References: <1319533791-32605-1-git-send-email-w.sang@pengutronix.de> X-Mailer: Evolution 3.0.2 (3.0.2-3.fc15) Message-ID: <1319920098.2126.17.camel@koala> Mime-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20111029_162822_176140_58210580 X-CRM114-Status: GOOD ( 20.97 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedekind1[at]gmail.com) 0.1 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Roland Kletzing , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: dedekind1@gmail.com List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Tue, 2011-10-25 at 11:09 +0200, Wolfram Sang wrote: > mtd tests may erase the mtd device, so force the user to specify which > mtd device to test by using the module parameter. Disable the default > (using mtd0) since this may destroy a vital part of the flash if the > module is inserted accidently or carelessly. > > Reported-by: Roland Kletzing > Signed-off-by: Wolfram Sang On top of this I've added the following patch: From 16a50bac6deb68e56c49d64d18952ba9ce5621d1 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Sat, 29 Oct 2011 23:20:34 +0300 Subject: [PATCH] mtd: add a scary warning The MTD tests require mtd device number to be specified. If the user does not specify it, print a message and warn that the tests are destructive and will wipe whole MTD device. This is a measure to make sure we do not have more reports from unhappy users accidentally losing their data. Signed-off-by: Artem Bityutskiy --- drivers/mtd/tests/mtd_oobtest.c | 6 ++++++ drivers/mtd/tests/mtd_pagetest.c | 6 ++++++ drivers/mtd/tests/mtd_readtest.c | 5 +++++ drivers/mtd/tests/mtd_speedtest.c | 6 ++++++ drivers/mtd/tests/mtd_stresstest.c | 6 ++++++ drivers/mtd/tests/mtd_subpagetest.c | 6 ++++++ drivers/mtd/tests/mtd_torturetest.c | 6 ++++++ 7 files changed, 41 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c index f253acb..673f3d1 100644 --- a/drivers/mtd/tests/mtd_oobtest.c +++ b/drivers/mtd/tests/mtd_oobtest.c @@ -364,6 +364,12 @@ static int __init mtd_oobtest_init(void) struct mtd_oob_ops ops; loff_t addr = 0, addr0; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "MTD device: %d\n", dev); diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c index f27b196..e4c263d 100644 --- a/drivers/mtd/tests/mtd_pagetest.c +++ b/drivers/mtd/tests/mtd_pagetest.c @@ -502,6 +502,12 @@ static int __init mtd_pagetest_init(void) uint64_t tmp; uint32_t i; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "MTD device: %d\n", dev); diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c index a40d860..7b44d57 100644 --- a/drivers/mtd/tests/mtd_readtest.c +++ b/drivers/mtd/tests/mtd_readtest.c @@ -168,6 +168,11 @@ static int __init mtd_readtest_init(void) uint64_t tmp; int err, i; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "MTD device: %d\n", dev); diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index 7ce07f9..a82ac11 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c @@ -359,6 +359,12 @@ static int __init mtd_speedtest_init(void) long speed; uint64_t tmp; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); if (count) diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c index b4f8879..376fd16 100644 --- a/drivers/mtd/tests/mtd_stresstest.c +++ b/drivers/mtd/tests/mtd_stresstest.c @@ -248,6 +248,12 @@ static int __init mtd_stresstest_init(void) int i, op; uint64_t tmp; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "MTD device: %d\n", dev); diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c index 85a86a7..d6f983f 100644 --- a/drivers/mtd/tests/mtd_subpagetest.c +++ b/drivers/mtd/tests/mtd_subpagetest.c @@ -377,6 +377,12 @@ static int __init mtd_subpagetest_init(void) uint32_t i; uint64_t tmp; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "MTD device: %d\n", dev); diff --git a/drivers/mtd/tests/mtd_torturetest.c b/drivers/mtd/tests/mtd_torturetest.c index fb3b903..a08c3cd 100644 --- a/drivers/mtd/tests/mtd_torturetest.c +++ b/drivers/mtd/tests/mtd_torturetest.c @@ -209,6 +209,12 @@ static int __init tort_init(void) int err = 0, i, infinite = !cycles_count; int bad_ebs[ebcnt]; + if (dev == -1) { + printk(KERN_ERR "Please, specify the MTD device\n"); + printk(KERN_ALERT "Careful! This test will wipe the MTD device!\n"); + return -EINVAL; + } + printk(KERN_INFO "\n"); printk(KERN_INFO "=================================================\n"); printk(PRINT_PREF "Warning: this program is trying to wear out your "