X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fntfs-apply.c;h=9dcf6b0a5ec18609257ff70652107cdce67b7f2d;hb=ad37dd86e75416ffc47c97b35f097012be5eeaa2;hp=fc1a354d595ee164d503e7a3ae9939b6dcd075ff;hpb=720b7bb7addd2ad2851a53dd045d49e14ac731cd;p=wimlib diff --git a/src/ntfs-apply.c b/src/ntfs-apply.c index fc1a354d..9dcf6b0a 100644 --- a/src/ntfs-apply.c +++ b/src/ntfs-apply.c @@ -7,7 +7,7 @@ */ /* - * Copyright (C) 2012 Eric Biggers + * Copyright (C) 2012, 2013 Eric Biggers * * This file is part of wimlib, a library for working with WIM files. * @@ -88,6 +88,7 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct wim_dentry *dent unsigned stream_idx = 0; ntfschar *stream_name = AT_UNNAMED; u32 stream_name_len = 0; + const char *stream_name_utf8; const struct wim_inode *inode = dentry->d_inode; struct wim_lookup_table_entry *lte; @@ -99,6 +100,15 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct wim_dentry *dent lte = inode->i_lte; while (1) { if (stream_name_len) { + + /* Skip special UNIX data entries (see documentation for + * WIMLIB_ADD_IMAGE_FLAG_UNIX_DATA) */ + if (stream_name_len == WIMLIB_UNIX_DATA_TAG_LEN + && !memcmp(stream_name_utf8, + WIMLIB_UNIX_DATA_TAG, + WIMLIB_UNIX_DATA_TAG_LEN)) + goto cont; + /* Create an empty named stream. */ ret = ntfs_attr_add(ni, AT_DATA, stream_name, stream_name_len, NULL, 0); @@ -148,11 +158,13 @@ static int write_ntfs_data_streams(ntfs_inode *ni, const struct wim_dentry *dent * have been extracted. */ progress_info->extract.completed_bytes += wim_resource_size(lte); } + cont: if (stream_idx == inode->i_num_ads) /* Has the last stream been extracted? */ break; /* Get the name and lookup table entry for the next stream. */ stream_name = (ntfschar*)inode->i_ads_entries[stream_idx].stream_name; + stream_name_utf8 = inode->i_ads_entries[stream_idx].stream_name_utf8; stream_name_len = inode->i_ads_entries[stream_idx].stream_name_len / 2; lte = inode->i_ads_entries[stream_idx].lte; stream_idx++; @@ -198,26 +210,20 @@ static ntfs_inode *dentry_open_parent_ni(const struct wim_dentry *dentry, * existing NTFS inode which already has a name @inode->i_extracted_file. * * The new name is made in the POSIX namespace (this is the behavior of - * ntfs_link()). I am assuming this is an acceptable behavior; however, it's - * possible that the original name was actually in the Win32 namespace. Note - * that the WIM format does not provide enough information to distinguish Win32 - * names from POSIX names in all cases. + * ntfs_link()). * - * Return 0 on success, nonzero on failure. + * Return 0 on success, nonzero on failure. dir_ni is closed either way. */ static int apply_ntfs_hardlink(const struct wim_dentry *from_dentry, const struct wim_inode *inode, - ntfs_inode **dir_ni_p) + ntfs_inode *dir_ni) { int ret; ntfs_inode *to_ni; - ntfs_inode *dir_ni; ntfs_volume *vol; - dir_ni = *dir_ni_p; vol = dir_ni->vol; ret = ntfs_inode_close(dir_ni); - *dir_ni_p = NULL; if (ret != 0) { ERROR_WITH_ERRNO("Error closing directory"); return WIMLIB_ERR_NTFS_3G; @@ -245,10 +251,9 @@ static int apply_ntfs_hardlink(const struct wim_dentry *from_dentry, ret |= ntfs_inode_close(dir_ni); ret |= ntfs_inode_close(to_ni); if (ret) { - ERROR_WITH_ERRNO("Could not create hard link `%s' => `%s' (ret=%d)", + ERROR_WITH_ERRNO("Could not create hard link `%s' => `%s'", from_dentry->full_path_utf8, - inode->i_extracted_file, - ret); + inode->i_extracted_file); ret = WIMLIB_ERR_NTFS_3G; } return ret; @@ -345,6 +350,7 @@ static int apply_reparse_data(ntfs_inode *ni, const struct wim_dentry *dentry, u8 reparse_data_buf[8 + wim_resource_size(lte)]; u8 *p = reparse_data_buf; p = put_u32(p, dentry->d_inode->i_reparse_tag); /* ReparseTag */ + DEBUG("ReparseTag = %#x", dentry->d_inode->i_reparse_tag); p = put_u16(p, wim_resource_size(lte)); /* ReparseDataLength */ p = put_u16(p, 0); /* Reserved */ @@ -390,9 +396,9 @@ static int do_apply_dentry_ntfs(struct wim_dentry *dentry, ntfs_inode *dir_ni, /* Already extracted another dentry in the hard * link group. Make a hard link instead of * extracting the file data. */ - ret = apply_ntfs_hardlink(dentry, inode, - &dir_ni); - goto out_close_dir_ni; + ret = apply_ntfs_hardlink(dentry, inode, dir_ni); + /* dir_ni was closed */ + goto out; } else { /* None of the dentries of this inode have been * extracted yet, so go ahead and extract the