util.c, ls.c, logdump.c, htree.c, dump.c, debugfs.h, debugfs.c, ChangeLog:
util.c (reset_getopt), debugfs.c (do_open_filesys,
do_show_super_stats), ls.c (do_list_dir), dump.c (do_dump),
htree.c (do_htree_dump, do_dx_hash), logdump.c (do_logdump):
Define and use a new function, reset_getopt(), which does whatever
is necessary to reset getopt() again. This is different for
different implementations, so the portabilty issues are a bit of a
nightmare. (Addresses Debian bug #192834)
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 651bd7b..33e2051 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -20,9 +20,6 @@
extern int optind;
extern char *optarg;
#endif
-#ifdef HAVE_OPTRESET
-extern int optreset; /* defined by BSD, but not others */
-#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -101,10 +98,7 @@
blk_t blocksize = 0;
int open_flags = 0;
- optind = 1;
-#ifdef HAVE_OPTRESET
- optreset = 1; /* Makes BSD getopt happy */
-#endif
+ reset_getopt();
while ((c = getopt (argc, argv, "iwfcb:s:")) != EOF) {
switch (c) {
case 'i':
@@ -242,10 +236,7 @@
int numdirs = 0;
const char *usage = "Usage: show_super [-h]";
- optind = 1;
-#ifdef HAVE_OPTRESET
- optreset = 1; /* Makes BSD getopt happy */
-#endif
+ reset_getopt();
while ((c = getopt (argc, argv, "h")) != EOF) {
switch (c) {
case 'h':
@@ -1486,7 +1477,7 @@
return;
ino = string_to_inode(argv[1]);
if (!ino)
- return 0;
+ return;
group = (ino - 1) / EXT2_INODES_PER_GROUP(current_fs->super);
offset = ((ino - 1) % EXT2_INODES_PER_GROUP(current_fs->super)) *