summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext2fs/inode.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/ext2fs/inode.c b/ext2fs/inode.c
index 12e249e4..cc252cd7 100644
--- a/ext2fs/inode.c
+++ b/ext2fs/inode.c
@@ -451,7 +451,6 @@ write_node (struct node *np)
}
di->i_links_count = st->st_nlink;
- di->i_size = st->st_size;
di->i_atime = st->st_atime;
di->i_mtime = st->st_mtime;
@@ -462,8 +461,6 @@ write_node (struct node *np)
di->i_ctime.ts_nsec = st->st_ctime_usec * 1000;
#endif
- di->i_blocks = st->st_blocks;
-
/* Convert generic flags in ST->st_flags to ext2-specific flags in DI
(but don't mess with ext2 flags we don't know about). The original
set was copied from DI into INFO by read_node, but might have been
@@ -478,11 +475,20 @@ write_node (struct node *np)
info->i_flags |= EXT2_IMMUTABLE_FL;
di->i_flags = info->i_flags;
- if (!(st->st_mode & S_IPTRANS) && sblock->s_creator_os == EXT2_OS_HURD)
- di->i_translator = 0;
-
- /* Set dtime non-zero to indicate a deleted file. */
- di->i_dtime = (st->st_mode ? 0 : di->i_mtime);
+ if (st->st_mode == 0)
+ /* Set dtime non-zero to indicate a deleted file.
+ We don't clear i_size, i_blocks, and i_translator in this case,
+ to give "undeletion" utilities a chance. */
+ di->i_dtime = di->i_mtime;
+ else
+ {
+ di->i_dtime = 0;
+ di->i_size = st->st_size;
+ di->i_blocks = st->st_blocks;
+ if (!(st->st_mode & S_IPTRANS)
+ && sblock->s_creator_os == EXT2_OS_HURD)
+ di->i_translator = 0;
+ }
if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
di->i_block[0] = st->st_rdev;