]> git.tue.mpg.de Git - paraslash.git/commitdiff
fsck.c: Improve log messages.
authorAndre Noll <maan@systemlinux.org>
Sat, 22 Dec 2007 13:00:12 +0000 (14:00 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 22 Dec 2007 13:00:12 +0000 (14:00 +0100)
fsck.c

diff --git a/fsck.c b/fsck.c
index 6d5078c7ea0fa6cdcf5b137acbb31fd06bac6b54..04916384c30d4d18417afafd58472d1dfad5689f 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -885,14 +885,22 @@ static int check_table(char *base_dir, char *table_name)
        };
        int ret;
 
+       PARA_INFO_LOG("checking table %s\n", table_name);
        if (!conf.no_fsck_given) {
                ret = fsck(&desc);
                if (ret < 0)
-                       return ret;
+                       goto out;
        }
+       ret = 1;
        if (!conf.dump_dir_given || !*conf.dump_dir_arg)
-               return 1;
-       return dump_table(conf.dump_dir_arg, &desc);
+               goto out;
+       ret = dump_table(conf.dump_dir_arg, &desc);
+out:
+       if (ret < 0)
+               PARA_ERROR_LOG("failed to check table %s\n", table_name);
+       else
+               PARA_NOTICE_LOG("successfully checked table %s\n", table_name);
+       return ret;
 }
 
 static int check_all_tables(char *base_dir)
@@ -939,7 +947,7 @@ int main(int argc, char **argv)
        }
        HANDLE_VERSION_FLAG("fsck", conf);
        if (conf.base_dir_given)
-               base_dir = conf.base_dir_arg;
+               base_dir = para_strdup(conf.base_dir_arg);
        else {
                char *home = para_homedir();
                base_dir = make_message("%s/.paraslash/afs_database", home);
@@ -955,9 +963,18 @@ int main(int argc, char **argv)
                        break;
        }
 out:
-       if (!conf.base_dir_given)
+       if (ret < 0) {
+               PARA_ERROR_LOG("%s%s: %s\n",
+                       base_dir? "base_dir: " : "",
+                       base_dir? base_dir : "",
+                       PARA_STRERROR(-ret)
+               );
+               if (conf.loglevel_arg > 1)
+                       PARA_EMERG_LOG("re-run with \"--logelvel %d\" to increase verbosity\n",
+                               conf.loglevel_arg - 1);
+       } else
+               PARA_NOTICE_LOG("success\n");
+       if (base_dir)
                free(base_dir);
-       if (ret < 0)
-               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
        return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
 }