]> wimlib.net Git - wimlib/blob - include/wimlib/scan.h
Various renamings from "capture" to "scan"
[wimlib] / include / wimlib / scan.h
1 #ifndef _WIMLIB_SCAN_H
2 #define _WIMLIB_SCAN_H
3
4 #include "wimlib.h"
5 #include "wimlib/inode_table.h"
6 #include "wimlib/list.h"
7 #include "wimlib/progress.h"
8 #include "wimlib/security.h"
9 #include "wimlib/textfile.h"
10 #include "wimlib/util.h"
11
12 struct blob_table;
13 struct wim_dentry;
14 struct wim_inode;
15
16 struct capture_config {
17
18         /* List of path patterns to exclude  */
19         struct string_set exclusion_pats;
20
21         /* List of path patterns to include, overriding exclusion_pats  */
22         struct string_set exclusion_exception_pats;
23
24         void *buf;
25 };
26
27 /* Scan parameters: common parameters to implementations of building an
28  * in-memory dentry tree from an external directory structure.  */
29 struct scan_params {
30
31         /* The blob table within which any new blobs discovered during the scan
32          * will be deduplicated.  */
33         struct blob_table *blob_table;
34
35         /* List of new blobs that have been discovered without their SHA-1
36          * message digests having been calculated (as a shortcut).  */
37         struct list_head *unhashed_blobs;
38
39         /* Map from (inode number, device number) pair to inode for new inodes
40          * that have been discovered so far.  */
41         struct wim_inode_table *inode_table;
42
43         /* The set of unique security descriptors to which each newly
44          * discovered, unique security descriptor will be added.  */
45         struct wim_sd_set *sd_set;
46
47         /* The capture configuration in effect, or NULL if none.  */
48         struct capture_config *config;
49
50         /* Flags that affect the scan operation (WIMLIB_ADD_FLAG_*) */
51         int add_flags;
52
53         /* If non-NULL, the user-supplied progress function. */
54         wimlib_progress_func_t progfunc;
55         void *progctx;
56
57         /* Progress data.  */
58         union wimlib_progress_info progress;
59
60         /* Before calling try_exclude(), the scan implementation must set this
61          * to the number of characters that try_exclude() will strip from the
62          * path when testing exclusion patterns.  */
63         size_t capture_root_nchars;
64
65         /* Can be used by the scan implementation.  */
66         u64 capture_root_ino;
67         u64 capture_root_dev;
68 };
69
70 /* scan.c */
71
72 extern int
73 do_scan_progress(struct scan_params *params, int status,
74                  const struct wim_inode *inode);
75
76 extern int
77 mangle_pat(tchar *pat, const tchar *path, unsigned long line_no);
78
79 extern int
80 read_capture_config(const tchar *config_file, const void *buf,
81                     size_t bufsize, struct capture_config *config);
82
83 extern void
84 destroy_capture_config(struct capture_config *config);
85
86 extern bool
87 match_pattern_list(const tchar *path, const struct string_set *list);
88
89 extern int
90 try_exclude(const tchar *full_path, const struct scan_params *params);
91
92 typedef int (*scan_tree_t)(struct wim_dentry **, const tchar *,
93                            struct scan_params *);
94
95 #ifdef WITH_NTFS_3G
96 /* ntfs-3g_capture.c */
97 extern int
98 ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret,
99                           const tchar *device, struct scan_params *params);
100 #endif
101
102 #ifdef __WIN32__
103 /* win32_capture.c */
104 extern int
105 win32_build_dentry_tree(struct wim_dentry **root_ret,
106                         const tchar *root_disk_path,
107                         struct scan_params *params);
108 #define platform_default_scan_tree win32_build_dentry_tree
109 #else
110 /* unix_capture.c */
111 extern int
112 unix_build_dentry_tree(struct wim_dentry **root_ret,
113                        const tchar *root_disk_path, struct scan_params *params);
114 #define platform_default_scan_tree unix_build_dentry_tree
115 #endif
116
117 #define WIMLIB_ADD_FLAG_ROOT    0x80000000
118
119 static inline int
120 report_scan_error(struct scan_params *params, int error_code, const tchar *path)
121 {
122         return report_error(params->progfunc, params->progctx, error_code, path);
123 }
124
125 extern bool
126 should_ignore_filename(const tchar *name, int name_nchars);
127
128 extern void
129 attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child,
130                     struct blob_table *blob_table);
131
132 #endif /* _WIMLIB_SCAN_H */