* @ni: The NTFS inode to apply the metadata to.
* @dir_ni: The NTFS inode for a directory containing @ni.
* @dentry: The WIM dentry whose inode contains the metadata to apply.
- * @w: The WIMStruct for the WIM, through which the table of security
+ * @wim: The WIMStruct for the WIM, through which the table of security
* descriptors can be accessed.
*
* Returns 0 on success, nonzero on failure.
apply_file_attributes_and_security_data(ntfs_inode *ni,
ntfs_inode *dir_ni,
struct wim_dentry *dentry,
- const WIMStruct *w,
+ const WIMStruct *wim,
int extract_flags)
{
int ret;
struct SECURITY_CONTEXT ctx;
- u32 attributes_le32;
+ le32 attributes;
const struct wim_inode *inode;
inode = dentry->d_inode;
DEBUG("Setting NTFS file attributes on `%s' to %#"PRIx32,
dentry->_full_path, inode->i_attributes);
- attributes_le32 = cpu_to_le32(inode->i_attributes);
+ attributes = cpu_to_le32(inode->i_attributes);
memset(&ctx, 0, sizeof(ctx));
ctx.vol = ni->vol;
ret = ntfs_xattr_system_setxattr(&ctx, XATTR_NTFS_ATTRIB,
ni, dir_ni,
- (const char*)&attributes_le32,
- sizeof(u32), 0);
+ (char*)&attributes,
+ sizeof(attributes), 0);
if (ret) {
ERROR("Failed to set NTFS file attributes on `%s'",
dentry->_full_path);
const char *desc;
const struct wim_security_data *sd;
- sd = wim_const_security_data(w);
+ sd = wim_const_security_data(wim);
wimlib_assert(inode->i_security_id < sd->num_entries);
desc = (const char *)sd->descriptors[inode->i_security_id];
DEBUG("Applying security descriptor %d to `%s'",
}
ret = apply_file_attributes_and_security_data(ni, dir_ni, dentry,
- args->w,
+ args->wim,
args->extract_flags);
if (ret)
goto out_close_dir_ni;
}
/* Set DOS (short) name if given */
- if (dentry_has_short_name(dentry)) {
+ if (dentry_has_short_name(dentry) && !dentry->dos_name_invalid)
+ {
char *short_name_mbs;
size_t short_name_mbs_nbytes;
ret = utf16le_to_tstr(dentry->short_name,
short_name_mbs_nbytes, 0);
FREE(short_name_mbs);
if (ret) {
- ERROR_WITH_ERRNO("Could not set DOS (short) name for `%s'",
- dentry->_full_path);
- ret = WIMLIB_ERR_NTFS_3G;
+ WARNING_WITH_ERRNO("Could not set DOS (short) name for `%s'",
+ dentry->_full_path);
+ ret = 0;
}
/* inodes have been closed by ntfs_set_ntfs_dos_name(). */
goto out;
static int
apply_root_dentry_ntfs(struct wim_dentry *dentry,
- ntfs_volume *vol, const WIMStruct *w,
+ ntfs_volume *vol, const WIMStruct *wim,
int extract_flags)
{
ntfs_inode *ni;
int ret = 0;
+ ret = calculate_dentry_full_path(dentry);
+ if (ret)
+ return ret;
+
ni = ntfs_pathname_to_inode(vol, NULL, "/");
if (!ni) {
ERROR_WITH_ERRNO("Could not find root NTFS inode");
return WIMLIB_ERR_NTFS_3G;
}
- ret = apply_file_attributes_and_security_data(ni, ni, dentry, w,
+ ret = apply_file_attributes_and_security_data(ni, ni, dentry, wim,
extract_flags);
if (ntfs_inode_close(ni) != 0) {
ERROR_WITH_ERRNO("Failed to close NTFS inode for root "
{
struct apply_args *args = arg;
ntfs_volume *vol = args->vol;
- WIMStruct *w = args->w;
+ WIMStruct *wim = args->wim;
struct wim_dentry *orig_dentry;
struct wim_dentry *other;
int ret;
/* Treat the root dentry specially. */
if (dentry_is_root(dentry))
- return apply_root_dentry_ntfs(dentry, vol, w,
+ return apply_root_dentry_ntfs(dentry, vol, wim,
args->extract_flags);
/* NTFS filename namespaces need careful consideration. A name for a
again:
orig_dentry = NULL;
if (!dentry->d_inode->i_dos_name_extracted &&
- !dentry_has_short_name(dentry))
+ (!dentry_has_short_name(dentry) || dentry->dos_name_invalid))
{
inode_for_each_dentry(other, dentry->d_inode) {
- if (dentry_has_short_name(other)) {
+ if (dentry_has_short_name(other) && !other->dos_name_invalid) {
orig_dentry = dentry;
dentry = other;
break;
}
}
dentry->d_inode->i_dos_name_extracted = 1;
+
+ ret = calculate_dentry_full_path(dentry);
+ if (ret)
+ return ret;
+
ntfs_inode *dir_ni = dentry_open_parent_ni(dentry, vol);
if (dir_ni) {
ret = do_apply_dentry_ntfs(dentry, dir_ni, arg);