"\"%"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;
return 0;
}
-#if defined(ENABLE_ERROR_MESSAGES) || defined(ENABLE_DEBUG)
-static void
+static inline void
print_inode_dentries(const struct wim_inode *inode)
{
struct wim_dentry *dentry;
inode_for_each_dentry(dentry, inode)
tfprintf(stderr, T("%"TS"\n"), dentry_full_path(dentry));
}
-#endif
static void
inconsistent_inode(const struct wim_inode *inode)
{
-#ifdef ENABLE_ERROR_MESSAGES
- ERROR("An inconsistent hard link group that cannot be corrected has "
- "been detected");
- ERROR("The dentries are located at the following paths:");
- print_inode_dentries(inode);
-#endif
+ if (wimlib_print_errors) {
+ ERROR("An inconsistent hard link group that cannot be corrected has "
+ "been detected");
+ ERROR("The dentries are located at the following paths:");
+ print_inode_dentries(inode);
+ }
}
static bool
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);
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);
* 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);
* 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);
* 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)
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;
}