Whamcloud - gitweb
Fix mke2fs so that it writes the root directory
authorTheodore Ts'o <tytso@mit.edu>
Mon, 21 Mar 2005 06:02:53 +0000 (01:02 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 21 Mar 2005 06:02:53 +0000 (01:02 -0500)
using ext2fs_write_new_inode(), and fix ext2fs_write_new_inode()
so that it initializes i_extra_isize properly.

lib/ext2fs/ChangeLog
lib/ext2fs/inode.c
misc/ChangeLog
misc/mke2fs.c

index 414ecec..5bbc742 100644 (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>
 
index 0e0a52c..99bd5d5 100644 (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);
 }
 
index 1f389b6..2c2bc1e 100644 (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
index 7211dc5..18e7e76 100644 (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"));