+ inode->resolved = true;
+
+ if (S_ISREG(root_stbuf.st_mode)) { /* Archiving a regular file */
+
+ struct lookup_table_entry *lte;
+ u8 hash[SHA1_HASH_SIZE];
+
+ inode->attributes = FILE_ATTRIBUTE_NORMAL;
+
+ /* Empty files do not have to have a lookup table entry. */
+ if (root_stbuf.st_size == 0)
+ goto out;
+
+ /* For each regular file, we must check to see if the file is in
+ * the lookup table already; if it is, we increment its refcnt;
+ * otherwise, we create a new lookup table entry and insert it.
+ * */
+
+ ret = sha1sum(root_disk_path, hash);
+ if (ret != 0)
+ goto out;
+
+ lte = __lookup_resource(lookup_table, hash);
+ if (lte) {
+ lte->refcnt++;
+ DEBUG("Add lte reference %u for `%s'", lte->refcnt,
+ root_disk_path);
+ } else {
+ char *file_on_disk = STRDUP(root_disk_path);
+ if (!file_on_disk) {
+ ERROR("Failed to allocate memory for file path");
+ ret = WIMLIB_ERR_NOMEM;
+ goto out;
+ }
+ lte = new_lookup_table_entry();
+ if (!lte) {
+ FREE(file_on_disk);
+ ret = WIMLIB_ERR_NOMEM;
+ goto out;
+ }
+ lte->file_on_disk = file_on_disk;
+ lte->resource_location = RESOURCE_IN_FILE_ON_DISK;
+ lte->resource_entry.original_size = root_stbuf.st_size;
+ lte->resource_entry.size = root_stbuf.st_size;
+ copy_hash(lte->hash, hash);
+ lookup_table_insert(lookup_table, lte);
+ }
+ root->d_inode->lte = lte;
+ } else if (S_ISDIR(root_stbuf.st_mode)) { /* Archiving a directory */
+
+ inode->attributes = FILE_ATTRIBUTE_DIRECTORY;