lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 31 Jul 2012 19:48:21 +0800
From:	Zheng Liu <gnehzuil.liu@...il.com>
To:	linux-ext4@...r.kernel.org
Cc:	Zheng Liu <wenqing.lz@...bao.com>
Subject: [PATCH 28/36 v4] debugfs: make punch/truncate cmd support inline data

From: Zheng Liu <wenqing.lz@...bao.com>

If inode includes inline_data flag, start and end arguments will be ignored.
Meanwhile we truncate inline data.

Signed-off-by: Zheng Liu <wenqing.lz@...bao.com>
---
 lib/ext2fs/punch.c |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c
index b53653a..28967a4 100644
--- a/lib/ext2fs/punch.c
+++ b/lib/ext2fs/punch.c
@@ -281,6 +281,34 @@ errout:
 	ext2fs_extent_free(handle);
 	return retval;
 }
+
+static errcode_t ext2fs_punch_inline_data(ext2_filsys fs, ext2_ino_t ino,
+					  struct ext2_inode *inode,
+					  blk64_t start, blk64_t end)
+{
+	struct ext2_inode_large large_inode;
+	struct inline_data idata;
+	errcode_t retval;
+	int inline_size;
+
+	retval = ext2fs_read_inode_full(fs, ino, (void *)&large_inode,
+					EXT2_INODE_SIZE(fs->super));
+	if (retval)
+		return retval;
+
+	ext2fs_iget_extra_inode(fs, &large_inode, &idata);
+
+	inline_size = idata.inline_size;
+	retval = inline_data_destory_data(fs, ino, &large_inode, &idata);
+	if (retval)
+		return retval;
+
+	large_inode.i_size = 0;
+	ext2fs_write_inode_full(fs, ino, (void *)&large_inode,
+				EXT2_INODE_SIZE(fs->super));
+
+	return retval;
+}
 	
 /*
  * Deallocate all logical blocks starting at start to end, inclusive.
@@ -307,7 +335,10 @@ extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
 			return retval;
 		inode = &inode_buf;
 	}
-	if (inode->i_flags & EXT4_EXTENTS_FL)
+	if (inode->i_flags & EXT4_INLINE_DATA_FL) {
+		retval = ext2fs_punch_inline_data(fs, ino, inode, start, end);
+		return retval;
+	} else if (inode->i_flags & EXT4_EXTENTS_FL)
 		retval = ext2fs_punch_extent(fs, ino, inode, start, end);
 	else {
 		blk_t	count;
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ