+ struct inode *inode = dentry->d_inode;
+
+ if (!((extract_flags & WIMLIB_EXTRACT_FLAG_MULTI_IMAGE)
+ && (extract_flags & (WIMLIB_EXTRACT_FLAG_SYMLINK |
+ WIMLIB_EXTRACT_FLAG_HARDLINK))))
+ {
+ /* If the dentry is one of a hard link set of at least 2
+ * dentries and one of the other dentries has already been
+ * extracted, make a hard link to the file corresponding to this
+ * already-extracted directory. Otherwise, extract the file,
+ * and set the inode->extracted_file field so that other
+ * dentries in the hard link group can link to it. */
+ if (inode->link_count > 1) {
+ if (inode->extracted_file) {
+ DEBUG("Extracting hard link `%s' => `%s'",
+ output_path, inode->extracted_file);
+ if (link(inode->extracted_file, output_path) != 0) {
+ ERROR_WITH_ERRNO("Failed to hard link "
+ "`%s' to `%s'",
+ output_path,
+ inode->extracted_file);
+ return WIMLIB_ERR_LINK;
+ }
+ return 0;
+ }
+ FREE(inode->extracted_file);
+ inode->extracted_file = STRDUP(output_path);
+ if (!inode->extracted_file) {
+ ERROR("Failed to allocate memory for filename");
+ return WIMLIB_ERR_NOMEM;
+ }
+ }
+ }
+
+ /* Extract the contents of the file to @output_path. */