X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fdentry.h;h=76087320d52ab46bc4928eefcf29677cb295755f;hp=5c1c1aad7c17230d48cce3b918e311b80d4fb669;hb=2a33c303e30fd740f740e21632fd06b9e414b0c7;hpb=1530b6dab02a9e1e5faf81529ab502aee68d8cd2 diff --git a/src/dentry.h b/src/dentry.h index 5c1c1aad..76087320 100644 --- a/src/dentry.h +++ b/src/dentry.h @@ -64,7 +64,7 @@ struct wim_dentry; * * We read this from disk in the read_ads_entries() function; see that function * for more explanation. */ -struct ads_entry { +struct wim_ads_entry { union { /* SHA-1 message digest of stream contents */ u8 hash[SHA1_HASH_SIZE]; @@ -95,8 +95,8 @@ struct ads_entry { }; -static inline bool ads_entries_have_same_name(const struct ads_entry *entry_1, - const struct ads_entry *entry_2) +static inline bool ads_entries_have_same_name(const struct wim_ads_entry *entry_1, + const struct wim_ads_entry *entry_2) { if (entry_1->stream_name_len != entry_2->stream_name_len) return false; @@ -110,8 +110,9 @@ static inline bool ads_entries_have_same_name(const struct ads_entry *entry_1, * * Note that this is a directory entry and not an inode. Since NTFS allows hard * links, it's possible for a NTFS inode to correspond to multiple WIM dentries. - * The hard_link field on the on-disk WIM dentry tells us the number of the NTFS - * inode that the dentry corresponds to. + * The hard link group ID field of the on-disk WIM dentry tells us the number of + * the NTFS inode that the dentry corresponds to (and this gets placed in + * d_inode->i_ino). * * Unfortunately, WIM files do not have an analogue to an inode; instead certain * information, such as file attributes, the security descriptor, and file @@ -128,8 +129,8 @@ static inline bool ads_entries_have_same_name(const struct ads_entry *entry_1, * file streams when they share the same hard link ID (don't even ask. I hope * that Microsoft may have fixed this problem, since I've only noticed it in the * 'install.wim' for Windows 7). For those dentries, we have to use the - * conflicting fields to split up the hard link groups. (See fix_inodes() in - * hardlink.c). + * conflicting fields to split up the hard link groups. (See + * dentry_tree_fix_inodes() in hardlink.c). */ struct wim_dentry { /* Byte 0 */ @@ -158,6 +159,9 @@ struct wim_dentry { u8 is_extracted : 1; + /* Only used during NTFS capture */ + u8 is_win32_name : 1; + /* Byte 40 */ /* Pointer to the filename converted to UTF-8 (malloc()ed buffer). */ @@ -251,6 +255,9 @@ struct wim_inode { /* %true iff verify_inode() has run on this inode. */ u8 i_verified : 1; + /* Used only in NTFS-mode extraction */ + u8 i_dos_name_extracted : 1; + /* Number of alternate data streams associated with this inode */ u16 i_num_ads; @@ -274,7 +281,7 @@ struct wim_inode { u32 i_nlink; /* Alternate data stream entries. */ - struct ads_entry *i_ads_entries; + struct wim_ads_entry *i_ads_entries; /* Inode number */ u64 i_ino; @@ -316,10 +323,8 @@ struct wim_inode { #define inode_add_dentry(dentry, inode) \ list_add_tail(&(dentry)->d_alias, &(inode)->i_dentry) -static inline struct wim_dentry *inode_first_dentry(struct wim_inode *inode) -{ - return container_of(inode->i_dentry.next, struct wim_dentry, d_alias); -} +#define inode_first_dentry(inode) \ + container_of(inode->i_dentry.next, struct wim_dentry, d_alias) static inline bool dentry_is_first_in_inode(const struct wim_dentry *dentry) { @@ -336,6 +341,15 @@ extern int for_dentry_in_rbtree(struct rb_node *node, int (*visitor)(struct wim_dentry *, void *), void *arg); +static inline int for_dentry_child(const struct wim_dentry *dentry, + int (*visitor)(struct wim_dentry *, void *), + void *arg) +{ + return for_dentry_in_rbtree(dentry->d_inode->i_children.rb_node, + visitor, + arg); +} + extern int for_dentry_in_tree_depth(struct wim_dentry *root, int (*visitor)(struct wim_dentry*, void*), void *args); @@ -345,11 +359,15 @@ extern void calculate_subdir_offsets(struct wim_dentry *dentry, u64 *subdir_offs extern int set_dentry_name(struct wim_dentry *dentry, const char *new_name); extern struct wim_dentry *get_dentry(struct WIMStruct *w, const char *path); + extern struct wim_inode *wim_pathname_to_inode(struct WIMStruct *w, - const char *path); -extern struct wim_dentry *get_dentry_child_with_name(const struct wim_dentry *dentry, - const char *name); -extern struct wim_dentry *get_parent_dentry(struct WIMStruct *w, const char *path); + const char *path); + +extern struct wim_dentry * +get_dentry_child_with_name(const struct wim_dentry *dentry, const char *name); + +extern struct wim_dentry *get_parent_dentry(struct WIMStruct *w, + const char *path); extern int print_dentry(struct wim_dentry *dentry, void *lookup_table); extern int print_dentry_full_path(struct wim_dentry *entry, void *ignore); @@ -370,21 +388,58 @@ extern void unlink_dentry(struct wim_dentry *dentry); extern bool dentry_add_child(struct wim_dentry * restrict parent, struct wim_dentry * restrict child); -extern struct ads_entry *inode_get_ads_entry(struct wim_inode *inode, - const char *stream_name, - u16 *idx_ret); -extern struct ads_entry *inode_add_ads(struct wim_inode *dentry, - const char *stream_name); +extern struct wim_ads_entry *inode_get_ads_entry(struct wim_inode *inode, + const char *stream_name, + u16 *idx_ret); + +extern struct wim_ads_entry *inode_add_ads(struct wim_inode *dentry, + const char *stream_name); +extern int inode_add_ads_with_data(struct wim_inode *inode, const char *name, + const u8 *value, size_t size, + 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_LEN (sizeof(WIMLIB_UNIX_DATA_TAG) - 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); + u64 metadata_resource_len, + struct wim_dentry *dentry); extern u8 *write_dentry_tree(const struct wim_dentry *tree, u8 *p);