From: "Lakshmipathi.G" <Lakshmipathi.G@giis.co.in>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: fsck-tests: corrupt and detect dir_item name (with fix)
Date: Thu, 5 Jan 2017 22:15:13 +0100 [thread overview]
Message-ID: <20170105211513.GA19134@fedori> (raw)
Please ignore previous 026-dir-item-name-corruption script,it breaks fsck-tests.sh. Use this one instead.
This test script aims to detects the corruption even though looks like --repair
wont fix the issue.
Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
.../026-dir-item-name-corruption/test.sh | 41 ++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100755 tests/fsck-tests/026-dir-item-name-corruption/test.sh
diff --git a/tests/fsck-tests/026-dir-item-name-corruption/test.sh b/tests/fsck-tests/026-dir-item-name-corruption/test.sh
new file mode 100755
index 0000000..6e76513
--- /dev/null
+++ b/tests/fsck-tests/026-dir-item-name-corruption/test.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+source $TOP/tests/common
+
+check_prereq btrfs-corrupt-block
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev 512M
+
+ROOT_NODE=256
+BTRFS_DIR_ITEM_KEY=84
+
+# test whether fsck can detect a corrupted dir item name
+test_dir_item_name_field()
+{
+ run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+
+ run_check_mount_test_dev
+ run_check $SUDO_HELPER touch $TEST_MNT/testfile.txt
+
+ run_check_umount_test_dev
+
+ # find key offset
+ key_offset=`$SUDO_HELPER $TOP/btrfs-debug-tree -t FS_TREE $TEST_DEV | \
+ grep -B3 'testfile.txt' | grep "$ROOT_NODE DIR_ITEM" | \
+ cut -f1 -d')' | awk '{print $6}'`
+
+ key=$ROOT_NODE","$BTRFS_DIR_ITEM_KEY","$key_offset
+
+ # corrupt dir item name
+ run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -D -f name \
+ -K $key $TEST_DEV
+
+ $SUDO_HELPER $TOP/btrfs check $TEST_DEV >& /dev/null && \
+ _fail "btrfs check failed to detect corruption"
+ run_check $SUDO_HELPER $TOP/btrfs check --repair $TEST_DEV
+}
+
+test_dir_item_name_field
--
2.7.4
reply other threads:[~2017-01-05 21:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170105211513.GA19134@fedori \
--to=lakshmipathi.g@giis.co.in \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox