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