Skip to contentSkip to conversation

btrfs-progs: Corruption-framework: Include inode nlink field

PATCH In review Lakshmipathi.G 2 participants 2 messages Jan 3, 2017 – Jan 4, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: Corruption-framework: Include inode nlink field

Will include other fields, if this gets accepted.

---
 btrfs-corrupt-block.c | 8 ++++++++
 1 file changed, 8 insertions(+)
btrfs-corrupt-block.c +8 -0
index 16680df..64376ca 100644
@@ -309,6 +309,7 @@ enum btrfs_inode_field {
 	BTRFS_INODE_FIELD_ISIZE,
 	BTRFS_INODE_FIELD_NBYTES,
 	BTRFS_INODE_FIELD_BAD,
+	BTRFS_INODE_FIELD_NLINK,
 };
 
 enum btrfs_file_extent_field {
@@ -346,6 +347,8 @@ static enum btrfs_inode_field convert_inode_field(char *field)
 		return BTRFS_INODE_FIELD_ISIZE;
 	if (!strncmp(field, "nbytes", FIELD_BUF_LEN))
 		return BTRFS_INODE_FIELD_NBYTES;
+	if (!strncmp(field, "nlink", FIELD_BUF_LEN))
+		return BTRFS_INODE_FIELD_NLINK;
 	return BTRFS_INODE_FIELD_BAD;
 }
 
@@ -603,6 +606,11 @@ static int corrupt_inode(struct btrfs_trans_handle *trans,
 		bogus = generate_u64(orig);
 		btrfs_set_inode_nbytes(path->nodes[0], ei, bogus);
 		break;
+	case BTRFS_INODE_FIELD_NLINK:
+		orig = btrfs_inode_nlink(path->nodes[0], ei);
+		bogus = generate_u32(orig);
+		btrfs_set_inode_nlink(path->nodes[0], ei, bogus);
+		break;
 	default:
 		ret = -EINVAL;
 		break;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 12 lines · Lakshmipathi.G

Will include other fields, if this gets accepted.

---
 btrfs-corrupt-block.c | 8 ++++++++
 1 file changed, 8 insertions(+)
btrfs-corrupt-block.c +0 -0
index 16680df..64376ca 100644

btrfs-corrupt-block.c enum btrfs_inode_field { · line 312

Quoted 4 lines
btrfs-corrupt-block.c +1 -0
@@ -309,6 +309,7 @@ enum btrfs_inode_field {
 	BTRFS_INODE_FIELD_ISIZE,
 	BTRFS_INODE_FIELD_NBYTES,
 	BTRFS_INODE_FIELD_BAD,
+	BTRFS_INODE_FIELD_NLINK,

This has to be before BTRFS_INODE_FIELD_BAD, as it's a not-so obvious end of field sequence maker.