Report directory tree scan errors
authorEric Biggers <ebiggers3@gmail.com>
Wed, 22 Oct 2014 03:18:05 +0000 (22:18 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Wed, 22 Oct 2014 03:25:29 +0000 (22:25 -0500)
include/wimlib.h
include/wimlib/capture.h
src/ntfs-3g_capture.c
src/unix_capture.c
src/win32_capture.c

index ffc9cdb..649f52a 100644 (file)
@@ -725,6 +725,7 @@ enum wimlib_progress_msg {
         * Currently, only the following types of errors will result in this
         * progress message being sent:
         *
+        *      - Directory tree scan errors, e.g. from wimlib_add_image()
         */
        WIMLIB_PROGRESS_MSG_HANDLE_ERROR = 31,
 };
index b30688a..b2938d5 100644 (file)
@@ -4,6 +4,7 @@
 #include "wimlib.h"
 #include "wimlib/inode_table.h"
 #include "wimlib/list.h"
+#include "wimlib/progress.h"
 #include "wimlib/security.h"
 #include "wimlib/textfile.h"
 #include "wimlib/util.h"
@@ -115,4 +116,11 @@ unix_build_dentry_tree(struct wim_dentry **root_ret,
 
 #define WIMLIB_ADD_FLAG_ROOT   0x80000000
 
+static inline int
+report_capture_error(struct add_image_params *params, int error_code,
+                    const tchar *path)
+{
+       return report_error(params->progfunc, params->progctx, error_code, path);
+}
+
 #endif /* _WIMLIB_CAPTURE_H */
index af6fa54..6255f09 100644 (file)
@@ -704,10 +704,12 @@ out_progress:
        else
                ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode);
 out:
-       if (ret == 0)
-               *root_ret = root;
-       else
+       if (unlikely(ret)) {
                free_dentry_tree(root, params->lookup_table);
+               root = NULL;
+               ret = report_capture_error(params, ret, path);
+       }
+       *root_ret = root;
        return ret;
 }
 
index 884c9fd..66cb4be 100644 (file)
@@ -437,10 +437,12 @@ out_progress:
        else
                ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL);
 out:
-       if (likely(ret == 0))
-               *tree_ret = tree;
-       else
+       if (unlikely(ret)) {
                free_dentry_tree(tree, params->lookup_table);
+               tree = NULL;
+               ret = report_capture_error(params, ret, full_path);
+       }
+       *tree_ret = tree;
        return ret;
 }
 
index 7d6d458..449e73e 100644 (file)
@@ -1383,10 +1383,12 @@ out_progress:
 out:
        if (likely(h != INVALID_HANDLE_VALUE))
                (*func_NtClose)(h);
-       if (likely(ret == 0))
-               *root_ret = root;
-       else
+       if (unlikely(ret)) {
                free_dentry_tree(root, params->lookup_table);
+               root = NULL;
+               ret = report_capture_error(params, ret, full_path);
+       }
+       *root_ret = root;
        return ret;
 }