1 #ifndef _WIMLIB_APPLY_H
2 #define _WIMLIB_APPLY_H
4 #include "wimlib/types.h"
5 #include "wimlib/list.h"
8 struct wim_lookup_table_entry;
9 struct wimlib_unix_data;
13 /* Path to extracted file, or "cookie" identifying the file (e.g. inode number).
21 * struct apply_operations - Callback functions for a specific extraction
22 * mode/backend. These are lower-level functions that are called by the generic
25 * Unless otherwise specified, the callbacks in this structure are expected to
26 * return 0 on success or a WIMLIB_ERR_* value on failure as well as set errno.
27 * When possible, error messages should NOT be printed as they are handled by
30 * Many callbacks are optional, but to extract the most data from the WIM
31 * format, as many as possible should be provided, and the corresponding
32 * features should be marked as supported in start_extract().
34 struct apply_operations {
36 /* OPTIONAL: Name of this extraction mode. */
39 /* REQUIRED: Fill in ctx->supported_features with nonzero values for
40 * features supported by the extraction mode and volume. This callback
41 * can also be used to do any setup needed to access the volume. */
43 (const tchar *path, struct apply_ctx *ctx);
45 /* OPTIONAL: If root_directory_is_special is set: provide this
46 * callback to determine whether the path corresponds to the root of the
47 * target volume (%true) or not (%false). */
48 bool (*target_is_root)
49 (const tchar *target);
51 /* REQUIRED: Create a file. */
53 (const tchar *path, struct apply_ctx *ctx, u64 *cookie_ret);
55 /* REQUIRED: Create a directory. */
56 int (*create_directory)
57 (const tchar *path, struct apply_ctx *ctx, u64 *cookie_ret);
59 /* OPTIONAL: Create a hard link. In start_extract(), set
60 * ctx->supported_features.hard_links if supported. */
61 int (*create_hardlink)
62 (const tchar *oldpath, const tchar *newpath,
63 struct apply_ctx *ctx);
65 /* OPTIONAL: Create a symbolic link. In start_extract(), set
66 * ctx->supported_features.symlink_reparse_points if supported. */
68 (const tchar *oldpath, const tchar *newpath,
69 struct apply_ctx *ctx);
71 /* REQUIRED: Extract unnamed data stream. */
72 int (*extract_unnamed_stream)
73 (file_spec_t file, struct wim_lookup_table_entry *lte,
74 struct apply_ctx *ctx);
76 /* OPTIONAL: Extracted named data stream. In start_extract(), set
77 * ctx->supported_features.alternate_data_streams if supported. */
78 int (*extract_named_stream)
79 (file_spec_t file, const utf16lechar *stream_name,
80 size_t stream_name_nchars, struct wim_lookup_table_entry *lte,
81 struct apply_ctx *ctx);
83 /* OPTIONAL: Extracted encrypted stream. In start_extract(), set
84 * ctx->supported_features.encrypted_files if supported. */
85 int (*extract_encrypted_stream)
86 (file_spec_t file, struct wim_lookup_table_entry *lte,
87 struct apply_ctx *ctx);
89 /* OPTIONAL: Set file attributes. Calling code calls this if non-NULL.
91 int (*set_file_attributes)
92 (const tchar *path, u32 attributes, struct apply_ctx *ctx);
94 /* OPTIONAL: Set reparse data. In start_extract(), set
95 * ctx->supported_features.reparse_data if supported. */
96 int (*set_reparse_data)
97 (const tchar *path, const u8 *rpbuf, u16 rpbuflen,
98 struct apply_ctx *ctx);
100 /* OPTIONAL: Set short (DOS) filename. In start_extract(), set
101 * ctx->supported_features.short_name if supported. */
102 int (*set_short_name)
103 (const tchar *path, const utf16lechar *short_name,
104 size_t short_name_nchars, struct apply_ctx *ctx);
106 /* OPTIONAL: Set Windows NT security descriptor. In start_extract(),
107 * set ctx->supported_features.security_descriptors if supported. */
108 int (*set_security_descriptor)
109 (const tchar *path, const u8 *desc, size_t desc_size,
110 struct apply_ctx *ctx);
112 /* OPTIONAL: Set wimlib-specific UNIX data. In start_extract(), set
113 * ctx->supported_features.unix_data if supported. */
115 (const tchar *path, const struct wimlib_unix_data *data,
116 struct apply_ctx *ctx);
118 /* OPTIONAL: Set timestamps. Calling code calls this if non-NULL. */
119 int (*set_timestamps)
120 (const tchar *path, u64 creation_time, u64 last_write_time,
121 u64 last_access_time, struct apply_ctx *ctx);
123 /* OPTIONAL: Called after the extraction operation has succeeded. */
124 int (*finish_extract)
125 (struct apply_ctx *ctx);
127 /* OPTIONAL: Called after the extraction operation has failed. */
129 (struct apply_ctx *ctx);
131 /* REQUIRED: Path separator character to use when building paths. */
132 tchar path_separator;
134 /* REQUIRED: Maximum path length, in tchars, including the
135 * null-terminator. */
138 /* OPTIONAL: String to prefix every path with. */
139 const tchar *path_prefix;
141 /* OPTIONAL: Length of path_prefix in tchars. */
142 unsigned path_prefix_nchars;
144 /* OPTIONAL: Set to 1 if paths must be prefixed by the name of the
145 * extraction target (i.e. if it's interpreted as a directory). */
146 unsigned requires_target_in_paths : 1;
148 /* OPTIONAL: Like above, but operations require real (absolute) path.
150 unsigned requires_realtarget_in_paths : 1;
152 /* OPTIONAL: Set to 1 if realpath() can be used to get the real
153 * (absolute) path of a file on the target volume before it's been
155 unsigned realpath_works_on_nonexisting_files : 1;
157 /* OPTIONAL: Set to 1 if this extraction mode supports case sensitive
159 unsigned supports_case_sensitive_filenames : 1;
161 /* OPTIONAL: Set to 1 if the root directory of the volume (see
162 * target_is_root() callback) should not be explicitly extracted. */
163 unsigned root_directory_is_special : 1;
165 /* OPTIONAL: Set to 1 if extraction cookie, or inode number, is stored
166 * in create_file() and create_directory() callbacks. This cookie will
167 * then be passed to callbacks taking a 'file_spec_t', rather than the
169 unsigned uses_cookies : 1;
172 struct wim_features {
173 unsigned long archive_files;
174 unsigned long hidden_files;
175 unsigned long system_files;
176 unsigned long compressed_files;
177 unsigned long encrypted_files;
178 unsigned long encrypted_directories;
179 unsigned long not_context_indexed_files;
180 unsigned long sparse_files;
181 unsigned long named_data_streams;
182 unsigned long hard_links;
183 unsigned long reparse_points;
184 unsigned long symlink_reparse_points;
185 unsigned long other_reparse_points;
186 unsigned long security_descriptors;
187 unsigned long short_names;
188 unsigned long unix_data;
191 /* Context for an apply (extract) operation. */
196 size_t target_nchars;
197 wimlib_progress_func_t progress_func;
198 union wimlib_progress_info progress;
199 struct wim_dentry *extract_root;
200 const struct apply_operations *ops;
201 struct wim_features supported_features;
202 u32 supported_attributes_mask;
203 struct list_head stream_list;
205 size_t realtarget_nchars;
206 unsigned long invalid_sequence;
207 u64 num_streams_remaining;
208 bool root_dentry_is_special;
209 uint64_t next_progress;
214 extern const struct apply_operations win32_apply_ops;
216 extern const struct apply_operations unix_apply_ops;
220 extern const struct apply_operations ntfs_3g_apply_ops;
223 #endif /* _WIMLIB_APPLY_H */