Add \brief command to file header to make doxygen happy.
[adu.git] / create.c
index 9b26f72..3a221ca 100644 (file)
--- a/create.c
+++ b/create.c
@@ -4,49 +4,21 @@
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
-/** \file create.c The create mode of adu. */
+/** \file create.c \brief The create mode of adu. */
 
 #include <dirent.h> /* readdir() */
+#include "format.h"
 #include "adu.h"
 #include "gcc-compat.h"
 #include "cmdline.h"
 #include "fd.h"
 #include "string.h"
 #include "error.h"
-#include "portable_io.h"
+#include "user.h"
 
 /* Id of the device containing the base dir. */
 static dev_t device_id;
 
-static int write_uid(struct user_info *ui, void *data)
-{
-       char **p = data;
-
-       write_u32(*p, ui->uid);
-       *p += sizeof(uint32_t);
-       return 1;
-}
-
-static int write_uid_list(void)
-{
-       char *buf, *p, *filename;
-       size_t size = num_uids * sizeof(uint32_t);
-       int ret;
-
-       if (!num_uids)
-               return 0;
-       buf = p = adu_malloc(size);
-       ret = for_each_admissible_user(write_uid, &p);
-       if (ret < 0)
-               goto out;
-       filename = get_uid_list_name();
-       ret = adu_write_file(filename, buf, size);
-       free(filename);
-out:
-       free(buf);
-       return ret;
-}
-
 static int add_directory(char *dirname, uint64_t *dir_num, uint64_t *parent_dir_num,
                uint64_t *dir_size, uint64_t *dir_files)
 {
@@ -86,9 +58,7 @@ static int update_user_row(struct osl_table *t, uint64_t dir_num,
                objects[UT_BYTES].size = sizeof(*add);
                objects[UT_FILES].data = &num_files;
                objects[UT_FILES].size = sizeof(num_files);
-               INFO_LOG("######################### ret: %d\n", ret);
                ret = osl(osl_add_row(t, objects));
-               INFO_LOG("######################### ret: %d\n", ret);
                return ret;
        } else { /* add size and increment file count */
                uint64_t num;
@@ -161,7 +131,7 @@ static int scan_dir(char *dirname, uint64_t *parent_dir_num)
                dir_size += size;
                dir_files++;
                uid = s.st_uid;
-               ret = search_uid(uid, NULL, CREATE_USER_TABLE | OPEN_USER_TABLE, &ui);
+               ret = create_user_table(uid, &ui);
                if (ret < 0)
                        goto out;
                ui->bytes += size;
@@ -200,8 +170,7 @@ int com_create(void)
        ret = scan_dir(conf.base_dir_arg, &zero);
        if (ret < 0)
                goto out;
-       ret = write_uid_list();
+       ret = write_uid_file();
 out:
-       close_all_tables();
        return ret;
 }