]> wimlib.net Git - wimlib/blob - include/wimlib/capture.h
9f9e4617fb44111b3fdcc3f2bfffdb84a7072666
[wimlib] / include / wimlib / capture.h
1 #ifndef _WIMLIB_CAPTURE_H
2 #define _WIMLIB_CAPTURE_H
3
4 #include "wimlib.h"
5 #include "wimlib/list.h"
6 #include "wimlib/security.h"
7 #include "wimlib/util.h"
8
9 struct wim_lookup_table;
10 struct wim_dentry;
11 struct wim_inode;
12
13 /* Hash table to find inodes, given an inode number (in the case of reading
14  * a WIM images), or both an inode number and a device number (in the case of
15  * capturing a WIM image). */
16 struct wim_inode_table {
17         /* Fields for the hash table */
18         struct hlist_head *array;
19         u64 num_entries;
20         u64 capacity;
21
22         /*
23          * Linked list of "extra" inodes.  These may be:
24          *
25          * - inodes with link count 1, which are all allowed to have 0 for their
26          *   inode number, meaning we cannot insert them into the hash table.
27          *
28          * - Groups we create ourselves by splitting a nominal inode due to
29          *   inconsistencies in the dentries.  These inodes will share an inode
30          *   number with some other inode until assign_inode_numbers() is
31          *   called.
32          */
33         struct list_head extra_inodes;
34 };
35
36 /* Common parameters to implementations of building an in-memory dentry tree
37  * from an on-disk directory structure. */
38 struct add_image_params {
39         /* Pointer to the lookup table of the WIM. */
40         struct wim_lookup_table *lookup_table;
41
42         /* Hash table of inodes that have been captured for this tree so far. */
43         struct wim_inode_table inode_table;
44
45         /* The set of security descriptors that have been captured for this
46          * image so far. */
47         struct wim_sd_set sd_set;
48
49         /* Pointer to the capture configuration, which indicates whether any
50          * files should be excluded from capture or not. */
51         struct wimlib_capture_config *config;
52
53         /* Flags that affect the capture operation (WIMLIB_ADD_FLAG_*) */
54         int add_flags;
55
56         /* Extra argument; set to point to a pointer to the ntfs_volume for
57          * libntfs-3g capture.  */
58         void *extra_arg;
59
60         u64 capture_root_ino;
61         u64 capture_root_dev;
62
63         /* If non-NULL, the user-supplied progress function. */
64         wimlib_progress_func_t progress_func;
65
66         /* Progress data.  */
67         union wimlib_progress_info progress;
68 };
69
70
71 /* capture_common.c */
72
73 extern void
74 do_capture_progress(struct add_image_params *params, int status,
75                     const struct wim_inode *inode);
76
77 extern bool
78 exclude_path(const tchar *path, size_t path_len,
79              const struct wimlib_capture_config *config,
80              bool exclude_prefix);
81
82 extern struct wimlib_capture_config *
83 copy_capture_config(const struct wimlib_capture_config *config);
84
85 extern int
86 copy_and_canonicalize_capture_config(const struct wimlib_capture_config *config,
87                                      struct wimlib_capture_config **config_copy_ret);
88
89 extern void
90 free_capture_config(struct wimlib_capture_config *config);
91
92 /* hardlink.c */
93
94 extern int
95 init_inode_table(struct wim_inode_table *table, size_t capacity);
96
97 extern int
98 inode_table_new_dentry(struct wim_inode_table *table, const tchar *name,
99                        u64 ino, u64 devno, bool noshare,
100                        struct wim_dentry **dentry_ret);
101
102 extern void
103 inode_table_prepare_inode_list(struct wim_inode_table *table,
104                                struct list_head *head);
105
106 static inline void
107 destroy_inode_table(struct wim_inode_table *table)
108 {
109         FREE(table->array);
110 }
111
112
113 #ifdef WITH_NTFS_3G
114 /* ntfs-3g_capture.c */
115 extern int
116 build_dentry_tree_ntfs(struct wim_dentry **root_p,
117                        const tchar *device,
118                        struct add_image_params *params);
119 #endif
120
121 #ifdef __WIN32__
122 /* win32_capture.c */
123 extern int
124 win32_build_dentry_tree(struct wim_dentry **root_ret,
125                         const tchar *root_disk_path,
126                         struct add_image_params *params);
127 #else
128 /* unix_capture.c */
129 extern int
130 unix_build_dentry_tree(struct wim_dentry **root_ret,
131                        const tchar *root_disk_path,
132                        struct add_image_params *params);
133 #endif
134
135 #define WIMLIB_ADD_FLAG_ROOT    0x80000000
136
137 #endif /* _WIMLIB_CAPTURE_H */