]> wimlib.net Git - wimlib/blobdiff - src/win32.c
Win32: Do not create lookup table entries for 0 length streams
[wimlib] / src / win32.c
index 6ab484e06c6c2931cef0e1af4475e37f130442a5..1b2aeffe597189f77396dd2a864a5ec54262c943 100644 (file)
@@ -46,6 +46,7 @@
 
 #define MAX_GET_SD_ACCESS_DENIED_WARNINGS 1
 #define MAX_GET_SACL_PRIV_NOTHELD_WARNINGS 1
+#define MAX_CREATE_HARD_LINK_WARNINGS 5
 struct win32_capture_state {
        unsigned long num_get_sd_access_denied;
        unsigned long num_get_sacl_priv_notheld;
@@ -743,18 +744,11 @@ win32_do_capture_rpfix(char *rpbuf, DWORD *rpbuflen_p,
 
 /* Load a reparse point into a WIM inode.  It is just stored in memory.
  *
- * @hFile:  Open handle to a reparse point, with permission to read the reparse
- *          data.
+ * @hFile is the open handle to a reparse point, with permission to read the
+ * reparse data.
  *
- * @inode:  WIM inode for the reparse point.
- *
- * @lookup_table:  Stream lookup table for the WIM; an entry will be added to it
- *                 for the reparse point unless an entry already exists for
- *                 the exact same data stream.
- *
- * @path:  External path to the reparse point.  Used for error messages only.
- *
- * Returns 0 on success; nonzero on failure. */
+ * @inode is the WIM inode for the reparse point.
+ */
 static int
 win32_capture_reparse_point(struct wim_dentry **root_p,
                            HANDLE hFile,
@@ -809,8 +803,8 @@ win32_capture_reparse_point(struct wim_dentry **root_p,
                        inode->i_not_rpfixed = 0;
                }
        }
-       return inode_add_ads_with_data(inode, L"", reparse_point_buf + 8,
-                                      bytesReturned - 8, params->lookup_table);
+       return inode_set_unnamed_stream(inode, reparse_point_buf + 8,
+                                       bytesReturned - 8, params->lookup_table);
 }
 
 /* Scans an unnamed or named stream of a Win32 file (not a reparse point
@@ -882,6 +876,12 @@ win32_capture_stream(const wchar_t *path,
                }
        }
 
+       /* If zero length stream, no lookup table entry needed. */
+       if ((u64)dat->StreamSize.QuadPart == 0) {
+               ret = 0;
+               goto out;
+       }
+
        /* Create a UTF-16LE string @spath that gives the filename, then a
         * colon, then the stream name.  Or, if it's an unnamed stream, just the
         * filename.  It is MALLOC()'ed so that it can be saved in the
@@ -1865,10 +1865,15 @@ win32_do_apply_dentry(const wchar_t *output_path,
                        win32_error(err);
                        return WIMLIB_ERR_LINK;
                } else {
-                       WARNING("Can't create hard link \"%ls => %ls\":\n"
-                               "          Volume does not support hard links!\n"
-                               "          Falling back to extracting a copy of the file.",
-                               output_path, inode->i_extracted_file);
+                       args->num_hard_links_failed++;
+                       if (args->num_hard_links_failed < MAX_CREATE_HARD_LINK_WARNINGS) {
+                               WARNING("Can't create hard link \"%ls => %ls\":\n"
+                                       "          Volume does not support hard links!\n"
+                                       "          Falling back to extracting a copy of the file.",
+                                       output_path, inode->i_extracted_file);
+                       } else if (args->num_hard_links_failed == MAX_CREATE_HARD_LINK_WARNINGS) {
+                               WARNING("Suppressing further hard linking warnings...");
+                       }
                }
        }