]> wimlib.net Git - wimlib/blob - include/wimlib/capture.h
Support for file exclusions via progress function
[wimlib] / include / wimlib / capture.h
1 #ifndef _WIMLIB_CAPTURE_H
2 #define _WIMLIB_CAPTURE_H
3
4 #include "wimlib.h"
5 #include "wimlib/inode_table.h"
6 #include "wimlib/list.h"
7 #include "wimlib/security.h"
8 #include "wimlib/textfile.h"
9 #include "wimlib/util.h"
10
11 struct wim_lookup_table;
12 struct wim_dentry;
13 struct wim_inode;
14
15 struct capture_config {
16         struct string_set exclusion_pats;
17         struct string_set exclusion_exception_pats;
18         void *buf;
19 };
20
21 /* Common parameters to implementations of building an in-memory dentry tree
22  * from an on-disk directory structure. */
23 struct add_image_params {
24         /* Pointer to the lookup table of the WIM.  */
25         struct wim_lookup_table *lookup_table;
26
27         /* List of streams that have been added so far, but without their SHA1
28          * message digests being calculated (as a shortcut).  */
29         struct list_head *unhashed_streams;
30
31         /* Hash table of inodes that have been captured for this tree so far. */
32         struct wim_inode_table *inode_table;
33
34         /* The set of security descriptors that have been captured for this
35          * image so far. */
36         struct wim_sd_set *sd_set;
37
38         /* Pointer to the capture configuration.  */
39         struct capture_config *config;
40
41         /* Flags that affect the capture operation (WIMLIB_ADD_FLAG_*) */
42         int add_flags;
43
44         /* Extra argument; set to point to a pointer to the ntfs_volume for
45          * libntfs-3g capture.  */
46         void *extra_arg;
47
48         /* If non-NULL, the user-supplied progress function. */
49         wimlib_progress_func_t progfunc;
50         void *progctx;
51
52         /* Progress data.  */
53         union wimlib_progress_info progress;
54
55         /* The capture implementation must set this to the number of characters
56          * that try_exclude() will strip from the path before testing exclusion
57          * patterns from the capture configuration file.  */
58         size_t capture_root_nchars;
59
60         /* Can be used by the capture implementation.  */
61         u64 capture_root_ino;
62         u64 capture_root_dev;
63 };
64
65 /* capture_common.c */
66
67 extern int
68 do_capture_progress(struct add_image_params *params, int status,
69                     const struct wim_inode *inode);
70
71 extern int
72 mangle_pat(tchar *pat, const tchar *path, unsigned long line_no);
73
74 extern int
75 read_capture_config(const tchar *config_file, const void *buf,
76                     size_t bufsize, struct capture_config *config);
77
78 extern void
79 destroy_capture_config(struct capture_config *config);
80
81 extern bool
82 match_pattern_list(const tchar *path, size_t path_nchars,
83                    const struct string_set *list);
84
85 extern int
86 try_exclude(const tchar *full_path, size_t full_path_nchars,
87             const struct add_image_params *params);
88
89 typedef int (*capture_tree_t)(struct wim_dentry **, const tchar *,
90                               struct add_image_params *);
91
92 #ifdef WITH_NTFS_3G
93 /* ntfs-3g_capture.c */
94 extern int
95 build_dentry_tree_ntfs(struct wim_dentry **root_p,
96                        const tchar *device,
97                        struct add_image_params *params);
98 #endif
99
100 #ifdef __WIN32__
101 /* win32_capture.c */
102 extern int
103 win32_build_dentry_tree(struct wim_dentry **root_ret,
104                         const tchar *root_disk_path,
105                         struct add_image_params *params);
106 #define platform_default_capture_tree win32_build_dentry_tree
107 #else
108 /* unix_capture.c */
109 extern int
110 unix_build_dentry_tree(struct wim_dentry **root_ret,
111                        const tchar *root_disk_path,
112                        struct add_image_params *params);
113 #define platform_default_capture_tree unix_build_dentry_tree
114 #endif
115
116 #define WIMLIB_ADD_FLAG_ROOT    0x80000000
117
118 #endif /* _WIMLIB_CAPTURE_H */