Merge branch 'master' into bloom
authorAndre Noll <maan@systemlinux.org>
Thu, 25 Dec 2008 11:23:10 +0000 (12:23 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 25 Dec 2008 11:23:10 +0000 (12:23 +0100)
Conflicts:
create.c

1  2 
create.c

diff --cc create.c
+++ b/create.c
@@@ -167,38 -121,20 +167,38 @@@ static int scan_dir(char *dirname, uint
                if (S_ISDIR(m)) {
                        if (conf.one_file_system_given && s.st_dev != device_id)
                                continue;
-                       ret = create_user_table(s.st_uid, &ui);
 +                      dir_size += s.st_size;
 +                      dir_files++;
++                      ret = create_user_table(conf.database_dir_arg, s.st_uid, &ui);
 +                      if (ret < 0)
 +                              goto out;
 +                      ret = update_user_row(ui->table, this_dir_num,
 +                              s.st_size);
 +                      if (ret < 0)
 +                              goto out;
                        ret = scan_dir(entry->d_name, &this_dir_num);
                        if (ret < 0)
                                goto out;
                        continue;
                }
 +
                /* regular file */
 -              size = s.st_size;
 -              dir_size += size;
 +              make_bloom_buf(&s, bloom_buf);
 +              if (insert_global_bloom(&s, bloom_buf))
 +                      DEBUG_LOG("global hard link: %s/%s\n", dirname,
 +                              entry->d_name);
 +              else
 +                      dir_size += s.st_size;
                dir_files++;
-               ret = create_user_table(s.st_uid, &ui);
 -              uid = s.st_uid;
 -              ret = create_user_table(conf.database_dir_arg, uid, &ui);
++              ret = create_user_table(conf.database_dir_arg, s.st_uid, &ui);
                if (ret < 0)
                        goto out;
 -              ret = update_user_row(ui->table, this_dir_num, &size);
 +              ret = insert_user_bloom(&s, bloom_buf);
 +              if (ret)
 +                      DEBUG_LOG("hard link for uid %d: %s/%s\n",
 +                              (unsigned)s.st_uid, dirname, entry->d_name);
 +              ret = update_user_row(ui->table, this_dir_num,
 +                      ret? 0 : s.st_size);
                if (ret < 0)
                        goto out;
        }
@@@ -269,10 -173,7 +269,10 @@@ int com_create(void
        ret = scan_dir(conf.base_dir_arg, &zero);
        if (ret < 0)
                goto out;
-       ret = write_uid_file();
+       ret = write_uid_file(conf.database_dir_arg);
 +      log_bloom_stats();
  out:
 +      bloom_free(global_bloom_filter);
 +      bloom_free(user_bloom_filter);
        return ret;
  }