+static int check_table(char *base_dir, char *table_name)
+{
+ struct osl_table_description desc = {
+ .column_descriptions = NULL,
+ .dir = base_dir,
+ .name = table_name
+ };
+ int ret;
+
+ PARA_INFO_LOG("checking table %s\n", table_name);
+ if (!conf.no_fsck_given) {
+ ret = fsck(&desc);
+ if (ret < 0)
+ goto out;
+ }
+ ret = 1;
+ if (!conf.dump_dir_given || !*conf.dump_dir_arg)
+ 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)
+{
+ DIR *dir;
+ struct dirent *entry;
+ int cwd_fd, ret2, ret = para_opendir(base_dir, &dir, &cwd_fd);
+
+ if (ret < 0)
+ return ret;
+ while ((entry = readdir(dir))) {
+ mode_t m;
+ struct stat s;
+ if (!strcmp(entry->d_name, "."))
+ continue;
+ if (!strcmp(entry->d_name, ".."))
+ continue;
+ if (lstat(entry->d_name, &s) == -1)
+ continue;
+ m = s.st_mode;
+ if (!S_ISDIR(m))
+ continue;
+ ret = check_table(base_dir, entry->d_name);
+ if (ret < 0)
+ break;
+ }
+ closedir(dir);
+ ret2 = para_fchdir(cwd_fd);
+ if (ret2 < 0 && ret >= 0)
+ ret = ret2;
+ close(cwd_fd);
+ return ret;
+}
+
+int main(int argc, char **argv)