-/* Acquire another reference to each single-instance stream referenced by this
- * inode. This is necessary when creating a hard link to this inode.
- *
- * The inode must be resolved. */
-void
-inode_ref_streams(struct wim_inode *inode)
-{
- for (unsigned i = 0; i <= inode->i_num_ads; i++) {
- struct wim_lookup_table_entry *lte;
-
- lte = inode_stream_lte_resolved(inode, i);
- if (lte)
- lte->refcnt++;
- }
-}
-
-/* Drop a reference to each single-instance stream referenced by this inode.
- * This is necessary when deleting a hard link to this inode. */
-void
-inode_unref_streams(struct wim_inode *inode,
- struct wim_lookup_table *lookup_table)
-{
- for (unsigned i = 0; i <= inode->i_num_ads; i++) {
- struct wim_lookup_table_entry *lte;
-
- lte = inode_stream_lte(inode, i, lookup_table);
- if (lte)
- lte_decrement_refcnt(lte, lookup_table);
- }
-}
-
-/* Initialize a hash table for hard link detection. */
-int
-init_inode_table(struct wim_inode_table *table, size_t capacity)
-{
- table->array = CALLOC(capacity, sizeof(table->array[0]));
- if (!table->array)
- return WIMLIB_ERR_NOMEM;
- table->num_entries = 0;
- table->capacity = capacity;
- INIT_LIST_HEAD(&table->extra_inodes);
- return 0;
-}
-
-/* Free the memory allocated by init_inode_table(). */
-void
-destroy_inode_table(struct wim_inode_table *table)
-{
- FREE(table->array);
-}
-
-static struct wim_inode *
-inode_table_get_inode(struct wim_inode_table *table, u64 ino, u64 devno)
-{
- u64 hash = hash_u64(hash_u64(ino) + hash_u64(devno));
- size_t pos = hash % table->capacity;
- struct wim_inode *inode;
- struct hlist_node *cur;
-
- /* Search for an existing inode having the same inode number and device
- * number. */
- hlist_for_each_entry(inode, cur, &table->array[pos], i_hlist) {
- if (inode->i_ino == ino && inode->i_devno == devno) {
- /* Found; use the existing inode. */
- inode->i_nlink++;
- return inode;
- }
- }
-
- /* Create a new inode and insert it into the table. */
- inode = new_timeless_inode();
- if (inode) {
- inode->i_ino = ino;
- inode->i_devno = devno;
- hlist_add_head(&inode->i_hlist, &table->array[pos]);
- table->num_entries++;
- }
- return inode;
-}
-