2 #include <dirent.h> /* readdir() */
4 #include "gcc-compat.h"
9 #include "portable_io.h"
13 /** Command line and config file options. */
14 static struct gengetopt_args_info conf;
17 /** whether this slot of the hash table is used. */
19 /** whether this uid should be taken into account. */
26 struct osl_table *table;
30 struct osl_table_description *desc;
34 * Contains info for each user that owns at least one regular file.
36 * Even users that are not taken into account because of the --uid
37 * option occupy a slot in this hash table. This allows to find out
38 * quicky whether a uid is admissible. And yes, this has to be fast.
40 static struct user_info *uid_hash_table;
42 static inline int ui_used(struct user_info *ui)
44 return ui->flags & UI_FL_SLOT_USED;
47 static inline int ui_admissible(struct user_info *ui)
49 return ui->flags & UI_FL_ADMISSIBLE;
57 static struct uid_range *admissible_uids;
59 static inline int check_uid_arg(const char *arg, uint32_t *uid)
61 const uint32_t max = ~0U;
63 * we need an 64-bit int for string -> uid conversion because strtoll()
64 * returns a signed value.
67 int ret = para_atoi64(arg, &val);
71 if (val < 0 || val > max)
72 return -ERRNO_TO_ERROR(EINVAL);
77 static int parse_uid_range(const char *orig_arg, struct uid_range *ur)
80 char *arg = para_strdup(orig_arg), *p = strchr(arg, '-');
83 if (p == arg) /* -42 */
85 ret = check_uid_arg(p, &ur->high);
88 ur->low = p? 0 : ur->high;
95 ret = check_uid_arg(arg, &ur->low);
99 if (*p) { /* 42-4711 */
100 ret = check_uid_arg(p, &ur->high);
104 if (ur->low > ur->high)
105 ret = -ERRNO_TO_ERROR(EINVAL);
108 ERROR_LOG("bad uid option: %s\n", orig_arg);
110 INFO_LOG("admissible uid range: %u - %u\n", ur->low,
117 /** evaluates to 1 if x < y, to -1 if x > y and to 0 if x == y */
118 #define NUM_COMPARE(x, y) ((int)((x) < (y)) - (int)((x) > (y)))
123 * \param ll Loglevel.
124 * \param fml Usual format string.
126 * All XXX_LOG() macros use this function.
128 __printf_2_3 void __log(int ll, const char* fmt,...)
136 if (ll < conf.loglevel_arg)
141 strftime(str, sizeof(str), "%b %d %H:%M:%S", tm);
142 fprintf(outfd, "%s ", str);
144 vfprintf(outfd, fmt, argp);
149 * Compare the size of two directories
151 * \param obj1 Pointer to the first object.
152 * \param obj2 Pointer to the second object.
154 * This function first compares the size values as usual integers. If they compare as
155 * equal, the address of \a obj1 and \a obj2 are compared. So this compare function
156 * returns zero if and only if \a obj1 and \a obj2 point to the same memory area.
158 static int size_compare(const struct osl_object *obj1, const struct osl_object *obj2)
160 uint64_t d1 = *(uint64_t *)obj1->data;
161 uint64_t d2 = *(uint64_t *)obj2->data;
162 int ret = NUM_COMPARE(d2, d1);
166 //INFO_LOG("addresses: %p, %p\n", obj1->data, obj2->data);
167 return NUM_COMPARE(obj2->data, obj1->data);
171 * Compare two osl objects of string type.
173 * \param obj1 Pointer to the first object.
174 * \param obj2 Pointer to the second object.
176 * In any case, only \p MIN(obj1->size, obj2->size) characters of each string
177 * are taken into account.
179 * \return It returns an integer less than, equal to, or greater than zero if
180 * \a obj1 is found, respectively, to be less than, to match, or be greater
183 * \sa strcmp(3), strncmp(3), osl_compare_func.
185 static int string_compare(const struct osl_object *obj1,
186 const struct osl_object *obj2)
188 const char *str1 = (const char *)obj1->data;
189 const char *str2 = (const char *)obj2->data;
190 return strncmp(str1, str2, MIN(obj1->size, obj2->size));
194 * Compare two osl objects pointing to unsigned integers of 64 bit size.
196 * \param obj1 Pointer to the first integer.
197 * \param obj2 Pointer to the second integer.
199 * \return The values required for an osl compare function.
201 * \sa osl_compare_func, osl_hash_compare().
203 static int uint64_compare(const struct osl_object *obj1,
204 const struct osl_object *obj2)
206 uint64_t d1 = read_u64((const char *)obj1->data);
207 uint64_t d2 = read_u64((const char *)obj2->data);
216 /** The columns of the directory table. */
217 enum dir_table_columns {
218 /** The name of the directory. */
220 /** The dir count number. */
222 /** The number of bytes of all regular files. */
224 /** The number of all regular files. */
226 /** Number of columns in this table. */
230 static struct osl_column_description dir_table_cols[] = {
232 .storage_type = OSL_MAPPED_STORAGE,
233 .storage_flags = OSL_RBTREE | OSL_UNIQUE,
235 .compare_function = string_compare,
238 .storage_type = OSL_MAPPED_STORAGE,
239 .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE | OSL_UNIQUE,
241 .compare_function = uint64_compare,
242 .data_size = sizeof(uint64_t)
245 .storage_type = OSL_MAPPED_STORAGE,
246 .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE,
247 .compare_function = size_compare,
249 .data_size = sizeof(uint64_t)
252 .storage_type = OSL_MAPPED_STORAGE,
253 .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE,
254 .compare_function = size_compare,
256 .data_size = sizeof(uint64_t)
260 static struct osl_table_description dir_table_desc = {
262 .num_columns = NUM_DT_COLUMNS,
264 .column_descriptions = dir_table_cols,
267 /** The columns of the id table. */
268 enum user_table_columns {
269 /** The numer of the directory. */
271 /** The number of bytes of all regular files in this dir owned by this id. */
273 /** The number of files in this dir owned by this id. */
275 /** Number of columns in this table. */
279 static struct osl_column_description user_table_cols[] = {
281 .storage_type = OSL_MAPPED_STORAGE,
282 .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE | OSL_UNIQUE,
284 .compare_function = uint64_compare,
285 .data_size = sizeof(uint64_t)
288 .storage_type = OSL_MAPPED_STORAGE,
289 .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE,
290 .compare_function = size_compare,
292 .data_size = sizeof(uint64_t)
295 .storage_type = OSL_MAPPED_STORAGE,
296 .storage_flags = OSL_RBTREE | OSL_FIXED_SIZE,
297 .compare_function = size_compare,
299 .data_size = sizeof(uint64_t)
303 static struct osl_table *dir_table;
305 static int add_directory(char *dirname, uint64_t dir_num, uint64_t *dir_size,
308 struct osl_object dir_objects[NUM_DT_COLUMNS];
310 INFO_LOG("adding #%llu: %s\n", (long long unsigned)dir_num, dirname);
311 dir_objects[DT_NAME].data = dirname;
312 dir_objects[DT_NAME].size = strlen(dirname) + 1;
313 dir_objects[DT_NUM].data = &dir_num;
314 dir_objects[DT_NUM].size = sizeof(dir_num);
315 dir_objects[DT_BYTES].data = dir_size;
316 dir_objects[DT_BYTES].size = sizeof(*dir_size);
317 dir_objects[DT_FILES].data = dir_files;
318 dir_objects[DT_FILES].size = sizeof(*dir_files);
320 return osl_add_row(dir_table, dir_objects);
323 static uint32_t num_uids;
325 static int open_user_table(struct user_info *ui, int create)
329 ui->desc = para_malloc(sizeof(*ui->desc));
330 ui->desc->num_columns = NUM_UT_COLUMNS;
332 ui->desc->column_descriptions = user_table_cols;
333 ui->desc->dir = para_strdup(conf.database_dir_arg);
334 ui->desc->name = make_message("%u", (unsigned)ui->uid);
335 INFO_LOG(".............................uid #%u: %u\n",
336 (unsigned)num_uids, (unsigned)ui->uid);
338 ret = osl_create_table(ui->desc);
343 ret = osl_open_table(ui->desc, &ui->table);
348 free((char *)ui->desc->name);
349 free((char *)ui->desc->dir);
351 ui->desc->name = NULL;
352 ui->desc->dir = NULL;
359 #define uid_hash_bits 8
360 static uint32_t uid_hash_table_size = 1 << uid_hash_bits;
361 #define PRIME1 0x811c9dc5
362 #define PRIME2 0x01000193
364 static void create_hash_table(void)
366 uid_hash_table = para_calloc(uid_hash_table_size
367 * sizeof(struct user_info));
370 static void free_hash_table(void)
372 free(uid_hash_table);
373 uid_hash_table = NULL;
376 static int create_tables(void)
380 dir_table_desc.dir = para_strdup(conf.database_dir_arg);
381 ret = osl_create_table(&dir_table_desc);
389 * We use a hash table of size s=2^uid_hash_bits to map the uids into the
390 * interval [0..s]. Hash collisions are treated by open addressing, i.e.
391 * unused slots in the table are used to store different uids that hash to the
394 * If a hash collision occurs, different slots are successively probed in order
395 * to find an unused slot for the new uid. Probing is implemented via a second
396 * hash function that maps the uid to h=(uid * PRIME2) | 1, which is always an
399 * An odd number is sufficient to make sure each entry of the hash table gets
400 * probed for probe_num between 0 and s-1 because s is a power of two, hence
401 * the second hash value has never a common divisor with the hash table size.
402 * IOW: h is invertible in the ring [0..s].
404 static uint32_t double_hash(uint32_t uid, uint32_t probe_num)
406 return (uid * PRIME1 + ((uid * PRIME2) | 1) * probe_num)
407 % uid_hash_table_size;
410 #define FOR_EACH_USER(ui) for (ui = uid_hash_table; ui && ui < uid_hash_table \
411 + uid_hash_table_size; ui++)
413 enum search_uid_flags {
415 CREATE_USER_TABLE = 2,
418 static int uid_is_admissible(uint32_t uid)
422 for (i = 0; i < conf.uid_given; i++) {
423 struct uid_range *ur = admissible_uids + i;
425 if (ur->low <= uid && ur->high >= uid)
428 i = !conf.uid_given || i < conf.uid_given;
429 DEBUG_LOG("uid %u is %sadmissible\n", (unsigned)uid,
434 static int search_uid(uint32_t uid, enum search_uid_flags flags,
435 struct user_info **ui_ptr)
439 for (p = 0; p < uid_hash_table_size; p++) {
440 struct user_info *ui = uid_hash_table + double_hash(uid, p);
447 ui->flags |= UI_FL_SLOT_USED;
448 if (!uid_is_admissible(uid))
450 ui->flags |= UI_FL_ADMISSIBLE;
451 ret = open_user_table(ui, flags & CREATE_USER_TABLE);
465 return flags? -E_HASH_TABLE_OVERFLOW : -E_BAD_UID;
468 static int update_user_row(struct osl_table *t, uint64_t dir_num,
472 struct osl_object obj = {.data = &dir_num, .size = sizeof(dir_num)};
474 int ret = osl_get_row(t, UT_DIR_NUM, &obj, &row);
476 if (ret < 0 && ret != -E_RB_KEY_NOT_FOUND)
478 if (ret < 0) { /* this is the first file we add */
479 struct osl_object objects[NUM_UT_COLUMNS];
480 uint64_t num_files = 1;
482 objects[UT_DIR_NUM].data = &dir_num;
483 objects[UT_DIR_NUM].size = sizeof(dir_num);
484 objects[UT_BYTES].data = add;
485 objects[UT_BYTES].size = sizeof(*add);
486 objects[UT_FILES].data = &num_files;
487 objects[UT_FILES].size = sizeof(num_files);
488 INFO_LOG("######################### ret: %d\n", ret);
489 ret = osl_add_row(t, objects);
490 INFO_LOG("######################### ret: %d\n", ret);
492 } else { /* add size and increment file count */
494 struct osl_object obj1, obj2 = {.data = &num, .size = sizeof(num)};
496 ret = osl_get_object(t, row, UT_BYTES, &obj1);
499 num = *(uint64_t *)obj1.data + *add;
500 ret = osl_update_object(t, row, UT_BYTES, &obj2);
503 ret = osl_get_object(t, row, UT_FILES, &obj1);
506 num = *(uint64_t *)obj1.data + 1;
507 return osl_update_object(t, row, UT_FILES, &obj2);
511 static uint64_t num_dirs;
512 static uint64_t num_files;
513 static uint64_t num_bytes;
515 int scan_dir(char *dirname)
518 struct dirent *entry;
519 int ret, cwd_fd, ret2;
520 uint64_t dir_size = 0, dir_files = 0;
521 uint64_t this_dir_num = num_dirs++;
523 DEBUG_LOG("----------------- %llu: %s\n", (long long unsigned)num_dirs, dirname);
524 ret = para_opendir(dirname, &dir, &cwd_fd);
526 if (ret != -ERRNO_TO_ERROR(EACCES))
528 WARNING_LOG("permission denied for %s\n", dirname);
531 while ((entry = readdir(dir))) {
537 struct user_info *ui;
539 if (!strcmp(entry->d_name, "."))
541 if (!strcmp(entry->d_name, ".."))
543 if (lstat(entry->d_name, &s) == -1) {
544 WARNING_LOG("lstat error for %s/%s\n", dirname,
549 if (!S_ISREG(m) && !S_ISDIR(m))
552 tmp = make_message("%s/%s", dirname, entry->d_name);
566 ret = search_uid(uid, CREATE_USER_TABLE | OPEN_USER_TABLE, &ui);
571 ret = update_user_row(ui->table, this_dir_num, &size);
575 ret = add_directory(dirname, this_dir_num, &dir_size, &dir_files);
578 ret2 = para_fchdir(cwd_fd);
579 if (ret2 < 0 && ret >= 0)
585 static int get_dir_name(struct osl_row *row, char **name)
587 struct osl_object obj;
588 int ret = osl_get_object(dir_table, row, DT_NAME, &obj);
596 const uint64_t size_unit_divisors[] = {
597 [size_unit_arg_b] = 1ULL,
598 [size_unit_arg_k] = 1024ULL,
599 [size_unit_arg_m] = 1024ULL * 1024ULL,
600 [size_unit_arg_g] = 1024ULL * 1024ULL * 1024ULL,
601 [size_unit_arg_t] = 1024ULL * 1024ULL * 1024ULL * 1024ULL,
604 const uint64_t count_unit_divisors[] = {
606 [count_unit_arg_n] = 1ULL,
607 [count_unit_arg_k] = 1000ULL,
608 [count_unit_arg_m] = 1000ULL * 1000ULL,
609 [count_unit_arg_g] = 1000ULL * 1000ULL * 1000ULL,
610 [count_unit_arg_t] = 1000ULL * 1000ULL * 1000ULL * 1000ULL,
613 const char size_unit_abbrevs[] = " BKMGT";
614 const char count_unit_abbrevs[] = " KMGT";
616 static void format_size_value(enum enum_size_unit unit, uint64_t value, char *result)
618 if (unit == size_unit_arg_h) /* human readable */
619 for (unit = size_unit_arg_b; unit < size_unit_arg_t && value > size_unit_divisors[unit + 1]; unit++)
621 sprintf(result, "%llu%c", (long long unsigned)value / size_unit_divisors[unit], size_unit_abbrevs[unit]);
624 static void format_count_value(enum enum_count_unit unit, uint64_t value, char *result)
626 if (unit == count_unit_arg_h) /* human readable */
627 for (unit = count_unit_arg_n; unit < count_unit_arg_t && value > count_unit_divisors[unit + 1]; unit++)
629 sprintf(result, "%llu%c", (long long unsigned)value / count_unit_divisors[unit], count_unit_abbrevs[unit]);
632 enum global_stats_flags {
633 GSF_PRINT_DIRNAME = 1,
636 GSF_COMPUTE_SUMMARY = 8,
639 struct global_stats_info {
641 enum global_stats_flags flags;
644 static int global_stats_loop_function(struct osl_row *row, void *data)
646 struct global_stats_info *gsi = data;
647 struct osl_object obj;
648 char *dirname, formated_value[25];
649 int ret, summary = gsi->flags & GSF_COMPUTE_SUMMARY;
651 if (!gsi->count && !summary)
652 return -E_LOOP_COMPLETE;
653 if (gsi->count && (gsi->flags & GSF_PRINT_DIRNAME)) {
654 ret = get_dir_name(row, &dirname);
657 printf("%s%s", dirname,
658 (gsi->flags & (GSF_PRINT_FILES | GSF_PRINT_BYTES))?
662 if (summary || (gsi->count && (gsi->flags & GSF_PRINT_FILES))) {
664 ret = osl_get_object(dir_table, row, DT_FILES, &obj);
667 files = *(uint64_t *)obj.data;
668 if (gsi->count && (gsi->flags & GSF_PRINT_FILES)) {
669 format_size_value(conf.size_unit_arg, files,
671 printf("%s%s", formated_value,
672 (gsi->flags & GSF_PRINT_BYTES)? "\t" : "\n");
677 if (summary || (gsi->count && (gsi->flags & GSF_PRINT_BYTES))) {
679 ret = osl_get_object(dir_table, row, DT_BYTES, &obj);
682 bytes = *(uint64_t *)obj.data;
683 if (gsi->count && (gsi->flags & GSF_PRINT_BYTES)) {
684 format_size_value(conf.size_unit_arg, bytes,
686 printf("%s\n", formated_value);
698 static void print_id_stats(void)
700 struct user_info *ui;
702 printf("--------------------- user summary (uid/dirs/files/bytes):\n");
704 char formated_dir_count[25], formated_file_count[25],
708 format_count_value(conf.count_unit_arg, ui->dirs,
710 format_count_value(conf.count_unit_arg, ui->files,
711 formated_file_count);
712 format_size_value(conf.size_unit_arg, ui->bytes,
714 printf("%u\t%s\t%s\t%s\n", (unsigned)ui->uid,
722 enum user_stats_flags {
723 USF_PRINT_DIRNAME = 1,
726 USF_COMPUTE_SUMMARY = 8,
729 struct user_stats_info {
731 enum user_stats_flags flags;
732 struct user_info *ui;
735 static int user_stats_loop_function(struct osl_row *row, void *data)
737 struct user_stats_info *usi = data;
738 struct osl_row *dir_row;
739 struct osl_object obj;
740 int ret, summary = usi->flags & GSF_COMPUTE_SUMMARY;
741 char formated_value[25];
743 if (!usi->count && !summary)
744 return -E_LOOP_COMPLETE;
745 if (usi->count && (usi->flags & USF_PRINT_DIRNAME)) {
747 ret = osl_get_object(usi->ui->table, row, UT_DIR_NUM, &obj);
750 ret = osl_get_row(dir_table, DT_NUM, &obj, &dir_row);
753 ret = osl_get_object(dir_table, dir_row, DT_NAME, &obj);
759 (usi->flags & (USF_PRINT_FILES | USF_PRINT_BYTES))?
763 if (summary || (usi->count && (usi->flags & USF_PRINT_FILES))) {
765 ret = osl_get_object(usi->ui->table, row, UT_FILES, &obj);
768 files = *(uint64_t *)obj.data;
769 if (usi->count && (usi->flags & USF_PRINT_FILES)) {
770 format_size_value(conf.size_unit_arg, files,
772 printf("%s%s", formated_value,
773 (usi->flags & USF_PRINT_BYTES)? "\t" : "\n"
777 usi->ui->files += files;
779 if (summary || (usi->count && (usi->flags & USF_PRINT_BYTES))) {
781 ret = osl_get_object(usi->ui->table, row, UT_BYTES, &obj);
784 bytes = *(uint64_t *)obj.data;
785 if (usi->count && (usi->flags & USF_PRINT_BYTES)) {
786 format_size_value(conf.size_unit_arg, bytes,
788 printf("%s\n", formated_value);
791 usi->ui->bytes += bytes;
801 static void print_user_stats(void)
803 struct user_info *ui;
806 struct user_stats_info usi = {
807 .count = conf.limit_arg,
810 if (!ui_used(ui) || !ui_admissible(ui))
812 usi.flags = USF_PRINT_DIRNAME | USF_PRINT_BYTES | USF_COMPUTE_SUMMARY;
813 printf("************************************************ uid %u\n",
815 printf("----------------- Largest dirs -------------------\n");
816 osl_rbtree_loop_reverse(ui->table, UT_BYTES, &usi,
817 user_stats_loop_function);
818 printf("---------- dirs containing most files ------------\n");
819 usi.count = conf.limit_arg,
820 usi.flags = USF_PRINT_DIRNAME | USF_PRINT_FILES;
821 osl_rbtree_loop_reverse(ui->table, UT_FILES, &usi,
822 user_stats_loop_function);
826 static int print_statistics(void)
829 struct global_stats_info gsi = {
830 .count = conf.limit_arg,
831 .flags = GSF_PRINT_DIRNAME | GSF_PRINT_BYTES | GSF_COMPUTE_SUMMARY
834 printf("----------------- Largest dirs -------------------\n");
835 ret = osl_rbtree_loop_reverse(dir_table, DT_BYTES, &gsi,
836 global_stats_loop_function);
837 if (ret < 0 && ret != -E_LOOP_COMPLETE)
839 gsi.count = conf.limit_arg;
841 gsi.flags = GSF_PRINT_DIRNAME | GSF_PRINT_FILES;
842 printf("---------- dirs containing most files ------------\n");
843 ret = osl_rbtree_loop_reverse(dir_table, DT_FILES, &gsi,
844 global_stats_loop_function);
845 if (ret < 0 && ret != -E_LOOP_COMPLETE)
848 printf("------------------ Global summary (dirs/files/bytes)\n"
849 "%llu\t%llu\t%llu\n",
850 (long long unsigned)num_dirs, (long long unsigned)num_files,
851 (long long unsigned)num_bytes);
857 static char *get_uid_list_name(void)
859 return make_message("%s/uid_list", conf.database_dir_arg);
862 static int write_uid_list(void)
864 char *buf, *filename;
866 struct user_info *ui;
867 size_t size = num_uids * sizeof(uint32_t);
872 buf = para_malloc(size);
874 if (!ui_used(ui) || !ui_admissible(ui))
876 DEBUG_LOG("saving uid %u\n", (unsigned) ui->uid);
877 write_u32(buf + count++ * sizeof(uint32_t), ui->uid);
879 filename = get_uid_list_name();
880 ret = para_write_file(filename, buf, size);
886 static int open_dir_table(void)
888 if (!dir_table_desc.dir) /* we did not create the table */
889 dir_table_desc.dir = para_strdup(conf.database_dir_arg);
890 return osl_open_table(&dir_table_desc, &dir_table);
893 static void close_dir_table(void)
899 ret = osl_close_table(dir_table, OSL_MARK_CLEAN);
901 ERROR_LOG("failed to close dir table: %s\n", error_txt(-ret));
902 free((char *)dir_table_desc.dir);
906 static void close_user_table(struct user_info *ui)
910 if (!ui || !ui_used(ui) || !ui_admissible(ui))
912 ret = osl_close_table(ui->table, OSL_MARK_CLEAN);
914 ERROR_LOG("failed to close user table %u: %s\n",
915 (unsigned) ui->uid, error_txt(-ret));
916 free((char *)ui->desc->name);
917 ui->desc->name = NULL;
918 free((char *)ui->desc->dir);
919 ui->desc->dir = NULL;
926 static void close_user_tables(void)
928 struct user_info *ui;
931 close_user_table(ui);
934 static void close_all_tables(void)
941 static int com_create()
943 int ret = create_tables();
946 ret = open_dir_table();
949 ret = scan_dir(conf.base_dir_arg);
952 ret = write_uid_list();
958 static int read_uid_file(void)
962 char *filename = get_uid_list_name(), *map;
963 int ret = mmap_full_file(filename, O_RDONLY, (void **)&map, &size, NULL);
966 INFO_LOG("failed to map %s\n", filename);
971 INFO_LOG("found %u uids in %s\n", (unsigned)num_uids, filename);
973 /* hash table size should be a power of two and larger than the number of uids */
974 uid_hash_table_size = 4;
975 while (uid_hash_table_size < num_uids)
976 uid_hash_table_size *= 2;
978 for (n = 0; n < num_uids; n++) {
979 uint32_t uid = read_u32(map + n * sizeof(uid));
980 ret = search_uid(uid, OPEN_USER_TABLE, NULL);
985 para_munmap(map, size);
989 static int com_select(void)
993 ret = open_dir_table();
996 ret = read_uid_file();
1004 static int check_args(void)
1008 if (!conf.uid_given)
1011 admissible_uids = para_malloc(conf.uid_given * sizeof(*admissible_uids));
1013 for (i = 0; i < conf.uid_given; i++) {
1014 ret = parse_uid_range(conf.uid_arg[i], admissible_uids + i);
1020 free(admissible_uids);
1021 admissible_uids = NULL;
1025 int main(int argc, char **argv)
1028 struct cmdline_parser_params params = {
1031 .check_required = 0,
1032 .check_ambiguity = 0,
1036 cmdline_parser_ext(argc, argv, &conf, ¶ms); /* aborts on errors */
1041 if (conf.select_given)
1048 free(admissible_uids);
1050 ERROR_LOG("%s\n", error_txt(-ret));
1051 return -EXIT_FAILURE;
1053 return EXIT_SUCCESS;