Browse Source

FIX: extra_isize field is 0

pull/11/head
ngkaho1234 9 years ago
parent
commit
b0d0fa2f98
  1. 6
      lwext4/ext4_fs.c
  2. 10
      lwext4/ext4_inode.c
  3. 12
      lwext4/ext4_inode.h

6
lwext4/ext4_fs.c

@ -799,6 +799,7 @@ int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref,
{
/* 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 @@ int ext4_fs_alloc_inode(struct ext4_fs *fs, struct ext4_inode_ref *inode_ref,
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 */

10
lwext4/ext4_inode.c

@ -271,6 +271,16 @@ void ext4_inode_set_generation(struct ext4_inode *inode, uint32_t gen)
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)
{

12
lwext4/ext4_inode.h

@ -199,6 +199,18 @@ uint32_t ext4_inode_get_generation(struct ext4_inode *inode);
*/
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

Loading…
Cancel
Save