From patchwork Fri Mar 1 18:37:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elie De Brauwer X-Patchwork-Id: 224430 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.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 366D22C0303 for ; Sat, 2 Mar 2013 05:39:44 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UBUqT-0002GN-Gb; Fri, 01 Mar 2013 18:38:13 +0000 Received: from mail-ee0-f53.google.com ([74.125.83.53]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UBUqK-0002CH-HD for linux-mtd@lists.infradead.org; Fri, 01 Mar 2013 18:38:05 +0000 Received: by mail-ee0-f53.google.com with SMTP id e53so2555413eek.12 for ; Fri, 01 Mar 2013 10:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Xgq4QmFkGhygeRrbHIhf9PqV8NW56l74ujM8aiTlbnc=; b=iHOz1UwK4YOHOHwFQwZwLYDtv+ysRpjJfIccmg9pEUheXoLu86mb2ukYrOXjIl9wh7 EIWJb9s05zGRca61H5kKtQCiGWHgoUMoLXexhM6Iat3rQWSSFR0dC+hyepgHb5ON6uN2 buvMCcMM+sarEHhdTixGQHeUoToPt/wBkGwScNIiJe8I3T0iKSwLEKz38VHg9OnNDXjU KHabvj7Sx6o6Y3OEkOGARXVKyn4HpfFEFC5KgWuXB8yTBVQfScLGXH9nnccKywe0xE8C bXZXbxMv4+kQn1W4ZPHCL1eU5bcM5IRBahlEQH+K4U1ypb5UpMUx6XcthqTURHnbyfWE G2HA== X-Received: by 10.15.67.134 with SMTP id u6mr29986550eex.6.1362163082644; Fri, 01 Mar 2013 10:38:02 -0800 (PST) Received: from lapelidb.telenet.be (dD576B56A.access.telenet.be. [213.118.181.106]) by mx.google.com with ESMTPS id f47sm18434443eep.13.2013.03.01.10.38.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 01 Mar 2013 10:38:01 -0800 (PST) From: Elie De Brauwer To: linux-mtd@lists.infradead.org Subject: [PATCH 2/4] integck.c: rework file_check_data to immediately dump the buffer containing the errors Date: Fri, 1 Mar 2013 19:37:38 +0100 Message-Id: <1362163060-5629-3-git-send-email-eliedebrauwer@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1362163060-5629-1-git-send-email-eliedebrauwer@gmail.com> References: <1362163060-5629-1-git-send-email-eliedebrauwer@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130301_133804_692702_CB2586FE X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.83.53 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (eliedebrauwer[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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: eliedebrauwer@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Elie De Brauwer --- tests/fs-tests/integrity/integck.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c index 2c6ffea..5ea3642 100644 --- a/tests/fs-tests/integrity/integck.c +++ b/tests/fs-tests/integrity/integck.c @@ -1502,7 +1502,8 @@ static void file_check_data(struct file_info *file, int fd, { size_t remains, block, i; off_t r; - char buf[IO_BUFFER_SIZE]; + unsigned char read_buf[IO_BUFFER_SIZE]; + unsigned char check_buf[IO_BUFFER_SIZE]; unsigned int seed = w->random_seed; if (args.power_cut_mode && !file->clean) @@ -1517,17 +1518,28 @@ static void file_check_data(struct file_info *file, int fd, block = IO_BUFFER_SIZE; else block = remains; - CHECK(read(fd, buf, block) == block); - for (i = 0; i < block; ++i) { - char c = (char)rand_r(&seed); - if (buf[i] != c) { - errmsg("file_check_data failed at %zu checking " - "data at %llu size %zu", w->size - remains + i, - (unsigned long long)w->offset, w->size); - file_info_display(file); - save_file(fd, file); - } - CHECK(buf[i] == c); + CHECK(read(fd, read_buf, block) == block); + for (i = 0; i < block; ++i) + check_buf[i] = (char)rand_r(&seed); + + if (memcmp(check_buf, read_buf, block) != 0) { + errmsg("file_check_data failed, dumping " + "data at offset %llu size %zu", + (unsigned long long)w->offset, w->size); + + fprintf (stderr, "Read data:\n"); + for (r = 0; r < block; ++r) + fprintf(stderr, "%02x%c", + read_buf[r], ((r+1)%16)?' ':'\n'); + fprintf(stderr, "\nExpected data:\n"); + for (r = 0; r < block; ++r) + fprintf(stderr, "%02x%c", + check_buf[r], ((r+1)%16)?' ':'\n'); + fprintf(stderr, " \n"); + + file_info_display(file); + save_file(fd, file); + CHECK(0); } remains -= block; }