linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btfs-progs: fsck-tests: corrupt nlink value test
@ 2017-01-07 23:19 Lakshmipathi.G
       [not found] ` <c9e21f30-2231-94cd-09ed-8422951e7b69@cn.fujitsu.com>
  0 siblings, 1 reply; 8+ messages in thread
From: Lakshmipathi.G @ 2017-01-07 23:19 UTC (permalink / raw)
  To: linux-btrfs

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
---
 tests/fsck-tests/025-wrong-inode-nlink/test.sh | 37 ++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 tests/fsck-tests/025-wrong-inode-nlink/test.sh

diff --git a/tests/fsck-tests/025-wrong-inode-nlink/test.sh b/tests/fsck-tests/025-wrong-inode-nlink/test.sh
new file mode 100755
index 0000000..15f1b84
--- /dev/null
+++ b/tests/fsck-tests/025-wrong-inode-nlink/test.sh
@@ -0,0 +1,37 @@
+#!/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
+
+# test whether fsck can fix a corrupted inode nlink
+test_inode_nlink_field()
+{
+	run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV
+
+	run_check_mount_test_dev
+	run_check $SUDO_HELPER touch $TEST_MNT/test_nlink.txt
+
+	run_check_umount_test_dev
+
+	# find inode_item id
+	inode_item=`$SUDO_HELPER $TOP/btrfs-debug-tree -t FS_TREE $TEST_DEV | \
+	grep -B3 "test_nlink.txt" |  grep INODE_ITEM | \
+	cut -f2 -d'(' | cut -f1 -d' ' | head -n1`
+
+	# corrupt nlink field of inode object:257
+        run_check $SUDO_HELPER $TOP/btrfs-corrupt-block -i $inode_item \
+		-f nlink $TEST_DEV
+
+	$SUDO_HELPER $TOP/btrfs check $TEST_DEV >& /dev/null && \
+			_fail "btrfs check failed to detect nlink corruption"
+	run_check $SUDO_HELPER $TOP/btrfs check --repair $TEST_DEV
+	run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV
+}
+
+test_inode_nlink_field
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-01-25 19:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-07 23:19 [PATCH] btfs-progs: fsck-tests: corrupt nlink value test Lakshmipathi.G
     [not found] ` <c9e21f30-2231-94cd-09ed-8422951e7b69@cn.fujitsu.com>
2017-01-10 17:36   ` lakshmipathi.g
2017-01-12  1:19     ` Qu Wenruo
2017-01-12 14:37       ` lakshmipathi.g
2017-01-13  1:14         ` Qu Wenruo
2017-01-16 16:35           ` lakshmipathi.g
2017-01-17 15:15             ` David Sterba
2017-01-25 19:43               ` Lakshmipathi.G

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).