]> wimlib.net Git - wimlib/blobdiff - src/ntfs-3g_capture.c
ntfs-3g_capture.c: Capture named data streams of reparse points
[wimlib] / src / ntfs-3g_capture.c
index 1faba226c5d05104dd4fee1b14d9deb17d62ee34..6bdb46484d7150d6c39f2940b95f920a6f9a0c8d 100644 (file)
@@ -245,12 +245,19 @@ capture_ntfs_streams(struct wim_inode *inode,
                         * dentry's inode. */
                        if (inode->i_lte) {
                                if (lte) {
-                                       ERROR("Found two un-named data streams for \"%s\" "
-                                             "(sizes = %"PRIu64", %"PRIu64")",
-                                             path, inode->i_lte->size,
-                                             lte->size);
-                                       ret = WIMLIB_ERR_NTFS_3G;
-                                       goto out_free_lte;
+                                       if (!(inode->i_attributes &
+                                             FILE_ATTRIBUTE_REPARSE_POINT))
+                                       {
+                                               WARNING("Found two un-named "
+                                                       "data streams for \"%s\" "
+                                                       "(sizes = %"PRIu64", "
+                                                       "%"PRIu64")",
+                                                       path,
+                                                       inode->i_lte->size,
+                                                       lte->size);
+                                       }
+                                       free_lookup_table_entry(lte);
+                                       continue;
                                }
                        } else {
                                stream_id = 0;
@@ -528,7 +535,6 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
        int ret;
        struct wim_dentry *root = NULL;
        struct wim_inode *inode = NULL;
-       ATTR_TYPES stream_type;
 
        if (exclude_path(path, path_len, params->config, false)) {
                /* Exclude a file or directory tree based on the capture
@@ -584,20 +590,30 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
        inode->i_attributes       = le32_to_cpu(attributes);
        inode->i_resolved         = 1;
 
-       if (attributes & FILE_ATTR_REPARSE_POINT)
-               stream_type = AT_REPARSE_POINT;
-       else
-               stream_type = AT_DATA;
+       /* Capture streams.  */
 
-       /* Capture the file's streams; more specifically, this is supposed to:
+       if (attributes & FILE_ATTR_REPARSE_POINT) {
+               /* Capture reparse data stream.  */
+               ret = capture_ntfs_streams(inode, ni, path, path_len,
+                                          params->unhashed_streams,
+                                          vol, AT_REPARSE_POINT);
+               if (ret)
+                       goto out;
+       }
+
+       /* Capture data streams.
+        *
+        * Directories should not have an unnamed data stream, but they may have
+        * named data streams.
+        *
+        * Reparse points may have an unnamed data stream (which will be ignored
+        * in favor of the reparse data stream), and they also may have named
+        * data streams.
         *
-        * - Regular files: capture unnamed data stream and any named data
-        *   streams
-        * - Directories: capture any named data streams
-        * - Reparse points: capture reparse data only
-        */
+        * Regular files can have an unnamed data stream as well as named data
+        * streams.  */
        ret = capture_ntfs_streams(inode, ni, path, path_len,
-                                  params->unhashed_streams, vol, stream_type);
+                                  params->unhashed_streams, vol, AT_DATA);
        if (ret)
                goto out;