*
*/
-#include <fcntl.h>
#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <termios.h>
+#include <time.h>
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
#define EXT2_SUPER_MAGIC 0xEF53
#ifdef HAVE_MNTENT_H
#include <mntent.h>
#endif
-#include <malloc.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <stdio.h>
#ifdef HAVE_LINUX_FS_H
#include <linux/fs.h>
+Mon Nov 3 14:45:06 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * resize2fs.c, ext2_block_move.c ext2_inode_move.c: Only include
+ printf statements if RESIZE2FS_DEBUG is defined.
+
+ * main.c: Don't read in the bitmaps since resize2fs.c does that.
+
Sun Oct 19 20:40:42 1997 Theodore Ts'o <tytso@rsts-11.mit.edu>
* resize2fs.h: Add #ifdef's for HAVE_SYS_TYPES_H and HAVE_SYS_TIME_H.
OBJS= extent.obj \
ext2_block_move.obj \
ext2_inode_move.obj \
- resize2fs.obj \
- sim_progress.obj
+ resize2fs.obj
ALL:: $(OBJS)
if (new) {
*block_nr = new;
ret |= BLOCK_CHANGED;
+#ifdef RESIZE2FS_DEBUG
if (pb->flags & RESIZE_DEBUG_BMOVE)
printf("ino=%ld, blockcnt=%d, %u->%u\n", pb->ino,
blockcnt, block, new);
+#endif
}
if (pb->is_dir) {
if (retval) goto errout;
if (!size)
break;
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_BMOVE)
printf("Moving %d blocks %u->%u\n", size,
old, new);
+#endif
do {
c = size;
if (c > fs->inode_blocks_per_group)
if (!new)
return 0;
+#ifdef RESIZE2FS_DEBUG
if (is->flags & RESIZE_DEBUG_INODEMAP)
printf("Inode translate (dir=%ld, name=%.*s, %u->%ld)\n",
dir, dirent->name_len, dirent->name,
dirent->inode, new);
+#endif
dirent->inode = new;
if (LINUX_S_ISDIR(inode.i_mode))
rfs->new_fs->group_desc[group].bg_used_dirs_count++;
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_INODEMAP)
printf("Inode moved %ld->%ld\n", ino, new);
+#endif
ext2fs_add_extent_entry(imap, ino, new);
}
printf ("Couldn't find valid filesystem superblock.\n");
exit (1);
}
- retval = ext2fs_read_bitmaps(fs);
- if (retval) {
- com_err (program_name, retval,
- "while trying to read the bitmaps", device_name);
- ext2fs_close (fs);
- exit (1);
- }
retval = resize_fs(fs, new_size, flags);
if (retval) {
com_err(program_name, retval, "while trying to resize %s",
new = fs->group_desc[i].bg_inode_table;
diff = new - old;
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE)
printf("Itable move group %d block "
"%u->%u (diff %d)\n",
i, old, new, diff);
+#endif
if (!diff)
continue;
if (*cp)
break;
n = n >> EXT2_BLOCK_SIZE_BITS(fs->super);
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE)
printf("%d blocks of zeros...\n", n);
+#endif
num = fs->inode_blocks_per_group;
if (n > diff)
num -= n;
}
ext2fs_flush(rfs->new_fs);
io_channel_flush(fs->io);
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE)
printf("Inode table move finished.\n");
+#endif
if (progress)
ext2fs_progress_close(progress);
return 0;
backout:
if (progress)
ext2fs_progress_close(progress);
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE)
printf("Error: %s; now backing out!\n", error_message(retval));
+#endif
while (--i >= 0) {
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_ITABLEMOVE)
printf("Group %d block %u->%u\n", i, new, old);
+#endif
old = rfs->old_fs->group_desc[i].bg_inode_table;
new = fs->group_desc[i].bg_inode_table;
if (retval)
goto errout;
+#ifdef RESIZE2FS_DEBUG
if (rfs->flags & RESIZE_DEBUG_BMOVE)
printf("Number of free blocks: %d/%d, Needed: %d\n",
rfs->old_fs->super->s_free_blocks_count,
rfs->new_fs->super->s_free_blocks_count,
rfs->needed_blocks);
+#endif
retval = ext2fs_block_move(rfs);
if (retval)