]> wimlib.net Git - wimlib/blobdiff - src/hardlink.c
inode updates (IN PROGRESS)
[wimlib] / src / hardlink.c
index 87f75a872a5a6d56d87835b51111b946bd231a81..5c2f20c4fc6720ef02d7fa522e7b24dfbcf59a0d 100644 (file)
@@ -75,12 +75,6 @@ static size_t inode_link_count(const struct inode *inode)
        return size;
 }
 
-static struct dentry *inode_first_dentry(struct inode *inode)
-{
-       return container_of(inode->dentry_list.next, struct dentry,
-                           inode_dentry_list);
-}
-
 /* 
  * Insert a dentry into the inode table based on its inode
  * ID.
@@ -148,10 +142,10 @@ int inode_table_insert(struct dentry *dentry, void *__table)
  * next available inode ID. */
 u64 assign_inode_numbers(struct hlist_head *inode_list)
 {
+       DEBUG("Assigning inode numbers");
        struct inode *inode;
        struct hlist_node *cur;
        u64 cur_ino = 1;
-       struct dentry *dentry;
        hlist_for_each_entry(inode, cur, inode_list, hlist) {
                inode->ino = cur_ino;
                cur_ino++;
@@ -160,8 +154,7 @@ u64 assign_inode_numbers(struct hlist_head *inode_list)
 }
 
 
-static void
-print_inode_dentries(const struct inode *inode)
+static void print_inode_dentries(const struct inode *inode)
 {
        struct dentry *dentry;
        list_for_each_entry(dentry, &inode->dentry_list, inode_dentry_list)
@@ -250,7 +243,7 @@ static int fix_true_inode(struct inode *inode)
        u64 last_atime = 0;
        bool found_short_name = false;
 
-       list_for_each_entry(dentry, &inode->dentry_list, inode_dentry_list) {
+       inode_for_each_dentry(dentry, inode) {
                if (!ref_dentry || ref_dentry->inode->num_ads == 0)
                        ref_dentry = dentry;
                if (dentry->short_name_len) {
@@ -274,7 +267,7 @@ static int fix_true_inode(struct inode *inode)
        ref_inode = ref_dentry->inode;
        ref_inode->link_count = 1;
 
-       list_for_each_entry(dentry, &inode->dentry_list, inode_dentry_list) {
+       inode_for_each_dentry(dentry, inode) {
                if (dentry != ref_dentry) {
                        if (!inodes_consistent(ref_inode, dentry->inode)) {
                                inconsistent_inode(dentry->inode);
@@ -325,7 +318,7 @@ fix_nominal_inode(struct inode *inode, struct hlist_head *inode_list)
         /* Create a list of dentries in the nominal inode that have at
          * least one data stream with a non-zero hash, and another list that
          * contains the dentries that have a zero hash for all data streams. */
-       list_for_each_entry(dentry, &inode->dentry_list, inode_dentry_list) {
+       inode_for_each_dentry(dentry, inode) {
                for (unsigned i = 0; i <= dentry->inode->num_ads; i++) {
                        const u8 *hash;
                        hash = inode_stream_hash(dentry->inode, i);
@@ -365,8 +358,7 @@ fix_nominal_inode(struct inode *inode, struct hlist_head *inode_list)
          * these dentries for consistency with the others to form a set of true
          * inodes. */
        num_true_inodes = 0;
-       list_for_each_entry(dentry, &dentries_with_data_streams, tmp_list)
-       {
+       list_for_each_entry(dentry, &dentries_with_data_streams, tmp_list) {
                /* Look for a true inode that is consistent with
                 * this dentry and add this dentry to it.  Or, if none
                 * of the true inodes are consistent with this
@@ -404,7 +396,7 @@ next_dentry_2:
                inode = container_of(true_inodes.first,
                                     struct inode,
                                     hlist);
-               /* Assign the streamless dentries to the one and only true link
+               /* Assign the streamless dentries to the one and only true
                 * inode. */
                list_for_each_entry(dentry, &dentries_with_no_data_streams, tmp_list)
                        list_add(&dentry->inode_dentry_list, &inode->dentry_list);
@@ -412,6 +404,10 @@ next_dentry_2:
         if (num_true_inodes != 1) {
                #ifdef ENABLE_DEBUG
                {
+                       inode = container_of(true_inodes.first,
+                                            struct inode,
+                                            hlist);
+
                        printf("Split nominal inode 0x%"PRIx64" into %zu "
                               "inodes:\n",
                               inode->ino, num_true_inodes);
@@ -437,13 +433,14 @@ next_dentry_2:
 }
 
 /*
- * Goes through each inode and shares the inodes among members of a hard
- * inode.
+ * Goes through each hard link group (dentries sharing the same hard link group
+ * ID field) that's been inserted into the inode table and shars the `struct
+ * inode's among members of each hard link group.
  *
- * In the process, the dentries in each inode are checked for consistency.
- * If they contain data features that indicate they cannot really be in the same
- * inode, this should be an error, but in reality this case needs to
- * be handled, so we split the dentries into different inodes.
+ * In the process, the dentries belonging to each inode are checked for
+ * consistency.  If they contain data features that indicate they cannot really
+ * correspond to the same inode, this should be an error, but in reality this
+ * case needs to be handled, so we split the dentries into different inodes.
  */
 int fix_inodes(struct inode_table *table, struct hlist_head *inode_list)
 {