X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fhardlink.c;h=3f316f1d993d1f84fa9852fde53e9ec900ad3f09;hb=926ff6c5ed956b96fcb521b2c20afcf9ac890b14;hp=461c9523371309b3594833d82e241a4234dd6bfd;hpb=fced769402ff6ef0bf75fe9e4dcb2880891469e0;p=wimlib diff --git a/src/hardlink.c b/src/hardlink.c index 461c9523..3f316f1d 100644 --- a/src/hardlink.c +++ b/src/hardlink.c @@ -108,7 +108,7 @@ inode_table_insert(struct wim_dentry *dentry, void *_table) "\"%"TS"\" <=> \"%"TS"\"", dentry_full_path(dentry), dentry_full_path(inode_first_dentry(inode))); - return WIMLIB_ERR_INVALID_DENTRY; + return WIMLIB_ERR_INVALID_METADATA_RESOURCE; } inode_add_dentry(dentry, inode); return 0; @@ -311,7 +311,7 @@ fix_true_inode(struct wim_inode *inode, struct list_head *inode_list) if (dentry != ref_dentry) { if (!inodes_consistent(ref_inode, dentry->d_inode)) { inconsistent_inode(ref_inode); - return WIMLIB_ERR_INVALID_DENTRY; + return WIMLIB_ERR_INVALID_METADATA_RESOURCE; } /* Free the unneeded `struct wim_inode'. */ wimlib_assert(dentry->d_inode->i_nlink == 1); @@ -349,7 +349,6 @@ fix_nominal_inode(struct wim_inode *inode, struct list_head *inode_list, struct hlist_node *cur, *tmp; int ret; size_t num_true_inodes; - unsigned nominal_group_size = inode_link_count(inode); LIST_HEAD(dentries_with_data_streams); LIST_HEAD(dentries_with_no_data_streams); @@ -378,6 +377,7 @@ fix_nominal_inode(struct wim_inode *inode, struct list_head *inode_list, * inode to be a true inode */ if (list_empty(&dentries_with_data_streams)) { #ifdef ENABLE_DEBUG + unsigned nominal_group_size = inode_link_count(inode); if (nominal_group_size > 1) { DEBUG("Found link group of size %u without " "any data streams:", nominal_group_size); @@ -420,13 +420,13 @@ next_dentry_2: * streamless dentries to. */ if (!list_empty(&dentries_with_no_data_streams)) { if (num_true_inodes != 1) { - ERROR("Hard inode ambiguity detected!"); + ERROR("Hard link ambiguity detected!"); ERROR("We split up inode 0x%"PRIx64" due to " "inconsistencies,", inode->i_ino); ERROR("but dentries with no stream information remained. " "We don't know which inode"); ERROR("to assign them to."); - ret = WIMLIB_ERR_INVALID_DENTRY; + ret = WIMLIB_ERR_INVALID_METADATA_RESOURCE; goto out_cleanup_true_inode_list; } inode = container_of(true_inodes.first, struct wim_inode, i_hlist); @@ -514,9 +514,13 @@ fix_inodes(struct wim_inode_table *table, struct list_head *inode_list, * WIM) is examined for consistency and may be split into multiple "true" inodes * that are maximally sized consistent sets of dentries. * - * Return 0 on success; WIMLIB_ERR_NOMEM or WIMLIB_ERR_INVALID_DENTRY on - * failure. On success, the list of "true" inodes, linked by the i_hlist field, + * On success, the list of "true" inodes, linked by the i_hlist field, * is returned in the hlist @inode_list. + * + * Return values: + * WIMLIB_ERR_SUCCESS (0) + * WIMLIB_ERR_INVALID_METADATA_RESOURCE + * WIMLIB_ERR_NOMEM */ int dentry_tree_fix_inodes(struct wim_dentry *root, struct list_head *inode_list) @@ -581,31 +585,31 @@ void inode_table_prepare_inode_list(struct wim_inode_table *table, struct list_head *head) { - struct wim_inode *inode; + struct wim_inode *inode, *tmp_inode; struct hlist_node *cur, *tmp; u64 cur_ino = 1; /* Re-assign inode numbers in the existing list to avoid duplicates. */ - list_for_each_entry(inode, head, i_list) { - if (inode->i_nlink > 1) - inode->i_ino = cur_ino++; - else - inode->i_ino = 0; - } + list_for_each_entry(inode, head, i_list) + inode->i_ino = cur_ino++; /* Assign inode numbers to the new inodes and move them to the image's * inode list. */ for (size_t i = 0; i < table->capacity; i++) { hlist_for_each_entry_safe(inode, cur, tmp, &table->array[i], i_hlist) { - if (inode->i_nlink > 1) - inode->i_ino = cur_ino++; - else - inode->i_ino = 0; + inode->i_ino = cur_ino++; + inode->i_devno = 0; list_add_tail(&inode->i_list, head); } INIT_HLIST_HEAD(&table->array[i]); } - list_splice_tail(&table->extra_inodes, head); + list_for_each_entry_safe(inode, tmp_inode, &table->extra_inodes, i_list) + { + inode->i_ino = cur_ino++; + inode->i_devno = 0; + list_add_tail(&inode->i_list, head); + } + INIT_LIST_HEAD(&table->extra_inodes); table->num_entries = 0; }