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 \
src/registry.c \
src/reparse.c \
src/resource.c \
+ src/scan.c \
src/security.c \
src/sha1.c \
src/solid.c \
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 \
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 \
-#ifndef _WIMLIB_CAPTURE_H
-#define _WIMLIB_CAPTURE_H
+#ifndef _WIMLIB_SCAN_H
+#define _WIMLIB_SCAN_H
#include "wimlib.h"
#include "wimlib/inode_table.h"
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. */
/* 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);
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__
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);
}
attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child,
struct blob_table *blob_table);
-#endif /* _WIMLIB_CAPTURE_H */
+#endif /* _WIMLIB_SCAN_H */
#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"
#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
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;
};
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,
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;
size_t path_len,
int name_type,
struct ntfs_volume_wrapper *volume,
- struct capture_params *params)
+ struct scan_params *params)
{
u32 attributes;
int 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;
}
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;
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;
/*
- * 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
#include <string.h>
#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"
/*
* 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.
* 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;
* > 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;
*/
/*
- * 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
#include <unistd.h>
#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"
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;
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;
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;
}
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;
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;
}
}
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;
* 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
*/
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;
#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"
#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. */
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;
#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,
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;
/* 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;
#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"
#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"
#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"
#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;
}
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);
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;
* 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;
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 |
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;
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
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 };