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.
*
return ret;
}
-static int check_table(char *base_dir, char *table_name)
+static int check_table(char *db_dir, char *table_name)
{
struct osl_table_description desc = {
.column_descriptions = NULL,
- .dir = base_dir,
+ .dir = db_dir,
.name = table_name
};
int ret;
return ret;
}
-static int check_all_tables(char *base_dir)
+static int check_all_tables(char *db_dir)
{
DIR *dir;
struct dirent *entry;
- int cwd_fd, ret2, ret = para_opendir(base_dir, &dir, &cwd_fd);
+ int cwd_fd, ret2, ret = para_opendir(db_dir, &dir, &cwd_fd);
if (ret < 0)
return ret;
m = s.st_mode;
if (!S_ISDIR(m))
continue;
- ret = check_table(base_dir, entry->d_name);
+ ret = check_table(db_dir, entry->d_name);
if (ret < 0)
break;
}
int main(int argc, char **argv)
{
int i, ret;
- char *base_dir = NULL;
struct fsck_cmdline_parser_params params = {
.override = 0,
.initialize = 1,
}
loglevel = conf.loglevel_arg;
HANDLE_VERSION_FLAG("fsck", conf);
- if (conf.base_dir_given)
- base_dir = para_strdup(conf.base_dir_arg);
- else {
- char *home = para_homedir();
- base_dir = make_message("%s/.paraslash/afs_database", home);
- free(home);
- }
- INFO_LOG("base_dir: %s\n", base_dir);
+ INFO_LOG("database dir: %s\n", conf.database_dir_arg);
if (!conf.inputs_num) {
- ret = check_all_tables(base_dir);
+ ret = check_all_tables(conf.database_dir_arg);
goto out;
}
for (i = 0; i < conf.inputs_num; i++) {
- ret = check_table(base_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 (base_dir)
- free(base_dir);
return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
}