]> wimlib.net Git - wimlib/commitdiff
Fix capturing non-directories in source list mode
authorEric Biggers <ebiggers3@gmail.com>
Thu, 25 Apr 2013 00:58:07 +0000 (19:58 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Thu, 25 Apr 2013 00:58:07 +0000 (19:58 -0500)
src/add_image.c
tests/test-imagex-capture_and_apply

index b50b05b55400c6c01fe6d0dac616118abd73ce4a..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;
index ce54c74acb12748da84b364c6bfe0b0d7e680387..90145e3054c51c996c3925db54a86a4c4ae5a4c7 100755 (executable)
@@ -114,6 +114,7 @@ if [ -e out.dir/hiberfil.sys -o -e "out.dir/System Volume Information" ]; then
        error "Files were not excluded from capture as expected"
 fi
 
+# Make sure reparse point fixups are working as expected
 __msg "Testing --rpfix"
 rm -r in.dir out.dir
 mkdir in.dir
@@ -151,6 +152,46 @@ then
        error "imagex apply failed to apply fixed absolute symlinks"
 fi
 
+# Make sure source list mode is working as expected
+rm -rf in.dir out.dir
+mkdir in.dir
+echo 1 > in.dir/1
+ln in.dir/1 in.dir/1link
+echo 5 > 5
+mkdir otherdir
+cp $srcdir/src/add_image.c otherdir
+cat > srclist << EOF
+in.dir /
+5      /5
+otherdir /otherdir
+EOF
+imagex capture srclist --source-list test.wim
+imagex apply test.wim out.dir
+if [[ ! -f out.dir/5 || ! -f out.dir/1 || ! -f out.dir/1link || \
+      ! -d out.dir/otherdir ]]; then
+       error "source list capture failed to work as expected"
+fi
+
+# Still testing source list capture: add quoted name, and try overlay
+rm -rf out.dir
+cat > srclist << EOF
+in.dir /
+5      /5
+otherdir /otherdir
+ "overlay dir 1"               'otherdir'      
+ "overlay dir 2"               'otherdir'  
+EOF
+mkdir "overlay dir 1"
+mkdir "overlay dir 2"
+echo A > "overlay dir 1"/A
+echo B > "overlay dir 2"/B
+imagex capture srclist --source-list test.wim
+imagex apply test.wim out.dir
+if [[ ! -f out.dir/5 || ! -f out.dir/1 || ! -f out.dir/1link || \
+      ! -f out.dir/otherdir/A || ! -f out.dir/otherdir/B ]]; then
+       error "source list capture (with quoted names and overlay) failed to work as expected"
+fi
+
 echo "**********************************************************"
 echo "          imagex capture/apply tests passed               "
 echo "**********************************************************"