X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdentry.h;h=1500bd7c3c63238ff07baeadb0b59ddb2c9d33be;hp=dfbcafca9b4b6c32c9f4aba510f4a542c1edfb3f;hb=36fae332ff07defaf465c363c56bc0274550b86c;hpb=14baa6ae892debbaa18dba8119931580efd0e517 diff --git a/src/dentry.h b/src/dentry.h index dfbcafca..1500bd7c 100644 --- a/src/dentry.h +++ b/src/dentry.h @@ -78,14 +78,16 @@ struct wim_ads_entry { * terminating null character. */ u16 stream_name_nbytes; - /* Stream name (UTF-16LE) */ - utf16lechar *stream_name; - -#ifdef WITH_FUSE /* Number to identify an alternate data stream even after it's possibly * been moved or renamed. */ u32 stream_id; -#endif + + /* Stream name (UTF-16LE) */ + utf16lechar *stream_name; + + /* Unused field. We read it into memory so we can write it out + * unchanged. */ + u64 unused; }; @@ -141,10 +143,12 @@ struct wim_dentry { * the terminating null character. */ u16 file_name_nbytes; - /* Length of full path name, in bytes, as a multibyte-encoded string */ + /* Length of full path name encoded using "tchars", in bytes, not + * including the terminating null character. */ u32 full_path_nbytes; - u8 is_extracted : 1; + /* Does this dentry need to be extracted? */ + u8 needs_extraction : 1; /* Only used during NTFS capture */ u8 is_win32_name : 1; @@ -184,10 +188,6 @@ struct wim_dentry { * points. */ u64 subdir_offset; - /* Number of references to the dentry tree itself, as in multiple - * WIMStructs */ - u32 refcnt; - /* Pointer to the UTF-16LE short filename (malloc()ed buffer) */ utf16lechar *short_name; @@ -195,7 +195,7 @@ struct wim_dentry { utf16lechar *file_name; /* Full path of this dentry */ - mbchar *full_path; + tchar *_full_path; }; #define rbnode_dentry(node) container_of(node, struct wim_dentry, rb_node) @@ -235,9 +235,21 @@ struct wim_inode { /* Used only in NTFS-mode extraction */ u8 i_dos_name_extracted : 1; + /* Set to 0 if reparse point fixups have been done. Otherwise set to 1. + * + * Note: this actually may reflect the SYMBOLIC_LINK_RELATIVE flag. */ + u16 i_not_rpfixed; + /* Number of alternate data streams associated with this inode */ u16 i_num_ads; + /* Unused/unknown fields that we just read into memory so we can + * re-write them unchanged. */ + u64 i_unused_1; + u64 i_unused_2; + u32 i_rp_unknown_1; + u16 i_rp_unknown_2; + /* A hash of the file's contents, or a pointer to the lookup table entry * for this dentry if the lookup table entries have been resolved. * @@ -263,30 +275,33 @@ struct wim_inode { /* Inode number */ u64 i_ino; + /* Device number, used only during image capture */ + u64 i_devno; + /* List of dentries that reference this inode (there should be * link_count of them) */ struct list_head i_dentry; - struct hlist_node i_hlist; - - struct list_head i_lte_inode_list; + union { + struct hlist_node i_hlist; + struct list_head i_list; + }; - mbchar *i_extracted_file; + tchar *i_extracted_file; /* Root of a red-black tree storing the children of this inode (if * non-empty, implies the inode is a directory, although that is also * noted in the @attributes field.) */ struct rb_root i_children; + /* Next alternate data stream ID to be assigned */ + u32 i_next_stream_id; + #ifdef WITH_FUSE /* wimfs file descriptors table for the inode */ u16 i_num_opened_fds; u16 i_num_allocated_fds; struct wimfs_fd **i_fds; - - /* Next alternate data stream ID to be assigned */ - u32 i_next_stream_id; - /* This mutex protects the inode's file descriptors table during * read-only mounts. Read-write mounts are still restricted to 1 * thread. */ @@ -337,31 +352,29 @@ for_dentry_in_tree_depth(struct wim_dentry *root, int (*visitor)(struct wim_dentry*, void*), void *args); -extern int -calculate_dentry_full_path(struct wim_dentry *dentry, void *ignore); - extern void calculate_subdir_offsets(struct wim_dentry *dentry, u64 *subdir_offset_p); extern int -set_dentry_name(struct wim_dentry *dentry, const mbchar *new_name); +set_dentry_name(struct wim_dentry *dentry, const tchar *new_name); extern struct wim_dentry * -get_dentry(struct WIMStruct *w, const mbchar *path); +get_dentry(struct WIMStruct *w, const tchar *path); extern struct wim_inode * -wim_pathname_to_inode(struct WIMStruct *w, const mbchar *path); +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 mbchar *name); + const tchar *name); extern struct wim_dentry * get_dentry_child_with_utf16le_name(const struct wim_dentry *dentry, - const utf16lechar *name); + const utf16lechar *name, + size_t name_nbytes); extern struct wim_dentry * -get_parent_dentry(struct WIMStruct *w, const mbchar *path); +get_parent_dentry(struct WIMStruct *w, const tchar *path); extern int print_dentry(struct wim_dentry *dentry, void *lookup_table); @@ -369,14 +382,26 @@ print_dentry(struct wim_dentry *dentry, void *lookup_table); extern int print_dentry_full_path(struct wim_dentry *entry, void *ignore); -extern struct -wim_dentry *new_dentry(const mbchar *name); +extern int +calculate_dentry_tree_full_paths(struct wim_dentry *root); + +extern tchar * +dentry_full_path(struct wim_dentry *dentry); -extern struct wim_dentry * -new_dentry_with_inode(const mbchar *name); +extern struct wim_inode * +new_timeless_inode(); -extern struct wim_dentry * -new_dentry_with_timeless_inode(const mbchar *name); +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 int +new_filler_directory(const tchar *name, struct wim_dentry **dentry_ret); extern void free_inode(struct wim_inode *inode); @@ -391,38 +416,47 @@ extern void free_dentry_tree(struct wim_dentry *root, struct wim_lookup_table *lookup_table); -extern int -increment_dentry_refcnt(struct wim_dentry *dentry, void *ignore); - extern void unlink_dentry(struct wim_dentry *dentry); -extern bool +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 mbchar *stream_name, +inode_get_ads_entry(struct wim_inode *inode, const tchar *stream_name, u16 *idx_ret); extern struct wim_ads_entry * -inode_add_ads(struct wim_inode *dentry, const mbchar *stream_name); +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 mbchar *name, +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_LEN (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) */ + * and directories (see: WIMLIB_ADD_FLAG_UNIX_DATA) */ struct wimlib_unix_data { u16 version; /* Must be 0 */ u16 uid; @@ -486,8 +520,8 @@ static inline bool inode_is_symlink(const struct wim_inode *inode) { return (inode->i_attributes & FILE_ATTRIBUTE_REPARSE_POINT) - && ((inode->i_reparse_tag == WIM_IO_REPARSE_TAG_SYMLINK) || - inode->i_reparse_tag == WIM_IO_REPARSE_TAG_MOUNT_POINT); + && (inode->i_reparse_tag == WIM_IO_REPARSE_TAG_SYMLINK || + inode->i_reparse_tag == WIM_IO_REPARSE_TAG_MOUNT_POINT); } static inline bool @@ -514,4 +548,16 @@ dentry_has_children(const struct wim_dentry *dentry) return inode_has_children(dentry->d_inode); } +static inline bool +dentry_has_short_name(const struct wim_dentry *dentry) +{ + return dentry->short_name_nbytes != 0; +} + +static inline bool +dentry_has_long_name(const struct wim_dentry *dentry) +{ + return dentry->file_name_nbytes != 0; +} + #endif