]> wimlib.net Git - wimlib/blobdiff - src/add_image.c
Fix capturing non-directories in source list mode
[wimlib] / src / add_image.c
index 8e97a8ec1e95c3b7e623dba8e5b174880fb913a9..2a7f938ec600b81178f2279eaaeaf5c49d66f89d 100644 (file)
@@ -256,11 +256,6 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        struct wim_inode *inode;
 
        if (exclude_path(path, path_len, params->config, true)) {
-               if (params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) {
-                       ERROR("Cannot exclude the root directory from capture");
-                       ret = WIMLIB_ERR_INVALID_CAPTURE_CONFIG;
-                       goto out;
-               }
                if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_EXCLUDE_VERBOSE)
                    && params->progress_func)
                {
@@ -388,7 +383,9 @@ unix_build_dentry_tree(struct wim_dentry **root_ret,
                        return WIMLIB_ERR_STAT;
                }
 
-               if (!S_ISDIR(root_stbuf.st_mode)) {
+               if ((params->add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) &&
+                   !S_ISDIR(root_stbuf.st_mode))
+               {
                        ERROR("Root of capture \"%s\" is not a directory",
                              root_disk_path);
                        return WIMLIB_ERR_NOTDIR;
@@ -865,8 +862,13 @@ wimlib_add_image_multisource(WIMStruct *w,
 
        if ((add_image_flags & (WIMLIB_ADD_IMAGE_FLAG_RPFIX |
                                WIMLIB_ADD_IMAGE_FLAG_NORPFIX)) == 0)
-               if (w->hdr.flags & WIM_HDR_FLAG_RP_FIX)
+       {
+               /* Do reparse-point fixups by default if the header flag is set
+                * from previous images, or if this is the first image being
+                * added. */
+               if ((w->hdr.flags & WIM_HDR_FLAG_RP_FIX) || w->hdr.image_count == 0)
                        add_image_flags |= WIMLIB_ADD_IMAGE_FLAG_RPFIX;
+       }
 
        if (!name || !*name) {
                ERROR("Must specify a non-empty string for the image name");