+static int set_dentry_dos_name(struct wim_dentry *dentry, void *arg)
+{
+ const struct dos_name_map *map = arg;
+ const struct dos_name_node *node;
+
+ if (dentry->is_win32_name) {
+ node = lookup_dos_name(map, dentry->d_inode->i_ino);
+ if (node) {
+ dentry->short_name = MALLOC(node->name_len_bytes);
+ if (!dentry->short_name)
+ return WIMLIB_ERR_NOMEM;
+ memcpy(dentry->short_name, node->dos_name,
+ node->name_len_bytes);
+ dentry->short_name_len = node->name_len_bytes;
+ DEBUG("Assigned DOS name to ino %"PRIu64,
+ dentry->d_inode->i_ino);
+ } else {
+ WARNING("NTFS inode %"PRIu64" has Win32 name with no "
+ "corresponding DOS name",
+ dentry->d_inode->i_ino);
+ }
+ }
+ return 0;
+}
+
+static void free_dos_name_tree(struct rb_node *node) {
+ if (node) {
+ free_dos_name_tree(node->rb_left);
+ free_dos_name_tree(node->rb_right);
+ FREE(container_of(node, struct dos_name_node, rb_node));
+ }
+}
+
+static void destroy_dos_name_map(struct dos_name_map *map)
+{
+ free_dos_name_tree(map->rb_root.rb_node);
+}
+
+struct readdir_ctx {
+ struct wim_dentry *parent;
+ ntfs_inode *dir_ni;
+ char *path;
+ size_t path_len;
+ struct wim_lookup_table *lookup_table;
+ struct sd_set *sd_set;
+ struct dos_name_map *dos_name_map;
+ const struct capture_config *config;
+ ntfs_volume **ntfs_vol_p;
+ int add_image_flags;
+ wimlib_progress_func_t progress_func;
+};
+
+static int
+build_dentry_tree_ntfs_recursive(struct wim_dentry **root_p, ntfs_inode *dir_ni,
+ ntfs_inode *ni, char path[], size_t path_len,
+ int name_type,
+ struct wim_lookup_table *lookup_table,
+ struct sd_set *sd_set,
+ const struct capture_config *config,
+ ntfs_volume **ntfs_vol_p,
+ int add_image_flags,
+ wimlib_progress_func_t progress_func);
+
+static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name,
+ const int name_len, const int name_type,
+ const s64 pos, const MFT_REF mref,
+ const unsigned dt_type)