]> wimlib.net Git - wimlib/blobdiff - src/unix_capture.c
read_wim_lookup_table(): Allow multiple "subpacks" per packed run
[wimlib] / src / unix_capture.c
index 7161d36367d7b2746b2d06ac0696b8662f48b71a..c0aa195066e5ea3f6acf767821e2ba8e1f4551dd 100644 (file)
@@ -45,7 +45,7 @@ static int
 unix_capture_regular_file(const char *path,
                          u64 size,
                          struct wim_inode *inode,
-                         struct wim_lookup_table *lookup_table)
+                         struct list_head *unhashed_streams)
 {
        inode->i_attributes = FILE_ATTRIBUTE_NORMAL;
 
@@ -65,7 +65,7 @@ unix_capture_regular_file(const char *path,
                lte->file_on_disk = file_on_disk;
                lte->resource_location = RESOURCE_IN_FILE_ON_DISK;
                lte->size = size;
-               lookup_table_insert_unhashed(lookup_table, lte, inode, 0);
+               add_unhashed_stream(lte, inode, 0, unhashed_streams);
                inode->i_lte = lte;
        }
        return 0;
@@ -163,14 +163,17 @@ unix_capture_symlink(struct wim_dentry **root_p,
                        dest = capture_fixup_absolute_symlink(dest,
                                                              params->capture_root_ino,
                                                              params->capture_root_dev);
-                       if (!dest) {
-                               WARNING("Ignoring out of tree absolute symlink "
-                                       "\"%s\" -> \"%s\"\n"
-                                       "          (Use --norpfix to capture "
-                                       "absolute symlinks as-is)",
-                                       path, deref_name_buf);
+                       if (dest == NULL) {
+                               /* RPFIX (reparse point fixup) mode:  Ignore
+                                * absolute symbolic link that points out of the
+                                * tree to be captured.  */
                                free_dentry(*root_p);
                                *root_p = NULL;
+                               params->progress.scan.cur_path = path;
+                               params->progress.scan.symlink_target = deref_name_buf;
+                               do_capture_progress(params,
+                                                   WIMLIB_SCAN_DENTRY_EXCLUDED_SYMLINK,
+                                                   NULL);
                                return 0;
                        }
                        inode->i_not_rpfixed = 0;
@@ -206,7 +209,10 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        struct wim_inode *inode = NULL;
        struct stat stbuf;
 
-       if (exclude_path(path, path_len, params->config, true)) {
+       if (exclude_path(path + params->capture_root_nchars,
+                        path_len - params->capture_root_nchars,
+                        params->config))
+       {
                ret = 0;
                goto out_progress;
        }
@@ -239,9 +245,10 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                goto out;
        }
 
-       ret = inode_table_new_dentry(&params->inode_table,
+       ret = inode_table_new_dentry(params->inode_table,
                                     path_basename_with_len(path, path_len),
-                                    stbuf.st_ino, stbuf.st_dev, false, &root);
+                                    stbuf.st_ino, stbuf.st_dev,
+                                    S_ISDIR(stbuf.st_mode), &root);
        if (ret)
                goto out;
 
@@ -275,11 +282,14 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        params->add_flags &= ~WIMLIB_ADD_FLAG_ROOT;
        if (S_ISREG(stbuf.st_mode))
                ret = unix_capture_regular_file(path, stbuf.st_size,
-                                               inode, params->lookup_table);
+                                               inode, params->unhashed_streams);
        else if (S_ISDIR(stbuf.st_mode))
                ret = unix_capture_directory(root, path, path_len, params);
-       else
+       else {
                ret = unix_capture_symlink(&root, path, inode, params);
+               if (root == NULL)
+                       goto out;
+       }
 
        if (ret)
                goto out;
@@ -335,13 +345,6 @@ unix_build_dentry_tree(struct wim_dentry **root_ret,
                        return WIMLIB_ERR_STAT;
                }
 
-               if ((params->add_flags & WIMLIB_ADD_FLAG_ROOT) &&
-                   !S_ISDIR(root_stbuf.st_mode))
-               {
-                       ERROR("Root of capture \"%s\" is not a directory",
-                             root_disk_path);
-                       return WIMLIB_ERR_NOTDIR;
-               }
                params->capture_root_ino = root_stbuf.st_ino;
                params->capture_root_dev = root_stbuf.st_dev;
        }
@@ -357,6 +360,8 @@ unix_build_dentry_tree(struct wim_dentry **root_ret,
                return WIMLIB_ERR_NOMEM;
        memcpy(path_buf, root_disk_path, path_len + 1);
 
+       params->capture_root_nchars = path_len;
+
        ret = unix_build_dentry_tree_recursive(root_ret, path_buf,
                                               path_len, params);
        FREE(path_buf);