]> wimlib.net Git - wimlib/blob - include/wimlib/capture.h
extract.c: replace tempnam() with mkstemp() on non-Windows
[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         /* If non-NULL, the user-supplied progress function. */
46         wimlib_progress_func_t progfunc;
47         void *progctx;
48
49         /* Progress data.  */
50         union wimlib_progress_info progress;
51
52         /* The capture implementation must set this to the number of characters
53          * that try_exclude() will strip from the path before testing exclusion
54          * patterns from the capture configuration file.  */
55         size_t capture_root_nchars;
56
57         /* Can be used by the capture implementation.  */
58         u64 capture_root_ino;
59         u64 capture_root_dev;
60 };
61
62 /* capture_common.c */
63
64 extern int
65 do_capture_progress(struct capture_params *params, int status,
66                     const struct wim_inode *inode);
67
68 extern int
69 mangle_pat(tchar *pat, const tchar *path, unsigned long line_no);
70
71 extern int
72 read_capture_config(const tchar *config_file, const void *buf,
73                     size_t bufsize, struct capture_config *config);
74
75 extern void
76 destroy_capture_config(struct capture_config *config);
77
78 extern bool
79 match_pattern_list(const tchar *path, const struct string_set *list);
80
81 extern int
82 try_exclude(const tchar *full_path, const struct capture_params *params);
83
84 typedef int (*capture_tree_t)(struct wim_dentry **, const tchar *,
85                               struct capture_params *);
86
87 #ifdef WITH_NTFS_3G
88 /* ntfs-3g_capture.c */
89 extern int
90 ntfs_3g_build_dentry_tree(struct wim_dentry **root_ret,
91                           const tchar *device,
92                           struct capture_params *params);
93 #endif
94
95 #ifdef __WIN32__
96 /* win32_capture.c */
97 extern int
98 win32_build_dentry_tree(struct wim_dentry **root_ret,
99                         const tchar *root_disk_path,
100                         struct capture_params *params);
101 #define platform_default_capture_tree win32_build_dentry_tree
102 #else
103 /* unix_capture.c */
104 extern int
105 unix_build_dentry_tree(struct wim_dentry **root_ret,
106                        const tchar *root_disk_path,
107                        struct capture_params *params);
108 #define platform_default_capture_tree unix_build_dentry_tree
109 #endif
110
111 #define WIMLIB_ADD_FLAG_ROOT    0x80000000
112
113 static inline int
114 report_capture_error(struct capture_params *params, int error_code,
115                      const tchar *path)
116 {
117         return report_error(params->progfunc, params->progctx, error_code, path);
118 }
119
120 extern bool
121 should_ignore_filename(const tchar *name, int name_nchars);
122
123 extern void
124 attach_scanned_tree(struct wim_dentry *parent, struct wim_dentry *child,
125                     struct blob_table *blob_table);
126
127 #endif /* _WIMLIB_CAPTURE_H */