+extern int
+for_dentry_in_tree_depth(struct wim_dentry *root,
+ int (*visitor)(struct wim_dentry*, void*),
+ void *args);
+
+extern void
+calculate_subdir_offsets(struct wim_dentry *dentry, u64 *subdir_offset_p);
+
+extern int
+set_dentry_name(struct wim_dentry *dentry, const tchar *new_name);
+
+extern struct wim_dentry *
+get_dentry(struct WIMStruct *w, const tchar *path);
+
+extern struct wim_inode *
+wim_pathname_to_inode(struct WIMStruct *w, const tchar *path);
+
+extern struct wim_dentry *
+get_dentry_child_with_name(const struct wim_dentry *dentry,
+ const tchar *name);
+
+extern struct wim_dentry *
+get_dentry_child_with_utf16le_name(const struct wim_dentry *dentry,
+ const utf16lechar *name,
+ size_t name_nbytes);
+
+extern struct wim_dentry *
+get_parent_dentry(struct WIMStruct *w, const tchar *path);
+
+extern int
+print_dentry(struct wim_dentry *dentry, void *lookup_table);
+
+extern int
+print_dentry_full_path(struct wim_dentry *entry, void *ignore);
+
+extern int
+calculate_dentry_tree_full_paths(struct wim_dentry *root);
+
+extern tchar *
+dentry_full_path(struct wim_dentry *dentry);
+
+extern struct wim_inode *
+new_timeless_inode();
+
+extern int
+new_dentry(const tchar *name, struct wim_dentry **dentry_ret);
+
+extern int
+new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret);
+
+extern int
+new_dentry_with_timeless_inode(const tchar *name, struct wim_dentry **dentry_ret);
+
+extern void
+free_inode(struct wim_inode *inode);
+
+extern void
+free_dentry(struct wim_dentry *dentry);
+
+extern void
+put_dentry(struct wim_dentry *dentry);
+
+extern void
+free_dentry_tree(struct wim_dentry *root,
+ struct wim_lookup_table *lookup_table);
+
+extern void
+unlink_dentry(struct wim_dentry *dentry);
+
+extern struct wim_dentry *
+dentry_add_child(struct wim_dentry * restrict parent,
+ struct wim_dentry * restrict child);
+
+extern struct wim_ads_entry *
+inode_get_ads_entry(struct wim_inode *inode, const tchar *stream_name,
+ u16 *idx_ret);
+
+extern struct wim_ads_entry *
+inode_add_ads_utf16le(struct wim_inode *inode,
+ const utf16lechar *stream_name,
+ size_t stream_name_nbytes);
+
+extern struct wim_ads_entry *
+inode_add_ads(struct wim_inode *dentry, const tchar *stream_name);
+
+extern int
+inode_add_ads_with_data(struct wim_inode *inode, const tchar *name,
+ const void *value, size_t size,
+ struct wim_lookup_table *lookup_table);
+
+extern int
+inode_set_unnamed_stream(struct wim_inode *inode, const void *data, size_t len,
+ struct wim_lookup_table *lookup_table);
+
+extern void
+inode_remove_ads(struct wim_inode *inode, u16 idx,
+ struct wim_lookup_table *lookup_table);
+
+
+#define WIMLIB_UNIX_DATA_TAG "$$__wimlib_UNIX_data"
+#define WIMLIB_UNIX_DATA_TAG_NBYTES (sizeof(WIMLIB_UNIX_DATA_TAG) - 1)
+
+#define WIMLIB_UNIX_DATA_TAG_UTF16LE "$\0$\0_\0_\0w\0i\0m\0l\0i\0b\0_\0U\0N\0I\0X\0_\0d\0a\0t\0a\0"
+#define WIMLIB_UNIX_DATA_TAG_UTF16LE_NBYTES (sizeof(WIMLIB_UNIX_DATA_TAG_UTF16LE) - 1)
+
+/* Format for special alternate data stream entries to store UNIX data for files
+ * and directories (see: WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA) */
+struct wimlib_unix_data {
+ u16 version; /* Must be 0 */
+ u16 uid;
+ u16 gid;
+ u16 mode;
+} PACKED;
+
+#ifndef __WIN32__
+
+#define NO_UNIX_DATA (-1)
+#define BAD_UNIX_DATA (-2)
+extern int
+inode_get_unix_data(const struct wim_inode *inode,
+ struct wimlib_unix_data *unix_data,
+ u16 *stream_idx_ret);
+
+#define UNIX_DATA_UID 0x1
+#define UNIX_DATA_GID 0x2
+#define UNIX_DATA_MODE 0x4
+#define UNIX_DATA_ALL (UNIX_DATA_UID | UNIX_DATA_GID | UNIX_DATA_MODE)
+#define UNIX_DATA_CREATE 0x8
+extern int
+inode_set_unix_data(struct wim_inode *inode, uid_t uid, gid_t gid, mode_t mode,
+ struct wim_lookup_table *lookup_table, int which);
+#endif
+
+extern int
+read_dentry(const u8 metadata_resource[], u64 metadata_resource_len,
+ u64 offset, struct wim_dentry *dentry);
+
+
+extern int
+read_dentry_tree(const u8 metadata_resource[], u64 metadata_resource_len,
+ struct wim_dentry *dentry);
+
+extern u8 *
+write_dentry_tree(const struct wim_dentry *tree, u8 *p);
+
+static inline bool
+dentry_is_root(const struct wim_dentry *dentry)