From: Eric Biggers Date: Wed, 22 Oct 2014 03:18:05 +0000 (-0500) Subject: Report directory tree scan errors X-Git-Tag: v1.7.3~14 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=c3e9bd8344d97960e8e6cf29cc1ff633e925f986 Report directory tree scan errors --- diff --git a/include/wimlib.h b/include/wimlib.h index ffc9cdbf..649f52a3 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -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, }; diff --git a/include/wimlib/capture.h b/include/wimlib/capture.h index b30688a4..b2938d51 100644 --- a/include/wimlib/capture.h +++ b/include/wimlib/capture.h @@ -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 */ diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index af6fa542..6255f09a 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -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; } diff --git a/src/unix_capture.c b/src/unix_capture.c index 884c9fd4..66cb4be2 100644 --- a/src/unix_capture.c +++ b/src/unix_capture.c @@ -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; } diff --git a/src/win32_capture.c b/src/win32_capture.c index 7d6d4583..449e73e0 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -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; }