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