]> git.tuebingen.mpg.de Git - adu.git/commitdiff
Implement --hash-table-bits.
authorAndre Noll <maan@systemlinux.org>
Sun, 1 Jun 2008 17:08:51 +0000 (19:08 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 1 Jun 2008 17:08:51 +0000 (19:08 +0200)
adu.c
adu.ggo
adu.h

diff --git a/adu.c b/adu.c
index 3fca7a089a8d06d55f94602b3333a7ea442034cb..c21df0b3aa5daa3136b5638a74127d803b373f69 100644 (file)
--- a/adu.c
+++ b/adu.c
@@ -285,15 +285,15 @@ err:
        return ret;
 }
 
        return ret;
 }
 
-#define uid_hash_bits 8
-uint32_t uid_hash_table_size = 1 << uid_hash_bits;
 #define PRIME1 0x811c9dc5
 #define PRIME2 0x01000193
 
 #define PRIME1 0x811c9dc5
 #define PRIME2 0x01000193
 
-void create_hash_table(void)
+uint32_t uid_hash_table_size;
+void create_hash_table(unsigned bits)
 {
 {
-       uid_hash_table = adu_calloc(uid_hash_table_size
-               * sizeof(struct user_info));
+       uid_hash_table_size = 1 << bits;
+       uid_hash_table = adu_calloc(uid_hash_table_size *
+               sizeof(struct user_info));
 }
 
 static void free_hash_table(void)
 }
 
 static void free_hash_table(void)
diff --git a/adu.ggo b/adu.ggo
index 9f8b7105314f3f1e8cc508b1f9b30e67b92f85f8..f2d14c98dc75e76fbd970f4afb744f70ae703b20 100644 (file)
--- a/adu.ggo
+++ b/adu.ggo
@@ -144,6 +144,21 @@ details="
        one that the argument being processed is on.
 "
 
        one that the argument being processed is on.
 "
 
+option "hash-table-bits" -
+#~~~~~~~~~~~~~~~~~~~~~~~~~
+"specify the size of the uid hash table"
+int typestr="num"
+dependon="create"
+default="10"
+optional
+details="
+       Use a hash table of size 2^num for the uid entries. If more than
+       2^num different uids own at least one regular file under base-dir,
+       the command fails. Increase this value if you have more than 1024
+       users. Decreasing the value causes adu to use slightly less memory.
+"
+
+
 ##############################
 section "Options for --select"
 ##############################
 ##############################
 section "Options for --select"
 ##############################
diff --git a/adu.h b/adu.h
index ea660dd7188e35e6f37c6a0ee812e08bf7d46c89..3e06c9509ff8d670e71ab582a017648b56f86a1c 100644 (file)
--- a/adu.h
+++ b/adu.h
@@ -192,7 +192,7 @@ int open_dir_table(int create);
 void check_signals(void);
 void close_all_tables(void);
 char *get_uid_list_name(void);
 void check_signals(void);
 void close_all_tables(void);
 char *get_uid_list_name(void);
-void create_hash_table(void);
+void create_hash_table(unsigned bits);
 int search_uid(uint32_t uid, enum search_uid_flags flags,
                struct user_info **ui_ptr);
 
 int search_uid(uint32_t uid, enum search_uid_flags flags,
                struct user_info **ui_ptr);