Exclude unsupported files from capture
authorEric Biggers <ebiggers3@gmail.com>
Sat, 17 Aug 2013 18:03:04 +0000 (13:03 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 17 Aug 2013 18:03:04 +0000 (13:03 -0500)
include/wimlib.h
programs/imagex.c
src/ntfs-3g_capture.c
src/unix_capture.c
src/util.c
src/win32_capture.c

index 8ba2175..eb8a33b 100644 (file)
@@ -421,9 +421,19 @@ union wimlib_progress_info {
                 * */
                const wimlib_tchar *cur_path;
 
-               /** True iff @p cur_path is being excluded from the image
-                * capture due to the capture configuration file. */
-               bool excluded;
+               enum {
+                       /** File or directory looks okay and will be captured.  */
+                       WIMLIB_SCAN_DENTRY_OK = 0,
+
+                       /** File or directory is being excluded from capture due
+                        * to the capture configuration file.  */
+                       WIMLIB_SCAN_DENTRY_EXCLUDED,
+
+                       /** File or directory is being excluded from capture due
+                        * to being unsupported (e.g. an encrypted or device
+                        * file).  */
+                       WIMLIB_SCAN_DENTRY_UNSUPPORTED,
+               } status;
 
                /** Target path in the WIM.  Only valid on messages
                 * ::WIMLIB_PROGRESS_MSG_SCAN_BEGIN and
@@ -1373,7 +1383,6 @@ enum wimlib_error_code {
        WIMLIB_ERR_SET_SECURITY,
        WIMLIB_ERR_SET_SHORT_NAME,
        WIMLIB_ERR_SET_TIMESTAMPS,
-       WIMLIB_ERR_SPECIAL_FILE,
        WIMLIB_ERR_SPLIT_INVALID,
        WIMLIB_ERR_SPLIT_UNSUPPORTED,
        WIMLIB_ERR_STAT,
index 90b53dd..9f3939c 100644 (file)
@@ -1032,10 +1032,18 @@ imagex_progress_func(enum wimlib_progress_msg msg,
                }
                break;
        case WIMLIB_PROGRESS_MSG_SCAN_DENTRY:
-               if (info->scan.excluded)
-                       imagex_printf(T("Excluding \"%"TS"\" from capture\n"), info->scan.cur_path);
-               else
+               switch (info->scan.status) {
+               case WIMLIB_SCAN_DENTRY_OK:
                        imagex_printf(T("Scanning \"%"TS"\"\n"), info->scan.cur_path);
+                       break;
+               case WIMLIB_SCAN_DENTRY_EXCLUDED:
+                       imagex_printf(T("Excluding \"%"TS"\" from capture\n"), info->scan.cur_path);
+                       break;
+               case WIMLIB_SCAN_DENTRY_UNSUPPORTED:
+                       imagex_printf(T("WARNING: Excluding unsupported file or directory\n"
+                                       "         \"%"TS"\" from capture\n"), info->scan.cur_path);
+                       break;
+               }
                break;
        case WIMLIB_PROGRESS_MSG_VERIFY_INTEGRITY:
                unit_shift = get_unit(info->integrity.total_bytes, &unit_name);
index 10d4bcc..27c446a 100644 (file)
@@ -557,7 +557,7 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
                {
                        union wimlib_progress_info info;
                        info.scan.cur_path = path;
-                       info.scan.excluded = true;
+                       info.scan.status = WIMLIB_SCAN_DENTRY_EXCLUDED;
                        params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
                }
                root = NULL;
@@ -572,12 +572,28 @@ build_dentry_tree_ntfs_recursive(struct wim_dentry **root_ret,
                return WIMLIB_ERR_NTFS_3G;
        }
 
+       if ((attributes & (FILE_ATTRIBUTE_DIRECTORY |
+                          FILE_ATTRIBUTE_ENCRYPTED)) == FILE_ATTRIBUTE_ENCRYPTED)
+       {
+               if ((params->add_flags & WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE)
+                   && params->progress_func)
+               {
+                       union wimlib_progress_info info;
+                       info.scan.cur_path = path;
+                       info.scan.status = WIMLIB_SCAN_DENTRY_UNSUPPORTED;
+                       params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
+               }
+               root = NULL;
+               ret = 0;
+               goto out;
+       }
+
        if ((params->add_flags & WIMLIB_ADD_FLAG_VERBOSE)
            && params->progress_func)
        {
                union wimlib_progress_info info;
                info.scan.cur_path = path;
-               info.scan.excluded = false;
+               info.scan.status = WIMLIB_SCAN_DENTRY_OK;
                params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
        }
 
index 906920a..a080e8c 100644 (file)
@@ -210,7 +210,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                {
                        union wimlib_progress_info info;
                        info.scan.cur_path = path;
-                       info.scan.excluded = true;
+                       info.scan.status = WIMLIB_SCAN_DENTRY_EXCLUDED;
                        params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
                }
                goto out;
@@ -221,7 +221,7 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        {
                union wimlib_progress_info info;
                info.scan.cur_path = path;
-               info.scan.excluded = false;
+               info.scan.status = WIMLIB_SCAN_DENTRY_OK;
                params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
        }
 
@@ -241,9 +241,14 @@ unix_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        }
        if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)
            && !S_ISLNK(stbuf.st_mode)) {
-               ERROR("`%s' is not a regular file, directory, or symbolic link.",
-                     path);
-               ret = WIMLIB_ERR_SPECIAL_FILE;
+               if ((params->add_flags & WIMLIB_ADD_FLAG_EXCLUDE_VERBOSE)
+                   && params->progress_func)
+               {
+                       union wimlib_progress_info info;
+                       info.scan.cur_path = path;
+                       info.scan.status = WIMLIB_SCAN_DENTRY_UNSUPPORTED;
+                       params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
+               }
                goto out;
        }
 
index 640f8b3..8cb5777 100644 (file)
@@ -390,8 +390,6 @@ static const tchar *error_strings[] = {
                = T("Failed to set short name on extracted file"),
        [WIMLIB_ERR_SET_TIMESTAMPS]
                = T("Failed to set timestamps on extracted file"),
-       [WIMLIB_ERR_SPECIAL_FILE]
-               = T("Encountered a special file that cannot be archived"),
        [WIMLIB_ERR_SPLIT_INVALID]
                = T("The WIM is part of an invalid split WIM"),
        [WIMLIB_ERR_SPLIT_UNSUPPORTED]
index 9b16796..cf11639 100644 (file)
@@ -944,7 +944,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
                {
                        union wimlib_progress_info info;
                        info.scan.cur_path = path;
-                       info.scan.excluded = true;
+                       info.scan.status = WIMLIB_SCAN_DENTRY_EXCLUDED;
                        params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
                }
                ret = 0;
@@ -968,7 +968,7 @@ win32_build_dentry_tree_recursive(struct wim_dentry **root_ret,
        {
                union wimlib_progress_info info;
                info.scan.cur_path = path;
-               info.scan.excluded = false;
+               info.scan.status = WIMLIB_SCAN_DENTRY_OK;
                params->progress_func(WIMLIB_PROGRESS_MSG_SCAN_DENTRY, &info);
        }