exit(EXIT_FAILURE);
}
-/**
- * Get the home directory of the current user.
- *
- * \return A dynammically allocated string that must be freed by the caller. If
- * the home directory could not be found, this function returns "/tmp".
- */
-__must_check __malloc static char *para_homedir(void)
-{
- struct passwd *pw = getpwuid(getuid());
- return para_strdup(pw? pw->pw_dir : "/tmp");
-}
-
/**
* Compare two osl objects pointing to unsigned integers of 32 bit size.
*
int main(int argc, char **argv)
{
int i, ret;
- char *db_dir = NULL;
struct fsck_cmdline_parser_params params = {
.override = 0,
.initialize = 1,
}
loglevel = conf.loglevel_arg;
HANDLE_VERSION_FLAG("fsck", conf);
- if (conf.database_dir_given)
- db_dir = para_strdup(conf.database_dir_arg);
- else {
- char *home = para_homedir();
- db_dir = make_message("%s/.paraslash/afs_database", home);
- free(home);
- }
- INFO_LOG("database dir: %s\n", db_dir);
+ INFO_LOG("database dir: %s\n", conf.database_dir_arg);
if (!conf.inputs_num) {
- ret = check_all_tables(db_dir);
+ ret = check_all_tables(conf.database_dir_arg);
goto out;
}
for (i = 0; i < conf.inputs_num; i++) {
- ret = check_table(db_dir, conf.inputs[i]);
+ ret = check_table(conf.database_dir_arg, conf.inputs[i]);
if (ret < 0)
break;
}
conf.loglevel_arg - 1);
} else
NOTICE_LOG("success\n");
- if (db_dir)
- free(db_dir);
return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
}