symlink fixes
authorEric Biggers <ebiggers3@gmail.com>
Sun, 19 Aug 2012 07:14:21 +0000 (02:14 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 19 Aug 2012 07:14:21 +0000 (02:14 -0500)
src/dentry.c
src/mount.c
src/symlink.c

index 68f9c57afa9df926b1856ccb79b825b1ccd36f21..92828bb4b6d267c14d3ac82b6ca4e4dfc2e2d5b8 100644 (file)
@@ -498,6 +498,7 @@ struct dentry *new_dentry(const char *name)
        dentry->next   = dentry;
        dentry->prev   = dentry;
        dentry->parent = dentry;
+       INIT_LIST_HEAD(&dentry->link_group_list);
        return dentry;
 err:
        FREE(dentry);
index 18a28558181025f715c449668b14a8c51ca7fa3b..0588746e91929eb65ab6327e7f5b01eec1846e0a 100644 (file)
@@ -775,12 +775,6 @@ static int wimfs_link(const char *to, const char *from)
                FREE(from_dentry);
                return -ENOMEM;
        }
-       if (calculate_dentry_full_path(from_dentry, to_dentry) != 0) {
-               FREE(from_dentry->file_name);
-               FREE(from_dentry->file_name_utf8);
-               FREE(from_dentry);
-               return -ENOMEM;
-       }
        list_add(&from_dentry->link_group_list, &to_dentry->link_group_list);
        link_dentry(from_dentry, from_dentry_parent);
        return 0;
@@ -1114,14 +1108,6 @@ static int wimfs_symlink(const char *to, const char *from)
        if (!dentry)
                return -ENOMEM;
 
-       if (!change_dentry_name(dentry, link_name)) {
-               FREE(dentry);
-               return -ENOMEM;
-       }
-
-       if (calculate_dentry_full_path(dentry, NULL) != 0)
-               goto out_free_dentry;
-
        dentry->attributes = FILE_ATTRIBUTE_REPARSE_POINT;
        dentry->reparse_tag = WIM_IO_REPARSE_TAG_SYMLINK;
 
index 9de1fb50cb2040ebc9995f4ebb7a5b5e7df88625..e7d7be9bb432b650b98918e8bbf62d73eea1ac88 100644 (file)
@@ -108,13 +108,14 @@ void *make_symlink_reparse_data_buf(const char *symlink_target, size_t *len_ret)
        void *buf = MALLOC(len);
        if (!buf)
                goto out;
+       /* XXX Fix absolute paths */
 
        u8 *p = buf;
        p = put_u16(p, 0); /* Substitute name offset */
        p = put_u16(p, utf16_len); /* Substitute name length */
        p = put_u16(p, utf16_len); /* Print name offset */
        p = put_u16(p, utf16_len); /* Print name length */
-       p = put_u32(p, (symlink_target[0] == '/') ?  0 : 1);
+       p = put_u32(p, 1);
        p = put_bytes(p, utf16_len, name_utf16);
        p = put_bytes(p, utf16_len, name_utf16);
        /*DEBUG("utf16_len = %zu, len = %zu", utf16_len, len);*/
@@ -148,13 +149,20 @@ ssize_t dentry_readlink(const struct dentry *dentry, char *buf, size_t buf_len,
        if (res_entry->original_size > 10000)
                return -EIO;
 
-       char res_buf[res_entry->original_size];
-       if (read_full_resource(w->fp, res_entry->size, 
-                              res_entry->original_size,
-                              res_entry->offset,
-                              wim_resource_compression_type(w, res_entry),
-                              res_buf) != 0)
-               return -EIO;
+       char __res_buf[res_entry->original_size];
+       const char *res_buf;
+       if (lte->is_symlink && lte->symlink_buf) {
+               res_buf = lte->symlink_buf;
+       } else {
+               res_buf = __res_buf;
+               if (read_full_resource(w->fp, res_entry->size, 
+                                      res_entry->original_size,
+                                      res_entry->offset,
+                                      wim_resource_compression_type(w, res_entry),
+                                      __res_buf) != 0)
+                       return -EIO;
+               res_buf = __res_buf;
+       }
        return get_symlink_name(res_buf, res_entry->original_size, buf,
                                buf_len, dentry->reparse_tag);
 }