- u64 data_size = ntfs_get_attribute_value_length(actx->attr);
- u64 name_length = actx->attr->name_length;
- u32 stream_id;
-
- if (data_size == 0) {
- /* Empty stream. No lookup table entry is needed. */
- lte = NULL;
- ntfs_loc = NULL;
- } else {
- ntfs_loc = CALLOC(1, sizeof(*ntfs_loc));
- if (!ntfs_loc) {
- ret = WIMLIB_ERR_NOMEM;
- goto out_put_actx;
- }
- ntfs_loc->ntfs_vol = vol;
- ntfs_loc->path = memdup(path, path_len + 1);
- if (!ntfs_loc->path) {
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_ntfs_loc;
- }
- if (name_length) {
- ntfs_loc->stream_name = memdup(attr_record_name(actx->attr),
- name_length * 2);
- if (!ntfs_loc->stream_name) {
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_ntfs_loc;
- }
- ntfs_loc->stream_name_nchars = name_length;
- }
-
- lte = new_lookup_table_entry();
- if (!lte) {
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_ntfs_loc;
- }
- lte->resource_location = RESOURCE_IN_NTFS_VOLUME;
- lte->ntfs_loc = ntfs_loc;
- ntfs_loc = NULL;
- if (type == AT_REPARSE_POINT) {
- if (data_size < 8) {
- ERROR("Invalid reparse data on \"%s\" "
- "(only %u bytes)!", path, (unsigned)data_size);
- ret = WIMLIB_ERR_NTFS_3G;
- goto out_free_lte;
- }
- lte->ntfs_loc->is_reparse_point = true;
- lte->size = data_size - 8;
- ret = read_reparse_tag(ni, lte->ntfs_loc,
- &inode->i_reparse_tag);
- if (ret)
- goto out_free_lte;
- } else {
- lte->ntfs_loc->is_reparse_point = false;
- lte->size = data_size;
- }
- }
- if (name_length == 0) {
- /* Unnamed data stream. Put the reference to it in the
- * dentry's inode. */
- if (inode->i_lte) {
- if (lte) {
- ERROR("Found two un-named data streams for \"%s\" "
- "(sizes = %"PRIu64", %"PRIu64")",
- path, inode->i_lte->size,
- lte->size);
- ret = WIMLIB_ERR_NTFS_3G;
- goto out_free_lte;
- }
- } else {
- stream_id = 0;
- inode->i_lte = lte;
- }
- } else {
- /* Named data stream. Put the reference to it in the
- * alternate data stream entries */
- struct wim_ads_entry *new_ads_entry;
-
- new_ads_entry = inode_add_ads_utf16le(inode,
- attr_record_name(actx->attr),
- name_length * 2);
- if (!new_ads_entry) {
- ret = WIMLIB_ERR_NOMEM;
- goto out_free_lte;
- }
- wimlib_assert(new_ads_entry->stream_name_nbytes == name_length * 2);
- stream_id = new_ads_entry->stream_id;
- new_ads_entry->lte = lte;
- }
- if (lte) {
- add_unhashed_stream(lte, inode,
- stream_id, unhashed_streams);
- }