- printf("----------------- Largest dirs -------------------\n");
- ret = osl_rbtree_loop_reverse(dir_table, DT_BYTES, &gsi,
- global_stats_loop_function);
- if (ret < 0 && ret != -E_LOOP_COMPLETE)
- return ret;
- gsi.count = 10;
-
- gsi.flags = GSF_PRINT_DIRNAME | GSF_PRINT_FILES;
- printf("---------- dirs containing most files ------------\n");
- ret = osl_rbtree_loop_reverse(dir_table, DT_FILES, &gsi,
- global_stats_loop_function);
- if (ret < 0 && ret != -E_LOOP_COMPLETE)
- return ret;
-
- printf("------------------ Global summary (dirs/files/bytes)\n"
- "%llu\t%llu\t%llu\n",
- (long long unsigned)num_dirs, (long long unsigned)num_files,
- (long long unsigned)num_bytes);
- print_user_stats();
- print_id_stats();
- return 1;
-}
-
-static int write_uid_list(void)
-{
- char *buf;
- uint32_t count = 0;
- struct user_info *ui;
- size_t size = num_uids * sizeof(uint32_t);
- int ret;
-
- if (!num_uids)
- return 0;
- buf = para_malloc(size);
- FOR_EACH_USER(ui) {
- if (!ui->table)
- continue;
- write_u32(buf + count++ * sizeof(uint32_t), ui->uid);
- }
- ret = para_write_file(UID_LIST, buf, size);
- free(buf);
- return ret;
-}
-
-static int open_dir_table(void)
-{
- return osl_open_table(&dir_table_desc, &dir_table);
-}
-
-static void close_dir_table(void)
-{
- int ret;
-
- if (!dir_table)
- return;
- ret = osl_close_table(dir_table, OSL_MARK_CLEAN);
- if (ret < 0)
- ERROR_LOG("failed to close dir table: %s\n", error_txt(-ret));
- dir_table = NULL;
-}
-
-static void close_user_table(struct user_info *ui)
-{
- int ret;
-
- if (!ui || !ui->table)
- return;
- ret = osl_close_table(ui->table, OSL_MARK_CLEAN);
- if (ret < 0)
- ERROR_LOG("failed to close user table %u: %s\n",
- (unsigned) ui->uid, error_txt(-ret));
- free((char *)ui->desc->name);
- ui->desc->name = NULL;
- free((char *)ui->desc->dir);
- ui->desc->dir = NULL;
- free(ui->desc);
- ui->desc = NULL;
- ui->table = NULL;
-}
-
-static void close_user_tables(void)
-{
- struct user_info *ui;
-
- FOR_EACH_USER(ui)
- close_user_table(ui);
-}
-
-static void close_all_tables(void)
-{
- close_dir_table();
- close_user_tables();
- free_hash_table();
-}
-
-static int com_create(char *dirname)
-{
- int ret = create_tables();
- if (ret < 0)
- return ret;
- ret = open_dir_table();
- if (ret < 0)
- return ret;
- ret = scan_dir(dirname);