]> wimlib.net Git - wimlib/blobdiff - src/ntfs-3g_apply.c
w -> wim
[wimlib] / src / ntfs-3g_apply.c
index 0bf7989bd74231870d2c578ba2703eb300fc7d88..a8292c7e2432c90da4b8d6c919e1a50fbf9c6dfa 100644 (file)
@@ -291,7 +291,7 @@ apply_ntfs_hardlink(struct wim_dentry *from_dentry,
  * @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.
@@ -300,7 +300,7 @@ static int
 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;
@@ -330,7 +330,7 @@ apply_file_attributes_and_security_data(ntfs_inode *ni,
                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'",
@@ -446,7 +446,7 @@ do_apply_dentry_ntfs(struct wim_dentry *dentry, ntfs_inode *dir_ni,
        }
 
        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;
@@ -458,7 +458,8 @@ do_apply_dentry_ntfs(struct wim_dentry *dentry, ntfs_inode *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,
@@ -475,9 +476,9 @@ do_apply_dentry_ntfs(struct wim_dentry *dentry, ntfs_inode *dir_ni,
                                             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;
@@ -506,18 +507,22 @@ 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 "
@@ -533,14 +538,14 @@ apply_dentry_ntfs(struct wim_dentry *dentry, void *arg)
 {
        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
@@ -593,10 +598,10 @@ apply_dentry_ntfs(struct wim_dentry *dentry, void *arg)
 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;
@@ -604,6 +609,11 @@ again:
                }
        }
        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);