ref: b0d0fa2f98efa4af0e5ac4af6cd2ccfd473c8b7f
parent: 3e54b8a78e230f6c8703390e7667cd0ad80f9462
author: ngkaho1234 <[email protected]>
date: Mon Oct 26 23:45:50 EDT 2015
FIX: extra_isize field is 0
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -799,6 +799,7 @@
{
/* Check if newly allocated i-node will be a directory */
bool is_dir;
+ uint16_t inode_size = ext4_get16(&fs->sb, inode_size);
is_dir = (filetype == EXT4_DIRENTRY_DIR);
@@ -850,6 +851,11 @@
ext4_inode_set_blocks_count(&fs->sb, inode, 0);
ext4_inode_set_flags(inode, 0);
ext4_inode_set_generation(inode, 0);
+ if (inode_size > EXT4_GOOD_OLD_INODE_SIZE)
+ ext4_inode_set_extra_isize(inode,
+ sizeof(struct ext4_inode) -
+ ext4_offsetof(struct ext4_inode,
+ extra_isize));
/* Reset blocks array. For symbolic link inode, just
* fill in blocks with 0 */
--- a/lwext4/ext4_inode.c
+++ b/lwext4/ext4_inode.c
@@ -271,6 +271,16 @@
inode->generation = to_le32(gen);
}
+uint16_t ext4_inode_get_extra_isize(struct ext4_inode *inode)
+{
+ return to_le16(inode->extra_isize);
+}
+
+void ext4_inode_set_extra_isize(struct ext4_inode *inode, uint16_t size)
+{
+ inode->extra_isize = to_le16(size);
+}
+
uint64_t ext4_inode_get_file_acl(struct ext4_inode *inode,
struct ext4_sblock *sb)
{
--- a/lwext4/ext4_inode.h
+++ b/lwext4/ext4_inode.h
@@ -199,6 +199,18 @@
*/
void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen);
+/**@brief Get extra I-node size field.
+ * @param inode I-node
+ * @return extra I-node size
+ */
+uint16_t ext4_inode_get_extra_isize(struct ext4_inode *inode);
+
+/**@brief Set extra I-node size field.
+ * @param inode I-node
+ * @param size extra I-node size
+ */
+void ext4_inode_set_extra_isize(struct ext4_inode *inode, uint16_t size);
+
/**@brief Get address of block, where are extended attributes located.
* @param inode I-node
* @param sb Superblock