]> wimlib.net Git - wimlib/blobdiff - src/win32.c
Win32: Do not hard link files with nNumberOfLinks = 1
[wimlib] / src / win32.c
index 932d2933d32b9a9ccf501d16a73b1dc22153dd96..0db8c3bf72583dcbe6e9c4091996dd5eac7745ce 100644 (file)
@@ -1123,11 +1123,14 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
 
        /* Create a WIM dentry with an associated inode, which may be shared.
         *
 
        /* Create a WIM dentry with an associated inode, which may be shared.
         *
-        * However, we need to explicitly check for directories and refuse to
-        * hard link them.  This is because Windows has a bug where it can
-        * return duplicate File IDs for directories on the FAT filesystem. */
+        * However, we need to explicitly check for directories and files with
+        * only 1 link and refuse to hard link them.  This is because Windows
+        * has a bug where it can return duplicate File IDs for files and
+        * directories on the FAT filesystem. */
        basename = path_basename_with_len(path, path_num_chars);
        basename = path_basename_with_len(path, path_num_chars);
-       if (!(file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+       if (!(file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+           && file_info.nNumberOfLinks > 1)
+       {
                ret = inode_table_new_dentry(params->inode_table,
                                             basename,
                                             ((u64)file_info.nFileIndexHigh << 32) |
                ret = inode_table_new_dentry(params->inode_table,
                                             basename,
                                             ((u64)file_info.nFileIndexHigh << 32) |