Fix mke2fs so that it writes the root directory

using ext2fs_write_new_inode(), and fix ext2fs_write_new_inode() 
so that it initializes i_extra_isize properly.
This commit is contained in:
Theodore Ts'o 2005-03-21 01:02:53 -05:00
parent 89db86d33c
commit e27b45639a
4 changed files with 13 additions and 3 deletions

View File

@ -6,7 +6,7 @@
* inode.c (ext2fs_write_new_inode): New function which should be
used when the caller is writing an inode for the first
time. It makes sure that the extra portion of the large
inode is cleared.
inode is initialized properly.
2005-03-18 Theodore Ts'o <tytso@mit.edu>

View File

@ -718,7 +718,7 @@ errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
/*
* This function should be called when writing a new inode. It makes
* sure that extra part of large inodes is cleared.
* sure that extra part of large inodes is initialized properly.
*/
errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *inode)
@ -726,6 +726,7 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode *buf;
errcode_t retval;
int size = EXT2_INODE_SIZE(fs->super);
struct ext2_inode_large *large_inode;
if (size == sizeof(struct ext2_inode))
return ext2fs_write_inode_full(fs, ino, inode,
@ -738,6 +739,10 @@ errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
memset(buf, 0, size);
*buf = *inode;
large_inode = (struct ext2_inode_large *) buf;
large_inode->i_extra_isize = sizeof(struct ext2_inode_large) -
EXT2_GOOD_OLD_INODE_SIZE;
retval = ext2fs_write_inode_full(fs, ino, buf, size);
}

View File

@ -1,3 +1,8 @@
2005-03-21 Theodore Ts'o <tytso@mit.edu>
* mke2fs.c (create_root_dir): Call ext2fs_write_new_inode() instead of
ext2fs_write_inode().
2005-03-19 Theodore Ts'o <tytso@mit.edu>
* mke2fs.c (show_stats): Use the new e2p_os2string() function

View File

@ -524,7 +524,7 @@ static void create_root_dir(ext2_filsys fs)
inode.i_uid = getuid();
if (inode.i_uid)
inode.i_gid = getgid();
retval = ext2fs_write_inode(fs, EXT2_ROOT_INO, &inode);
retval = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
if (retval) {
com_err("ext2fs_write_inode", retval,
_("while setting root inode ownership"));