- return (uid * PRIME1 + ((uid * PRIME2) | 1) * probe_num)
- % uid_hash_table_size;
-}
-
-static int uid_is_admissible(uint32_t uid)
-{
- int i;
-
- for (i = 0; i < conf.uid_given; i++) {
- struct uid_range *ur = admissible_uids + i;
-
- if (ur->low <= uid && ur->high >= uid)
- break;
- }
- i = !conf.uid_given || i < conf.uid_given;
- DEBUG_LOG("uid %u is %sadmissible\n", (unsigned)uid,
- i? "" : "not ");
- return i;
-}
-
-int search_uid(uint32_t uid, enum search_uid_flags flags,
- struct user_info **ui_ptr)
-{
- uint32_t p;
-
- for (p = 0; p < uid_hash_table_size; p++) {
- struct user_info *ui = uid_hash_table + double_hash(uid, p);
-
- if (!ui_used(ui)) {
- int ret;
- if (!flags)
- return -E_BAD_UID;
- ui->uid = uid;
- ui->flags |= UI_FL_SLOT_USED;
- if (!uid_is_admissible(uid))
- return 0;
- ui->flags |= UI_FL_ADMISSIBLE;
- ret = open_user_table(ui, flags & CREATE_USER_TABLE);
- if (ret < 0)
- return ret;
-
- if (ui_ptr)
- *ui_ptr = ui;
- return 1;
- }
- if (ui->uid != uid)
- continue;
- if (ui_ptr)
- *ui_ptr = ui;
- return 0;
- }
- return flags? -E_HASH_TABLE_OVERFLOW : -E_BAD_UID;
-}
-
-static int update_user_row(struct osl_table *t, uint64_t dir_num,
- uint64_t *add)
-{
- struct osl_row *row;
- struct osl_object obj = {.data = &dir_num, .size = sizeof(dir_num)};
-
- int ret = osl(osl_get_row(t, UT_DIR_NUM, &obj, &row));
-
- if (ret == -E_OSL && osl_errno != E_OSL_RB_KEY_NOT_FOUND)
- return ret;
- if (ret < 0) { /* this is the first file we add */
- struct osl_object objects[NUM_UT_COLUMNS];
- uint64_t num_files = 1;
-
- objects[UT_DIR_NUM].data = &dir_num;
- objects[UT_DIR_NUM].size = sizeof(dir_num);
- objects[UT_BYTES].data = add;
- 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;
- struct osl_object obj1, obj2 = {.data = &num, .size = sizeof(num)};
-
- ret = osl(osl_get_object(t, row, UT_BYTES, &obj1));
- if (ret < 0)
- return ret;
- num = *(uint64_t *)obj1.data + *add;
- ret = osl(osl_update_object(t, row, UT_BYTES, &obj2));
- if (ret < 0)
- return ret;
- ret = osl(osl_get_object(t, row, UT_FILES, &obj1));
- if (ret < 0)
- return ret;
- num = *(uint64_t *)obj1.data + 1;
- return osl(osl_update_object(t, row, UT_FILES, &obj2));
- }
-}
-
-/* id of the device containing the base dir. */
-static dev_t device_id;