+/*
+ * Makes a NTFS hard link
+ *
+ * It is named @from_dentry->file_name and is located under the directory
+ * specified by @dir_ni, and it is made to point to the previously extracted
+ * file located at @to_dentry->extracted_file.
+ *
+ * Return 0 on success, nonzero on failure.
+ */
+static int wim_apply_hardlink_ntfs(const struct dentry *from_dentry,
+ const struct dentry *to_dentry,
+ ntfs_inode *dir_ni)
+{
+ int ret;
+ ntfs_inode *to_ni;
+
+ DEBUG("Extracting NTFS hard link `%s' => `%s'",
+ from_dentry->full_path_utf8, to_dentry->extracted_file);
+
+ to_ni = ntfs_pathname_to_inode(dir_ni->vol, NULL,
+ to_dentry->extracted_file);
+ if (!to_ni) {
+ ERROR_WITH_ERRNO("Could not find NTFS inode for `%s'",
+ to_dentry->extracted_file);
+ return WIMLIB_ERR_NTFS_3G;
+ }
+ ret = ntfs_link(to_ni, dir_ni,
+ (ntfschar*)from_dentry->file_name,
+ from_dentry->file_name_len / 2);
+ if (ret != 0) {
+ ERROR_WITH_ERRNO("Could not create hard link `%s' => `%s'",
+ from_dentry->full_path_utf8,
+ to_dentry->extracted_file);
+ ret = WIMLIB_ERR_NTFS_3G;
+ }
+ if (ntfs_inode_close(to_ni) != 0) {
+ ERROR_WITH_ERRNO("Failed to close NTFS inode for `%s'",
+ to_dentry->extracted_file);
+ ret = WIMLIB_ERR_NTFS_3G;
+ }
+ return ret;
+}
+