2005-03-20 Theodore Ts'o <tytso@mit.edu>
+ * util.c (debugfs_write_new_inode): New function
+
+ * debgufs.c (do_write, do_mknod): Call ext2fs_write_new_inode()
+ instead of ext2fs_write_inode().
+
* debugfs.c (do_stat): Add support for dumping extended attributes
which are stored in the inode body.
inode.i_atime = inode.i_ctime = inode.i_mtime = time(NULL);
inode.i_links_count = 1;
inode.i_size = statbuf.st_size;
- if (debugfs_write_inode(newfile, &inode, argv[0])) {
+ if (debugfs_write_new_inode(newfile, &inode, argv[0])) {
close(fd);
return;
}
inode.i_block[1] = (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
}
inode.i_links_count = 1;
- if (debugfs_write_inode(newfile, &inode, argv[0]))
+ if (debugfs_write_new_inode(newfile, &inode, argv[0]))
return;
}
const char *cmd);
extern int debugfs_write_inode(ext2_ino_t ino, struct ext2_inode * inode,
const char *cmd);
+extern int debugfs_write_new_inode(ext2_ino_t ino, struct ext2_inode * inode,
+ const char *cmd);
/* ss command functions */
return 0;
}
+int debugfs_write_new_inode(ext2_ino_t ino, struct ext2_inode * inode,
+ const char *cmd)
+{
+ int retval;
+
+ retval = ext2fs_write_new_inode(current_fs, ino, inode);
+ if (retval) {
+ com_err(cmd, retval, "while creating inode %u", ino);
+ return 1;
+ }
+ return 0;
+}
2005-03-20 Theodore Ts'o <tytso@mit.edu>
+ * pass3.c (check_root, e2fsck_get_lost_and_found): Call
+ ext2fs_write_new_inode() instead of ext2fs_write_inode().
+
* pass1.c (check_blocks): Move counting the extended attribute
block earlier so that we don't have to worry about
num_blocks wrapping for files which are too big.
/*
* Write out the inode.
*/
- pctx.errcode = ext2fs_write_inode(fs, EXT2_ROOT_INO, &inode);
+ pctx.errcode = ext2fs_write_new_inode(fs, EXT2_ROOT_INO, &inode);
if (pctx.errcode) {
pctx.str = "ext2fs_write_inode";
fix_problem(ctx, PR_3_CREATE_ROOT_ERROR, &pctx);
/*
* Next, write out the inode.
*/
- pctx.errcode = ext2fs_write_inode(fs, ino, &inode);
+ pctx.errcode = ext2fs_write_new_inode(fs, ino, &inode);
if (pctx.errcode) {
pctx.str = "ext2fs_write_inode";
fix_problem(ctx, PR_3_CREATE_LPF_ERROR, &pctx);
+2005-03-20 Theodore Ts'o <tytso@mit.edu>
+
+ * mkdir.c (ext2fs_mkdir): Call ext2fs_write_new_inode() instead of
+ ext2fs_write_inode().
+
+ * 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.
+
2005-03-18 Theodore Ts'o <tytso@mit.edu>
* Makefile.in: Fix clean target to remove tst_getsectsize.
int bufsize);
extern errcode_t ext2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
struct ext2_inode * inode);
+extern errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
+ struct ext2_inode * inode);
extern errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks);
extern errcode_t ext2fs_check_directory(ext2_filsys fs, ext2_ino_t ino);
return ext2fs_write_inode_full(fs, ino, inode,
sizeof(struct ext2_inode));
}
+
+/*
+ * This function should be called when writing a new inode. It makes
+ * sure that extra part of large inodes is cleared.
+ */
+errcode_t ext2fs_write_new_inode(ext2_filsys fs, ext2_ino_t ino,
+ struct ext2_inode *inode)
+{
+ struct ext2_inode *buf;
+ errcode_t retval;
+ int size = EXT2_INODE_SIZE(fs->super);
+
+ if (size == sizeof(struct ext2_inode))
+ return ext2fs_write_inode_full(fs, ino, inode,
+ sizeof(struct ext2_inode));
+
+ buf = malloc(size);
+ if (!buf)
+ return ENOMEM;
+
+ memset(buf, 0, size);
+ *buf = *inode;
+
+ retval = ext2fs_write_inode_full(fs, ino, buf, size);
+}
+
errcode_t ext2fs_get_blocks(ext2_filsys fs, ext2_ino_t ino, blk_t *blocks)
{
retval = ext2fs_write_dir_block(fs, blk, block);
if (retval)
goto cleanup;
- retval = ext2fs_write_inode(fs, ino, &inode);
+ retval = ext2fs_write_new_inode(fs, ino, &inode);
if (retval)
goto cleanup;