dentry_to_stbuf() fix
authorEric Biggers <ebiggers3@gmail.com>
Sun, 19 Aug 2012 05:02:46 +0000 (00:02 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 19 Aug 2012 05:02:46 +0000 (00:02 -0500)
src/dentry.c
src/dentry.h
src/hardlink.c
src/mount.c

index 095af557f7a137eb98ea6774fa6c520469fd453e..e5362e1b23a13f324618bcf8c9d8c238e006ee02 100644 (file)
@@ -92,18 +92,13 @@ void dentry_to_stbuf(const struct dentry *dentry, struct stat *stbuf,
        else
                stbuf->st_mode = S_IFREG | 0644;
 
-       if (table)
-               lte = __lookup_resource(table, dentry_hash(dentry));
-       else
-               lte = NULL;
-
-       if (lte) {
-               stbuf->st_nlink = lte->refcnt;
+       /* Use the size of the unnamed (default) file stream. */
+       if (table && (lte = __lookup_resource(table, dentry_hash(dentry))))
                stbuf->st_size = lte->resource_entry.original_size;
-       } else {
-               stbuf->st_nlink = 1;
+       else
                stbuf->st_size = 0;
-       }
+
+       stbuf->st_nlink   = dentry_link_group_size(dentry);
        stbuf->st_uid     = getuid();
        stbuf->st_gid     = getgid();
        stbuf->st_atime   = ms_timestamp_to_unix(dentry->last_access_time);
index 50021322f5cbbe0d6e1eebf15d377b3c5bd0b2cb..469946f8019b812b4db66d0837b8ebb390bd201a 100644 (file)
@@ -213,12 +213,14 @@ static inline const u8 *dentry_hash(const struct dentry *dentry)
        return dentry->hash;
 }
 
-static inline size_t dentry_link_group_size(struct dentry *dentry)
+static inline size_t dentry_link_group_size(const struct dentry *dentry)
 {
        size_t size = 0;
        struct list_head *list;
        list_for_each(list, &dentry->link_group_list)
                size++;
+       if (size == 0)
+               size = 1;
        return size;
 }
 
index 67be5aab450e985bd2b6fd016dc17d22fb2b5e45..a5d8b9fae05fae57f56dae0fab55262bcb9456ef 100644 (file)
@@ -36,8 +36,10 @@ int link_group_table_insert(struct dentry *dentry, struct link_group_table *tabl
        size_t pos;
        struct link_group *group;
 
-       if (dentry->hard_link == 0)
+       if (dentry->hard_link == 0) {
+               INIT_LIST_HEAD(&dentry->link_group_list);
                return 0;
+       }
 
        /* Try adding to existing hard link group */
        pos = dentry->hard_link % table->capacity;
index 9e285c6c739da4fc5191b42ac48a1347dcd8f209..984666e6b6c2c88e35f0fd55e325694a4b0d888a 100644 (file)
@@ -98,7 +98,7 @@ static int alloc_wimlib_fd(struct lookup_table_entry *lte,
                u16 num_new_fds;
 
                if (lte->num_allocated_fds == max_fds)
-                       return -ENFILE;
+                       return -EMFILE;
                num_new_fds = min(fds_per_alloc, max_fds - lte->num_allocated_fds);
                
                fds = CALLOC(lte->num_allocated_fds + num_new_fds,