Whamcloud - gitweb
resize2fs.c (inode_scan_and_fix, check_and_change_inodes): When
authorTheodore Ts'o <tytso@mit.edu>
Fri, 1 Nov 2002 00:56:56 +0000 (19:56 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 1 Nov 2002 00:56:56 +0000 (19:56 -0500)
moving an inode, set the ctime field so that people using
dump/restore will backup the changed inode.  Also update
the mtime and ctime of directories which get updated when
we need to move an inode.

resize/ChangeLog
resize/resize2fs.c

index dc65274..1d79392 100644 (file)
@@ -1,3 +1,11 @@
+2002-10-31  Theodore Ts'o  <tytso@mit.edu>
+
+       * resize2fs.c (inode_scan_and_fix, check_and_change_inodes): When
+               moving an inode, set the ctime field so that people using
+               dump/restore will backup the changed inode.  Also update
+               the mtime and ctime of directories which get updated when
+               we need to move an inode.
+
 2002-10-30  Theodore Ts'o  <tytso@mit.edu>
 
        * Makefile.in (install): Search all compression extensions when
index cc2fda4..7494f8f 100644 (file)
@@ -1126,6 +1126,7 @@ static errcode_t inode_scan_and_fix(ext2_resize_t rfs)
                        retval = ext2fs_read_inode(rfs->old_fs, ino, &inode);
                        if (retval) goto errout;
                }
+               inode.i_ctime = time(0);
                retval = ext2fs_write_inode(rfs->old_fs, new_inode, &inode);
                if (retval) goto errout;
 
@@ -1178,7 +1179,9 @@ static int check_and_change_inodes(ext2_ino_t dir, int entry,
                                   int  blocksize, char *buf, void *priv_data)
 {
        struct istruct *is = (struct istruct *) priv_data;
-       ext2_ino_t      new_inode;
+       struct ext2_inode       inode;
+       ext2_ino_t              new_inode;
+       errcode_t               retval;
 
        if (is->rfs->progress && offset == 0) {
                io_channel_flush(is->rfs->old_fs->io);
@@ -1205,6 +1208,13 @@ static int check_and_change_inodes(ext2_ino_t dir, int entry,
 
        dirent->inode = new_inode;
 
+       /* Update the directory mtime and ctime */
+       retval = ext2fs_read_inode(is->rfs->old_fs, dir, &inode);
+       if (retval == 0) {
+               inode.i_mtime = inode.i_ctime = time(0);
+               ext2fs_write_inode(is->rfs->old_fs, dir, &inode);
+       }
+
        return DIRENT_CHANGED;
 }