Changeset 0ca7286 in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c
- Timestamp:
- 2012-07-21T11:19:27Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2732c94
- Parents:
- 1c1da4b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_ops.c
r1c1da4b r0ca7286 56 56 #define max(a, b) ((a) > (b) ? (a) : (b)) 57 57 58 #define NODES_BUCKETS 25659 60 58 /** All root nodes have index 0. */ 61 59 #define TMPFS_SOME_ROOT 0 … … 146 144 147 145 /* Implementation of hash table interface for the nodes hash table. */ 148 static hash_index_t nodes_hash(unsigned long key[]) 149 { 150 return key[NODES_KEY_INDEX] % NODES_BUCKETS; 151 } 152 153 static int nodes_compare(unsigned long key[], hash_count_t keys, link_t *item) 146 static size_t nodes_key_hash(unsigned long key[]) 147 { 148 /* Based on Effective Java, 2nd Edition. */ 149 size_t hash = 17; 150 hash = 37 * hash + key[NODES_KEY_DEV]; 151 hash = 37 * hash + key[NODES_KEY_INDEX]; 152 return hash; 153 } 154 155 static size_t nodes_hash(const link_t *item) 156 { 157 tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t, nh_link); 158 159 unsigned long key[] = { 160 [NODES_KEY_DEV] = nodep->service_id, 161 [NODES_KEY_INDEX] = nodep->index 162 }; 163 164 return nodes_key_hash(key); 165 } 166 167 static bool nodes_match(unsigned long key[], size_t keys, const link_t *item) 154 168 { 155 169 tmpfs_node_t *nodep = hash_table_get_instance(item, tmpfs_node_t, … … 192 206 193 207 /** TMPFS nodes hash table operations. */ 194 hash_table_op erations_t nodes_ops = {208 hash_table_ops_t nodes_ops = { 195 209 .hash = nodes_hash, 196 .compare = nodes_compare, 210 .key_hash = nodes_key_hash, 211 .match = nodes_match, 212 .equal = 0, 197 213 .remove_callback = nodes_remove_callback 198 214 }; … … 220 236 bool tmpfs_init(void) 221 237 { 222 if (!hash_table_create(&nodes, NODES_BUCKETS, 2, &nodes_ops))238 if (!hash_table_create(&nodes, 0, 2, &nodes_ops)) 223 239 return false; 224 240 … … 331 347 332 348 /* Insert the new node into the nodes hash table. */ 333 unsigned long key[] = { 334 [NODES_KEY_DEV] = nodep->service_id, 335 [NODES_KEY_INDEX] = nodep->index 336 }; 337 hash_table_insert(&nodes, key, &nodep->nh_link); 349 hash_table_insert(&nodes, &nodep->nh_link); 338 350 *rfn = FS_NODE(nodep); 339 351 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.