return osl_add_row(dir_table, dir_objects);
}
+static uint32_t num_uids;
+
int create_and_open_user_table(uint32_t uid, struct osl_table **t)
{
int ret;
desc->column_descriptions = user_table_cols;
desc->dir = para_strdup(DATABASE_DIR);
desc->name = make_message("%u", uid);
- INFO_LOG("................................. %u\n", uid);
+ num_uids++;
+ INFO_LOG(".............................uid #%u: %u\n",
+ (unsigned)num_uids, (unsigned)uid);
// user_table_desc.name = make_message("%u", uid);
ret = osl_create_table(desc);
if (ret < 0)
return 1;
}
+static int write_uid_list(void)
+{
+ char *buf, *filename = DATABASE_DIR "/" "uid_list";
+ 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(filename, buf, size);
+ free(buf);
+ return ret;
+}
+
+static int com_create(char *dirname)
+{
+ int ret = scan_dir(dirname);
+
+ if (ret < 0)
+ return ret;
+ return write_uid_list();
+}
int main(int argc, char **argv)
{
ret = -E_SYNTAX;
if (argc != 2)
goto out;
- ret = scan_dir(argv[1]);
+ ret = com_create(argv[1]);
if (ret < 0)
goto out;
print_statistics();