Use the newer add/remove_error_table com_err interfaces

Change all of the e2fsprogs programs to use the newer add_error_table()
and remove_error_table() interfaces instead of the much older
initialize_*_error_table() function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog
index 4a814b8..a67cd98 100644
--- a/debugfs/ChangeLog
+++ b/debugfs/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-22  Theodore Tso  <tytso@mit.edu>
+
+	* debugfs.c (main): Use the new {add,remove}_error_table comerr
+		interfaces instead of initialize_*_error_table.
+
 2006-11-12  Theodore Tso  <tytso@mit.edu>
 
 	* debugfs.c (do_open_filesys, main): Open filesystems with the
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 2e30d67..cc99e81 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -1801,7 +1801,7 @@
 	int		catastrophic = 0;
 	char		*data_filename = 0;
 	
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
 	fprintf (stderr, "debugfs %s (%s)\n", E2FSPROGS_VERSION,
 		 E2FSPROGS_DATE);
 
@@ -1877,5 +1877,6 @@
 	if (current_fs)
 		close_filesystem();
 	
+	remove_error_table(&et_ext2_error_table);
 	return exit_status;
 }
diff --git a/e2fsck/ChangeLog b/e2fsck/ChangeLog
index 0ab7830..5abc2e6 100644
--- a/e2fsck/ChangeLog
+++ b/e2fsck/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-22  Theodore Tso  <tytso@mit.edu>
+
+	* unix.c (PRS, main): Use the new {add,remove}_error_table comerr
+		interfaces instead of initialize_*_error_table.
+
 2006-11-14  Theodore Tso  <tytso@mit.edu>
 
 	* unix.c (PRS): Always allocate the replacement PATH environment
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 4f4c506..898bc33 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -600,8 +600,8 @@
 	}
 	memset(bar, '=', sizeof(bar)-1);
 	memset(spaces, ' ', sizeof(spaces)-1);
-	initialize_ext2_error_table();
-	initialize_prof_error_table();
+	add_error_table(&et_ext2_error_table);
+	add_error_table(&et_prof_error_table);
 	blkid_get_cache(&ctx->blkid, NULL);
 	
 	if (argc && *argv)
@@ -1224,5 +1224,7 @@
 		print_resource_track(NULL, &ctx->global_rtrack);
 #endif
 	e2fsck_free_context(ctx);
+	remove_error_table(&et_ext2_error_table);
+	remove_error_table(&et_prof_error_table);
 	return exit_value;
 }
diff --git a/misc/ChangeLog b/misc/ChangeLog
index ead69fe..bdeaf23 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,11 @@
+2006-12-22  Theodore Tso  <tytso@mit.edu>
+
+	* tune2fs.c, mke2fs.c, e2initrd_helper.c, e2image.c, dumpe2fs.c:
+		Use the new {add,remove}_error_table comerr interfaces
+		instead of initialize_*_error_table.
+
+	* Makefile.in: Link in prof_err.o into mke2fs.
+
 2006-11-17  Theodore Tso  <tytso@mit.edu>
 
 	* badblocks.c (exclusive_usage): Print the program name in the
diff --git a/misc/Makefile.in b/misc/Makefile.in
index f1f67d9..8dcae2e 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -29,7 +29,7 @@
 
 TUNE2FS_OBJS=	tune2fs.o util.o
 MKLPF_OBJS=	mklost+found.o
-MKE2FS_OBJS=	mke2fs.o util.o profile.o
+MKE2FS_OBJS=	mke2fs.o util.o profile.o prof_err.o
 CHATTR_OBJS=	chattr.o
 LSATTR_OBJS=	lsattr.o
 UUIDGEN_OBJS=	uuidgen.o
@@ -364,14 +364,15 @@
 #
 tune2fs.o: $(srcdir)/tune2fs.c $(top_srcdir)/lib/ext2fs/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/uuid/uuid.h \
- $(top_srcdir)/lib/e2p/e2p.h $(srcdir)/jfs_user.h \
- $(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
- $(top_srcdir)/lib/ext2fs/kernel-list.h $(srcdir)/util.h \
- $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
- $(top_srcdir)/version.h $(srcdir)/nls-enable.h
+ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
+ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
+ $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
+ $(top_srcdir)/lib/uuid/uuid.h $(top_srcdir)/lib/e2p/e2p.h \
+ $(srcdir)/jfs_user.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
+ $(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h \
+ $(srcdir)/util.h $(top_srcdir)/lib/blkid/blkid.h \
+ $(top_builddir)/lib/blkid/blkid_types.h $(top_srcdir)/version.h \
+ $(srcdir)/nls-enable.h
 mklost+found.o: $(srcdir)/mklost+found.c $(top_srcdir)/lib/ext2fs/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/version.h \
  $(srcdir)/nls-enable.h
@@ -379,9 +380,10 @@
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/et/com_err.h \
  $(top_srcdir)/lib/uuid/uuid.h $(top_srcdir)/lib/e2p/e2p.h \
  $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/util.h $(srcdir)/../e2fsck/profile.h $(top_srcdir)/version.h \
+ $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
+ $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/util.h \
+ $(srcdir)/../e2fsck/profile.h prof_err.h $(top_srcdir)/version.h \
  $(srcdir)/nls-enable.h
 chattr.o: $(srcdir)/chattr.c $(top_srcdir)/lib/ext2fs/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/et/com_err.h \
@@ -393,28 +395,31 @@
  $(top_srcdir)/version.h $(srcdir)/nls-enable.h
 dumpe2fs.o: $(srcdir)/dumpe2fs.c $(top_srcdir)/lib/ext2fs/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/bitops.h $(top_srcdir)/lib/e2p/e2p.h \
- $(srcdir)/jfs_user.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \
- $(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h \
- $(top_srcdir)/lib/uuid/uuid.h $(top_srcdir)/version.h $(srcdir)/nls-enable.h
+ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
+ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
+ $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
+ $(top_srcdir)/lib/e2p/e2p.h $(srcdir)/jfs_user.h \
+ $(top_srcdir)/lib/ext2fs/kernel-jbd.h $(top_srcdir)/lib/ext2fs/jfs_compat.h \
+ $(top_srcdir)/lib/ext2fs/kernel-list.h $(top_srcdir)/lib/uuid/uuid.h \
+ $(top_srcdir)/version.h $(srcdir)/nls-enable.h
 badblocks.o: $(srcdir)/badblocks.c $(top_srcdir)/lib/et/com_err.h \
  $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/et/com_err.h \
- $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
- $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/nls-enable.h
+ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_srcdir)/lib/ext2fs/ext3_extents.h \
+ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
+ $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
+ $(srcdir)/nls-enable.h
 fsck.o: $(srcdir)/fsck.c $(top_srcdir)/version.h $(srcdir)/nls-enable.h \
  $(srcdir)/fsck.h $(top_srcdir)/lib/blkid/blkid.h \
  $(top_builddir)/lib/blkid/blkid_types.h
 util.o: $(srcdir)/util.c $(top_srcdir)/lib/et/com_err.h \
  $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
  $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \
- $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
- $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
- $(srcdir)/nls-enable.h $(top_srcdir)/lib/blkid/blkid.h \
- $(top_builddir)/lib/blkid/blkid_types.h $(srcdir)/util.h
+ $(top_srcdir)/lib/ext2fs/ext3_extents.h $(top_srcdir)/lib/et/com_err.h \
+ $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \
+ $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/nls-enable.h \
+ $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \
+ $(srcdir)/util.h
 uuidgen.o: $(srcdir)/uuidgen.c $(top_srcdir)/lib/uuid/uuid.h \
  $(srcdir)/nls-enable.h
 blkid.o: $(srcdir)/blkid.c $(top_srcdir)/lib/blkid/blkid.h \
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index fe3b50b..fcae0f0 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -343,7 +343,7 @@
 	bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
 	textdomain(NLS_CAT_NAME);
 #endif
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
 	fprintf (stderr, "dumpe2fs %s (%s)\n", E2FSPROGS_VERSION,
 		 E2FSPROGS_DATE);
 	if (argc && *argv)
@@ -435,5 +435,6 @@
 		}
 	}
 	ext2fs_close (fs);
+	remove_error_table(&et_ext2_error_table);
 	exit (0);
 }
diff --git a/misc/e2image.c b/misc/e2image.c
index 5bbc49b..a6c42fb 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -628,7 +628,7 @@
 		 E2FSPROGS_DATE);
 	if (argc && *argv)
 		program_name = *argv;
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
 	while ((c = getopt (argc, argv, "rsI")) != EOF)
 		switch (c) {
 		case 'r':
@@ -683,5 +683,6 @@
 		write_image_file(fs, fd);
 
 	ext2fs_close (fs);
+	remove_error_table(&et_ext2_error_table);
 	exit (0);
 }
diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c
index 2600190..8b8a00c 100644
--- a/misc/e2initrd_helper.c
+++ b/misc/e2initrd_helper.c
@@ -364,7 +364,7 @@
 	ext2_filsys fs;
 	io_manager io_ptr;
 
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
 
 	blkid_get_cache(&cache, NULL);
 	PRS(argc, argv);
@@ -382,5 +382,6 @@
 	if (root_type) 
 		get_root_type(fs);
 
+	remove_error_table(&et_ext2_error_table);
 	return (ext2fs_close (fs) ? 1 : 0);
 }
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 80a40ac..2e72dca 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -52,6 +52,7 @@
 #include "ext2fs/ext2fs.h"
 #include "util.h"
 #include "profile.h"
+#include "prof_err.h"
 #include "../version.h"
 #include "nls-enable.h"
 
@@ -952,7 +953,8 @@
 	
 	setbuf(stdout, NULL);
 	setbuf(stderr, NULL);
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
+	add_error_table(&et_prof_error_table);
 	memset(&fs_param, 0, sizeof(struct ext2_super_block));
 	fs_param.s_rev_level = 1;  /* Create revision 1 filesystems now */
 
@@ -1729,5 +1731,7 @@
 			print_check_message(fs);
 	}
 	val = ext2fs_close(fs);
+	remove_error_table(&et_ext2_error_table);
+	remove_error_table(&et_prof_error_table);
 	return (retval || val) ? 1 : 0;
 }
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index d5b9eb3..967b589 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -755,7 +755,7 @@
 #endif
 	if (argc && *argv)
 		program_name = *argv;
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
 
 	if (strcmp(get_progname(argv[0]), "findfs") == 0)
 		do_findfs(argc, argv);
@@ -784,6 +784,7 @@
 		/* For e2label emulation */
 		printf("%.*s\n", (int) sizeof(sb->s_volume_name),
 		       sb->s_volume_name);
+		remove_error_table(&et_ext2_error_table);
 		exit(0);
 	}
 	retval = ext2fs_check_if_mounted(device_name, &mount_flags);
@@ -920,5 +921,6 @@
 
 	if (l_flag)
 		list_super (sb);
+	remove_error_table(&et_ext2_error_table);
 	return (ext2fs_close (fs) ? 1 : 0);
 }
diff --git a/resize/ChangeLog b/resize/ChangeLog
index ee61c72..e12c00d 100644
--- a/resize/ChangeLog
+++ b/resize/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-22  Theodore Tso  <tytso@mit.edu>
+
+	* main.c (main): Use the new {add,remove}_error_table comerr
+		interfaces instead of initialize_*_error_table.
+
 2006-10-01  Theodore Tso  <tytso@mit.edu>
 
 	* online.c (online_resize_fs): Check to make sure the filesystem
diff --git a/resize/main.c b/resize/main.c
index 537c9a6..e71bbde 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -171,7 +171,7 @@
 	textdomain(NLS_CAT_NAME);
 #endif
 
-	initialize_ext2_error_table();
+	add_error_table(&et_ext2_error_table);
 
 	fprintf (stderr, "resize2fs %s (%s)\n",
 		 E2FSPROGS_VERSION, E2FSPROGS_DATE);
@@ -415,5 +415,6 @@
 	}
 	if (fd > 0)
 		close(fd);
+	remove_error_table(&et_ext2_error_table);
 	return (0);
 }