]> wimlib.net Git - wimlib/blobdiff - src/dentry.c
hardlink fixes
[wimlib] / src / dentry.c
index e5af01ba695a4d0963d2a46a894b5609d3fa1905..cf77adc765c6180100c43cbea5726a844ca86881 100644 (file)
@@ -80,6 +80,11 @@ void stbuf_to_dentry(const struct stat *stbuf, struct dentry *dentry)
        } else {
                dentry->attributes = FILE_ATTRIBUTE_NORMAL;
        }
+       if (sizeof(ino_t) >= 8)
+               dentry->hard_link = (u64)stbuf->st_ino;
+       else
+               dentry->hard_link = (u64)stbuf->st_ino |
+                                  ((u64)stbuf->st_dev << (sizeof(ino_t) * 8));
 }
 
 /* Transfers file attributes from a struct dentry to a `stat' buffer. */
@@ -495,19 +500,21 @@ struct dentry *new_dentry(const char *name)
        
        dentry = MALLOC(sizeof(struct dentry));
        if (!dentry)
-               return NULL;
+               goto err;
 
        dentry_common_init(dentry);
-       if (change_dentry_name(dentry, name) != 0) {
-               FREE(dentry);
-               return NULL;
-       }
+       if (change_dentry_name(dentry, name) != 0)
+               goto err;
 
        dentry_update_all_timestamps(dentry);
        dentry->next   = dentry;
        dentry->prev   = dentry;
        dentry->parent = dentry;
        return dentry;
+err:
+       FREE(dentry);
+       ERROR("Failed to allocate new dentry");
+       return NULL;
 }
 
 static void dentry_free_ads_entries(struct dentry *dentry)
@@ -660,6 +667,7 @@ static int do_name_change(char **file_name_ret,
        *file_name_utf8_ret     = file_name_utf8;
        *file_name_len_ret      = utf16_len;
        *file_name_utf8_len_ret = utf8_len;
+       return 0;
 }
 
 /* Changes the name of a dentry to @new_name.  Only changes the file_name and