X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fntfs-capture.c;h=9861523b081b8e200149eb818b25715ea065e193;hb=5ed5a1ef610700e463abd0c07aed377cce5eef47;hp=ff8c3a9b68b8bb20cf21f6a2aa72156abdb181e5;hpb=5caa8cde33f9f1dd77437df6c7db9559a7f06dbe;p=wimlib diff --git a/src/ntfs-capture.c b/src/ntfs-capture.c index ff8c3a9b..9861523b 100644 --- a/src/ntfs-capture.c +++ b/src/ntfs-capture.c @@ -49,14 +49,14 @@ #include #include "rbtree.h" -/* Structure that allows searching the security descriptors by SHA1 message - * digest. */ +/* Red-black tree that maps SHA1 message digests of security descriptors to + * security IDs, which are themselves indices into the table of security + * descriptors in the 'struct wim_security_data'. */ struct sd_set { struct wim_security_data *sd; struct rb_root rb_root; }; -/* Binary tree node of security descriptors, indexed by the @hash field. */ struct sd_node { int security_id; u8 hash[SHA1_HASH_SIZE]; @@ -222,6 +222,7 @@ static int ntfs_attr_sha1sum(ntfs_inode *ni, ATTR_RECORD *ar, if (ntfs_attr_pread(na, 0, 8, buf) != 8) goto out_error; *reparse_tag_ret = le32_to_cpu(*(u32*)buf); + DEBUG("ReparseTag = %#x", *reparse_tag_ret); pos = 8; bytes_remaining -= 8; } @@ -298,6 +299,9 @@ static int capture_ntfs_streams(struct wim_dentry *dentry, ntfs_inode *ni, if (ret != 0) goto out_put_actx; + if (type == AT_REPARSE_POINT) + dentry->d_inode->i_reparse_tag = reparse_tag; + /* Make a lookup table entry for the stream, or use an existing * one if there's already an identical stream. */ lte = __lookup_resource(lookup_table, attr_hash); @@ -329,7 +333,6 @@ static int capture_ntfs_streams(struct wim_dentry *dentry, ntfs_inode *ni, lte->ntfs_loc = ntfs_loc; lte->resource_location = RESOURCE_IN_NTFS_VOLUME; if (type == AT_REPARSE_POINT) { - dentry->d_inode->i_reparse_tag = reparse_tag; ntfs_loc->is_reparse_point = true; lte->resource_entry.original_size = data_size - 8; lte->resource_entry.size = data_size - 8; @@ -349,6 +352,7 @@ static int capture_ntfs_streams(struct wim_dentry *dentry, ntfs_inode *ni, if (name_length == 0) { /* Unnamed data stream. Put the reference to it in the * dentry's inode. */ + #if 0 if (dentry->d_inode->i_lte) { ERROR("Found two un-named data streams for " "`%s'", path); @@ -356,6 +360,15 @@ static int capture_ntfs_streams(struct wim_dentry *dentry, ntfs_inode *ni, goto out_free_lte; } dentry->d_inode->i_lte = lte; + #else + if (dentry->d_inode->i_lte) { + WARNING("Found two un-named data streams for " + "`%s'", path); + free_lookup_table_entry(lte); + } else { + dentry->d_inode->i_lte = lte; + } + #endif } else { /* Named data stream. Put the reference to it in the * alternate data stream entries */ @@ -489,19 +502,18 @@ static int set_dentry_dos_name(struct wim_dentry *dentry, void *arg) 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 + 2); + 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); - *(u16*)&dentry->short_name[node->name_len_bytes] = 0; dentry->short_name_len = node->name_len_bytes; DEBUG("Assigned DOS name to ino %"PRIu64, dentry->d_inode->i_ino); } else { - DEBUG("ino %"PRIu64" has Win32 name with no " - "corresponding DOS name", - dentry->d_inode->i_ino); + WARNING("NTFS inode %"PRIu64" has Win32 name with no " + "corresponding DOS name", + dentry->d_inode->i_ino); } } return 0; @@ -559,14 +571,14 @@ static int wim_ntfs_capture_filldir(void *dirent, const ntfschar *name, ctx = dirent; if (name_type & FILE_NAME_DOS) { - /* Special case: If this is the entry for a DOS name, store it - * for later. */ + /* If this is the entry for a DOS name, store it for later. */ ret = insert_dos_name(ctx->dos_name_map, name, name_len, mref & MFT_REF_MASK_CPU); - if (ret != 0) + + /* Return now if an error occurred or if this is just a DOS name + * and not a Win32+DOS name. */ + if (ret != 0 || name_type == FILE_NAME_DOS) return ret; - if (name_type == FILE_NAME_DOS) /* DOS only, not Win32 + DOS */ - return 0; } ret = utf16_to_utf8((const char*)name, name_len * 2, &utf8_name, &utf8_name_len);