From 80c0fc3492278168448017e79730905aa5b9b62b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 3 Nov 1997 19:46:49 +0000 Subject: [PATCH] Many files: 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. e2label.c, mke2fs.c: Adjust header files. --- misc/e2label.c | 18 +++++++++++++++++- misc/mke2fs.c | 2 -- resize/ChangeLog | 7 +++++++ resize/Makefile.pq | 3 +-- resize/ext2_block_move.c | 4 ++++ resize/ext2_inode_move.c | 4 ++++ resize/main.c | 7 ------- resize/resize2fs.c | 12 ++++++++++++ 8 files changed, 45 insertions(+), 12 deletions(-) diff --git a/misc/e2label.c b/misc/e2label.c index 2b4f171..928a896 100644 --- a/misc/e2label.c +++ b/misc/e2label.c @@ -5,8 +5,24 @@ * */ -#include #include +#include +#include +#include +#include +#include +#ifdef HAVE_GETOPT_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif #define EXT2_SUPER_MAGIC 0xEF53 diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 81a0262..47dfc42 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -36,11 +36,9 @@ #ifdef HAVE_MNTENT_H #include #endif -#include #include #include #include -#include #ifdef HAVE_LINUX_FS_H #include diff --git a/resize/ChangeLog b/resize/ChangeLog index bb559ee..3a957f9 100644 --- a/resize/ChangeLog +++ b/resize/ChangeLog @@ -1,3 +1,10 @@ +Mon Nov 3 14:45:06 1997 Theodore Ts'o + + * 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 * resize2fs.h: Add #ifdef's for HAVE_SYS_TYPES_H and HAVE_SYS_TIME_H. diff --git a/resize/Makefile.pq b/resize/Makefile.pq index c383c87..5421c6d 100644 --- a/resize/Makefile.pq +++ b/resize/Makefile.pq @@ -5,8 +5,7 @@ OBJFILE=RESIZE.LST OBJS= extent.obj \ ext2_block_move.obj \ ext2_inode_move.obj \ - resize2fs.obj \ - sim_progress.obj + resize2fs.obj ALL:: $(OBJS) diff --git a/resize/ext2_block_move.c b/resize/ext2_block_move.c index ec60edf..3170e95 100644 --- a/resize/ext2_block_move.c +++ b/resize/ext2_block_move.c @@ -34,9 +34,11 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, 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) { @@ -125,9 +127,11 @@ errcode_t ext2fs_block_move(ext2_resize_t rfs) 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) diff --git a/resize/ext2_inode_move.c b/resize/ext2_inode_move.c index 5d26b15..3ec74b8 100644 --- a/resize/ext2_inode_move.c +++ b/resize/ext2_inode_move.c @@ -56,10 +56,12 @@ static int check_and_change_inodes(ino_t dir, int entry, 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; @@ -251,8 +253,10 @@ errcode_t ext2fs_inode_move(ext2_resize_t rfs) 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); } diff --git a/resize/main.c b/resize/main.c index b5e5a7f..7765052 100644 --- a/resize/main.c +++ b/resize/main.c @@ -104,13 +104,6 @@ void main (int argc, char ** argv) 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", diff --git a/resize/resize2fs.c b/resize/resize2fs.c index 66e0b20..1345708 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -574,10 +574,12 @@ static errcode_t move_itables(ext2_resize_t rfs) 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; @@ -596,8 +598,10 @@ static errcode_t move_itables(ext2_resize_t rfs) 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; @@ -622,8 +626,10 @@ static errcode_t move_itables(ext2_resize_t rfs) } 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; @@ -631,11 +637,15 @@ static errcode_t move_itables(ext2_resize_t rfs) 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; @@ -746,11 +756,13 @@ errcode_t resize_fs(ext2_filsys fs, blk_t new_size, int flags) 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) -- 1.8.3.1