From 47fcf3c14dec59bb5338b6e53890ab83c0ad4f2b Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 2 Mar 2016 20:07:19 -0600 Subject: [PATCH] Various renamings from "capture" to "scan" --- Makefile.am | 4 +- include/wimlib/{capture.h => scan.h} | 71 +++++++++++++++------------- src/ntfs-3g_capture.c | 21 ++++---- src/{capture_common.c => scan.c} | 14 +++--- src/unix_capture.c | 36 +++++++------- src/update_image.c | 12 ++--- src/win32_apply.c | 2 +- src/win32_capture.c | 26 +++++----- 8 files changed, 94 insertions(+), 92 deletions(-) rename include/wimlib/{capture.h => scan.h} (51%) rename src/{capture_common.c => scan.c} (97%) diff --git a/Makefile.am b/Makefile.am index d6b42d15..e51d3b3c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,6 @@ libwim_la_SOURCES = \ src/add_image.c \ src/avl_tree.c \ src/blob_table.c \ - src/capture_common.c \ src/compress.c \ src/compress_common.c \ src/compress_parallel.c \ @@ -76,6 +75,7 @@ libwim_la_SOURCES = \ src/registry.c \ src/reparse.c \ src/resource.c \ + src/scan.c \ src/security.c \ src/sha1.c \ src/solid.c \ @@ -101,7 +101,6 @@ libwim_la_SOURCES = \ include/wimlib/bitops.h \ include/wimlib/blob_table.h \ include/wimlib/bt_matchfinder.h \ - include/wimlib/capture.h \ include/wimlib/case.h \ include/wimlib/compiler.h \ include/wimlib/compressor_ops.h \ @@ -139,6 +138,7 @@ libwim_la_SOURCES = \ include/wimlib/registry.h \ include/wimlib/reparse.h \ include/wimlib/resource.h \ + include/wimlib/scan.h \ include/wimlib/security.h \ include/wimlib/security_descriptor.h \ include/wimlib/sha1.h \ diff --git a/include/wimlib/capture.h b/include/wimlib/scan.h similarity index 51% rename from include/wimlib/capture.h rename to include/wimlib/scan.h index 88ca5e8d..903f3d7f 100644 --- a/include/wimlib/capture.h +++ b/include/wimlib/scan.h @@ -1,5 +1,5 @@ -#ifndef _WIMLIB_CAPTURE_H -#define _WIMLIB_CAPTURE_H +#ifndef _WIMLIB_SCAN_H +#define _WIMLIB_SCAN_H #include "wimlib.h" #include "wimlib/inode_table.h" @@ -14,32 +14,40 @@ struct wim_dentry; struct wim_inode; struct capture_config { + + /* List of path patterns to exclude */ struct string_set exclusion_pats; + + /* List of path patterns to include, overriding exclusion_pats */ struct string_set exclusion_exception_pats; + void *buf; }; -/* Common parameters to implementations of building an in-memory dentry tree - * from an on-disk directory structure. */ -struct capture_params { - /* Pointer to the blob table of the WIM. */ +/* Scan parameters: common parameters to implementations of building an + * in-memory dentry tree from an external directory structure. */ +struct scan_params { + + /* The blob table within which any new blobs discovered during the scan + * will be deduplicated. */ struct blob_table *blob_table; - /* List of blobs that have been added so far, but without their SHA-1 - * message digests being calculated (as a shortcut). */ + /* List of new blobs that have been discovered without their SHA-1 + * message digests having been calculated (as a shortcut). */ struct list_head *unhashed_blobs; - /* Hash table of inodes that have been captured for this tree so far. */ + /* Map from (inode number, device number) pair to inode for new inodes + * that have been discovered so far. */ struct wim_inode_table *inode_table; - /* The set of security descriptors that have been captured for this - * image so far. */ + /* The set of unique security descriptors to which each newly + * discovered, unique security descriptor will be added. */ struct wim_sd_set *sd_set; - /* Pointer to the capture configuration. */ + /* The capture configuration in effect, or NULL if none. */ struct capture_config *config; - /* Flags that affect the capture operation (WIMLIB_ADD_FLAG_*) */ + /* Flags that affect the scan operation (WIMLIB_ADD_FLAG_*) */ int add_flags; /* If non-NULL, the user-supplied progress function. */ @@ -49,21 +57,21 @@ struct capture_params { /* Progress data. */ union wimlib_progress_info progress; - /* The capture implementation must set this to the number of characters - * that try_exclude() will strip from the path before testing exclusion - * patterns from the capture configuration file. */ + /* Before calling try_exclude(), the scan implementation must set this + * to the number of characters that try_exclude() will strip from the + * path when testing exclusion patterns. */ size_t capture_root_nchars; - /* Can be used by the capture implementation. */ + /* Can be used by the scan implementation. */ u64 capture_root_ino; u64 capture_root_dev; }; -/* capture_common.c */ +/* scan.c */ extern int -do_capture_progress(struct capture_params *params, int status, - const struct wim_inode *inode); +do_scan_progress(struct scan_params *params, int status, + const struct wim_inode *inode); extern int mangle_pat(tchar *pat, const tchar *path, unsigned long line_no); @@ -79,17 +87,16 @@ extern bool match_pattern_list(const tchar *path, const struct string_set *list); extern int -try_exclude(const tchar *full_path, const struct capture_params *params); +try_exclude(const tchar *full_path, const struct scan_params *params); -typedef int (*capture_tree_t)(struct wim_dentry **, const tchar *, - struct capture_params *); +typedef int (*scan_tree_t)(struct wim_dentry **, const tchar *, + struct scan_params *); #ifdef WITH_NTFS_3G /* ntfs-3g_capture.c */ extern int ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret, - const tchar *device, - struct capture_params *params); + const tchar *device, struct scan_params *params); #endif #ifdef __WIN32__ @@ -97,22 +104,20 @@ ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret, extern int win32_build_dentry_tree(struct wim_dentry **root_ret, const tchar *root_disk_path, - struct capture_params *params); -#define platform_default_capture_tree win32_build_dentry_tree + struct scan_params *params); +#define platform_default_scan_tree win32_build_dentry_tree #else /* unix_capture.c */ extern int unix_build_dentry_tree(struct wim_dentry **root_ret, - const tchar *root_disk_path, - struct capture_params *params); -#define platform_default_capture_tree unix_build_dentry_tree + const tchar *root_disk_path, struct scan_params *params); +#define platform_default_scan_tree unix_build_dentry_tree #endif #define WIMLIB_ADD_FLAG_ROOT 0x80000000 static inline int -report_capture_error(struct capture_params *params, int error_code, - const tchar *path) +report_scan_error(struct scan_params *params, int error_code, const tchar *path) { return report_error(params->progfunc, params->progctx, error_code, path); } @@ -124,4 +129,4 @@ extern void attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child, struct blob_table *blob_table); -#endif /* _WIMLIB_CAPTURE_H */ +#endif /* _WIMLIB_SCAN_H */ diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index 93d71e55..9d973a23 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -39,7 +39,6 @@ #include "wimlib/alloca.h" #include "wimlib/assert.h" #include "wimlib/blob_table.h" -#include "wimlib/capture.h" #include "wimlib/dentry.h" #include "wimlib/encoding.h" #include "wimlib/endianness.h" @@ -48,6 +47,7 @@ #include "wimlib/object_id.h" #include "wimlib/paths.h" #include "wimlib/reparse.h" +#include "wimlib/scan.h" #include "wimlib/security.h" /* NTFS-3g 2013 renamed MS_RDONLY to NTFS_MNT_RDONLY. We can't check for the @@ -611,7 +611,7 @@ struct readdir_ctx { size_t path_len; struct dos_name_map dos_name_map; struct ntfs_volume_wrapper *volume; - struct capture_params *params; + struct scan_params *params; int ret; }; @@ -622,7 +622,7 @@ ntfs_3g_build_dentry_tree_recursive(struct wim_dentry **root_p, size_t path_len, int name_type, struct ntfs_volume_wrapper *volume, - struct capture_params *params); + struct scan_params *params); static int filldir(void *_ctx, const ntfschar *name, const int name_nchars, @@ -676,7 +676,7 @@ static int ntfs_3g_recurse_directory(ntfs_inode *ni, char *path, size_t path_len, struct wim_dentry *parent, struct ntfs_volume_wrapper *volume, - struct capture_params *params) + struct scan_params *params) { int ret; s64 pos = 0; @@ -721,7 +721,7 @@ ntfs_3g_build_dentry_tree_recursive(struct wim_dentry **root_ret, size_t path_len, int name_type, struct ntfs_volume_wrapper *volume, - struct capture_params *params) + struct scan_params *params) { u32 attributes; int ret; @@ -759,7 +759,7 @@ ntfs_3g_build_dentry_tree_recursive(struct wim_dentry **root_ret, goto out; } params->progress.scan.cur_path = path; - ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_UNSUPPORTED, NULL); + ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_UNSUPPORTED, NULL); goto out; } @@ -838,16 +838,16 @@ ntfs_3g_build_dentry_tree_recursive(struct wim_dentry **root_ret, out_progress: params->progress.scan.cur_path = path; if (root == NULL) - ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); + ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); else - ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode); + ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_OK, inode); out: if (ni) ntfs_inode_close(ni); if (unlikely(ret)) { free_dentry_tree(root, params->blob_table); root = NULL; - ret = report_capture_error(params, ret, path); + ret = report_scan_error(params, ret, path); } *root_ret = root; return ret; @@ -855,8 +855,7 @@ out: int ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret, - const char *device, - struct capture_params *params) + const char *device, struct scan_params *params) { struct ntfs_volume_wrapper *volume; ntfs_volume *vol; diff --git a/src/capture_common.c b/src/scan.c similarity index 97% rename from src/capture_common.c rename to src/scan.c index 3c060124..96abe715 100644 --- a/src/capture_common.c +++ b/src/scan.c @@ -1,9 +1,9 @@ /* - * capture_common.c - Mostly code to handle excluding paths from capture. + * scan.c - Helper routines for directory tree scans */ /* - * Copyright (C) 2013, 2014 Eric Biggers + * Copyright (C) 2013-2016 Eric Biggers * * This file is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -26,12 +26,12 @@ #include #include "wimlib/blob_table.h" -#include "wimlib/capture.h" #include "wimlib/dentry.h" #include "wimlib/error.h" #include "wimlib/paths.h" #include "wimlib/pattern.h" #include "wimlib/progress.h" +#include "wimlib/scan.h" #include "wimlib/textfile.h" /* @@ -39,7 +39,7 @@ * and possibly call the progress function provided by the library user. * * @params - * Flags, optional progress function, and progress data for the capture + * Flags, optional progress function, and progress data for the scan * operation. * @status * Status of the scanned file. @@ -50,8 +50,8 @@ * via additional hard links, inode->i_nlink will be greater than 1. */ int -do_capture_progress(struct capture_params *params, int status, - const struct wim_inode *inode) +do_scan_progress(struct scan_params *params, int status, + const struct wim_inode *inode) { int ret; tchar *cookie; @@ -286,7 +286,7 @@ match_pattern_list(const tchar *path, const struct string_set *list) * > 0 (wimlib error code) if error */ int -try_exclude(const tchar *full_path, const struct capture_params *params) +try_exclude(const tchar *full_path, const struct scan_params *params) { int ret; diff --git a/src/unix_capture.c b/src/unix_capture.c index 2843c36a..a909f45b 100644 --- a/src/unix_capture.c +++ b/src/unix_capture.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 2012, 2013, 2014 Eric Biggers + * Copyright (C) 2012-2016 Eric Biggers * * This file is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free @@ -33,10 +33,10 @@ #include #include "wimlib/blob_table.h" -#include "wimlib/capture.h" #include "wimlib/dentry.h" #include "wimlib/error.h" #include "wimlib/reparse.h" +#include "wimlib/scan.h" #include "wimlib/timestamp.h" #include "wimlib/unix_data.h" @@ -136,13 +136,13 @@ static int unix_build_dentry_tree_recursive(struct wim_dentry **tree_ret, char *path, size_t path_len, int dirfd, const char *relpath, - struct capture_params *params); + struct scan_params *params); static int unix_scan_directory(struct wim_dentry *dir_dentry, char *full_path, size_t full_path_len, int parent_dirfd, const char *dir_relpath, - struct capture_params *params) + struct scan_params *params) { int dirfd; @@ -277,7 +277,7 @@ unix_relativize_link_target(char *target, u64 ino, u64 dev) static noinline_for_stack int unix_scan_symlink(const char *full_path, int dirfd, const char *relpath, - struct wim_inode *inode, struct capture_params *params) + struct wim_inode *inode, struct scan_params *params) { char orig_target[REPARSE_POINT_MAX_SIZE]; char *target = orig_target; @@ -313,7 +313,7 @@ unix_scan_symlink(const char *full_path, int dirfd, const char *relpath, inode->i_rp_flags &= ~WIM_RP_FLAG_NOT_FIXED; status = WIMLIB_SCAN_DENTRY_FIXED_SYMLINK; } - ret = do_capture_progress(params, status, NULL); + ret = do_scan_progress(params, status, NULL); if (ret) return ret; } @@ -338,7 +338,7 @@ static int unix_build_dentry_tree_recursive(struct wim_dentry **tree_ret, char *full_path, size_t full_path_len, int dirfd, const char *relpath, - struct capture_params *params) + struct scan_params *params) { struct wim_dentry *tree = NULL; struct wim_inode *inode = NULL; @@ -380,9 +380,9 @@ unix_build_dentry_tree_recursive(struct wim_dentry **tree_ret, goto out; } params->progress.scan.cur_path = full_path; - ret = do_capture_progress(params, - WIMLIB_SCAN_DENTRY_UNSUPPORTED, - NULL); + ret = do_scan_progress(params, + WIMLIB_SCAN_DENTRY_UNSUPPORTED, + NULL); goto out; } } @@ -443,14 +443,14 @@ unix_build_dentry_tree_recursive(struct wim_dentry **tree_ret, out_progress: params->progress.scan.cur_path = full_path; if (likely(tree)) - ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_OK, inode); + ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_OK, inode); else - ret = do_capture_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); + ret = do_scan_progress(params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); out: if (unlikely(ret)) { free_dentry_tree(tree, params->blob_table); tree = NULL; - ret = report_capture_error(params, ret, full_path); + ret = report_scan_error(params, ret, full_path); } *tree_ret = tree; return ret; @@ -461,13 +461,12 @@ out: * Builds a tree of WIM dentries from an on-disk directory tree (UNIX * version; no NTFS-specific data is captured). * - * @root_ret: Place to return a pointer to the root of the dentry tree. Only - * modified if successful. Set to NULL if the file or directory was - * excluded from capture. + * @root_ret: Place to return a pointer to the root of the dentry tree. Set + * to NULL if the file or directory was excluded from capture. * * @root_disk_path: The path to the root of the directory tree on disk. * - * @params: See doc for `struct capture_params'. + * @params: See doc for `struct scan_params'. * * @return: 0 on success, nonzero on failure. It is a failure if any of * the files cannot be `stat'ed, or if any of the needed @@ -478,8 +477,7 @@ out: */ int unix_build_dentry_tree(struct wim_dentry **root_ret, - const char *root_disk_path, - struct capture_params *params) + const char *root_disk_path, struct scan_params *params) { size_t path_len; size_t path_bufsz; diff --git a/src/update_image.c b/src/update_image.c index 63982cfe..8551b5f6 100644 --- a/src/update_image.c +++ b/src/update_image.c @@ -56,7 +56,6 @@ #include "wimlib/alloca.h" #include "wimlib/assert.h" #include "wimlib/blob_table.h" -#include "wimlib/capture.h" #include "wimlib/dentry.h" #include "wimlib/encoding.h" #include "wimlib/endianness.h" @@ -64,6 +63,7 @@ #include "wimlib/metadata.h" #include "wimlib/paths.h" #include "wimlib/progress.h" +#include "wimlib/scan.h" #include "wimlib/xml_windows.h" /* Saved specification of a "primitive" update operation that was performed. */ @@ -786,9 +786,9 @@ execute_add_command(struct update_command_journal *j, tchar *fs_source_path; tchar *wim_target_path; const tchar *config_file; - struct capture_params params; + struct scan_params params; struct capture_config config; - capture_tree_t capture_tree = platform_default_capture_tree; + scan_tree_t scan_tree = platform_default_scan_tree; struct wim_dentry *branch; add_flags = add_cmd->add.add_flags; @@ -800,7 +800,7 @@ execute_add_command(struct update_command_journal *j, #ifdef WITH_NTFS_3G if (add_flags & WIMLIB_ADD_FLAG_NTFS) - capture_tree = ntfs_3g_build_dentry_tree; + scan_tree = ntfs_3g_build_dentry_tree; #endif ret = get_capture_config(config_file, &config, @@ -826,7 +826,7 @@ execute_add_command(struct update_command_journal *j, if (WIMLIB_IS_WIM_ROOT_PATH(wim_target_path)) params.add_flags |= WIMLIB_ADD_FLAG_ROOT; - ret = (*capture_tree)(&branch, fs_source_path, ¶ms); + ret = (*scan_tree)(&branch, fs_source_path, ¶ms); if (ret) goto out_destroy_config; @@ -861,7 +861,7 @@ execute_add_command(struct update_command_journal *j, /* If a capture configuration file was explicitly specified when * capturing an image in WIMBoot mode, save it as * /Windows/System32/WimBootCompress.ini in the WIM image. */ - ret = platform_default_capture_tree(&branch, config_file, ¶ms); + ret = platform_default_scan_tree(&branch, config_file, ¶ms); if (ret) goto out_destroy_config; diff --git a/src/win32_apply.c b/src/win32_apply.c index 57f3a54b..b7d506b3 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -30,7 +30,6 @@ #include "wimlib/apply.h" #include "wimlib/assert.h" #include "wimlib/blob_table.h" -#include "wimlib/capture.h" /* for mangle_pat() and match_pattern_list() */ #include "wimlib/dentry.h" #include "wimlib/encoding.h" #include "wimlib/error.h" @@ -39,6 +38,7 @@ #include "wimlib/paths.h" #include "wimlib/pattern.h" #include "wimlib/reparse.h" +#include "wimlib/scan.h" /* for mangle_pat() and match_pattern_list() */ #include "wimlib/textfile.h" #include "wimlib/xml.h" #include "wimlib/wimboot.h" diff --git a/src/win32_capture.c b/src/win32_capture.c index 12212910..d4512e08 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -31,7 +31,6 @@ #include "wimlib/assert.h" #include "wimlib/blob_table.h" -#include "wimlib/capture.h" #include "wimlib/dentry.h" #include "wimlib/encoding.h" #include "wimlib/endianness.h" @@ -39,11 +38,12 @@ #include "wimlib/object_id.h" #include "wimlib/paths.h" #include "wimlib/reparse.h" +#include "wimlib/scan.h" #include "wimlib/win32_vss.h" #include "wimlib/wof.h" struct winnt_scan_ctx { - struct capture_params *params; + struct scan_params *params; bool is_ntfs; u32 vol_flags; unsigned long num_get_sd_access_denied; @@ -910,7 +910,7 @@ out_close_root_dir: } static int -winnt_rpfix_progress(struct capture_params *params, const wchar_t *path, +winnt_rpfix_progress(struct scan_params *params, const wchar_t *path, const struct link_reparse_point *link, int scan_status) { size_t print_name_nchars = link->print_name_nbytes / sizeof(wchar_t); @@ -921,12 +921,12 @@ winnt_rpfix_progress(struct capture_params *params, const wchar_t *path, params->progress.scan.cur_path = path; params->progress.scan.symlink_target = print_name0; - return do_capture_progress(params, scan_status, NULL); + return do_scan_progress(params, scan_status, NULL); } static int winnt_try_rpfix(struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_p, - const wchar_t *path, struct capture_params *params) + const wchar_t *path, struct scan_params *params) { struct link_reparse_point link; const wchar_t *rel_target; @@ -1019,7 +1019,7 @@ winnt_try_rpfix(struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_p, * capture root. */ static noinline_for_stack int winnt_load_reparse_data(HANDLE h, struct wim_inode *inode, - const wchar_t *full_path, struct capture_params *params) + const wchar_t *full_path, struct scan_params *params) { struct reparse_buffer_disk rpbuf; NTSTATUS status; @@ -1361,7 +1361,7 @@ set_sort_key(struct wim_inode *inode, u64 sort_key) static inline bool should_try_to_use_wimboot_hash(const struct wim_inode *inode, const struct winnt_scan_ctx *ctx, - const struct capture_params *params) + const struct scan_params *params) { /* Directories and encrypted files aren't valid for external backing. */ if (inode->i_attributes & (FILE_ATTRIBUTE_DIRECTORY | @@ -1802,16 +1802,16 @@ winnt_build_dentry_tree_recursive(struct wim_dentry **root_ret, out_progress: ctx->params->progress.scan.cur_path = full_path; if (likely(root)) - ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_OK, inode); + ret = do_scan_progress(ctx->params, WIMLIB_SCAN_DENTRY_OK, inode); else - ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); + ret = do_scan_progress(ctx->params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); out: if (likely(h)) NtClose(h); if (unlikely(ret)) { free_dentry_tree(root, ctx->params->blob_table); root = NULL; - ret = report_capture_error(ctx->params, ret, full_path); + ret = report_scan_error(ctx->params, ret, full_path); } *root_ret = root; return ret; @@ -2779,9 +2779,9 @@ generate_wim_structures_recursive(struct wim_dentry **root_ret, out_progress: ctx->params->progress.scan.cur_path = path; if (likely(root)) - ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_OK, inode); + ret = do_scan_progress(ctx->params, WIMLIB_SCAN_DENTRY_OK, inode); else - ret = do_capture_progress(ctx->params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); + ret = do_scan_progress(ctx->params, WIMLIB_SCAN_DENTRY_EXCLUDED, NULL); out: if (--ni->num_aliases == 0) { /* Memory usage optimization: when we don't need the ntfs_inode @@ -2851,7 +2851,7 @@ out: int win32_build_dentry_tree(struct wim_dentry **root_ret, const wchar_t *root_disk_path, - struct capture_params *params) + struct scan_params *params) { wchar_t *path = NULL; struct winnt_scan_ctx ctx = { .params = params }; -- 2.43.0