]> wimlib.net Git - wimlib/blob - include/wimlib/inode_table.h
extract.c: replace tempnam() with mkstemp() on non-Windows
[wimlib] / include / wimlib / inode_table.h
1 #ifndef _WIMLIB_INODE_TABLE_H
2 #define _WIMLIB_INODE_TABLE_H
3
4 #include "wimlib/list.h"
5 #include "wimlib/types.h"
6 #include "wimlib/util.h"
7
8 struct wim_dentry;
9
10 /* Hash table to find inodes for hard link detection, given an inode number (in
11  * the case of reading a WIM image), or both an inode number and a device number
12  * (in the case of adding files to a WIM image).  Also contains an extra list to
13  * hold inodes for which no additional hard link detection is desired.  In both
14  * cases the inodes are linked by i_hlist_node.  */
15 struct wim_inode_table {
16         struct hlist_head *array;
17         size_t filled;
18         size_t capacity;
19         struct hlist_head extra_inodes;
20 };
21
22
23 /* Compute the index of the hash bucket to use for the given inode number and
24  * device number.  */
25 static inline size_t
26 hash_inode(const struct wim_inode_table *table, u64 ino, u64 devno)
27 {
28         return (hash_u64(ino) + devno) & (table->capacity - 1);
29 }
30
31 extern int
32 init_inode_table(struct wim_inode_table *table, size_t capacity);
33
34 extern int
35 inode_table_new_dentry(struct wim_inode_table *table, const tchar *name,
36                        u64 ino, u64 devno, bool noshare,
37                        struct wim_dentry **dentry_ret);
38
39 extern void
40 enlarge_inode_table(struct wim_inode_table *table);
41
42 extern void
43 inode_table_prepare_inode_list(struct wim_inode_table *table,
44                                struct hlist_head *head);
45
46 extern void
47 destroy_inode_table(struct wim_inode_table *table);
48
49 #endif /* _WIMLIB_INODE_TABLE_H  */