- lte = inode_stream_lte(dentry->d_inode, 0, lookup_table);
- if (lte) {
- print_lookup_table_entry(lte, stdout);
- } else {
- hash = inode_stream_hash(inode, 0);
- if (hash) {
- tprintf(T("Hash = 0x"));
- print_hash(hash, stdout);
- tputchar(T('\n'));
- tputchar(T('\n'));
- }
- }
- for (u16 i = 0; i < inode->i_num_ads; i++) {
- tprintf(T("[Alternate Stream Entry %u]\n"), i);
- wimlib_printf(T("Name = \"%"WS"\"\n"),
- inode->i_ads_entries[i].stream_name);
- tprintf(T("Name Length (UTF16 bytes) = %hu\n"),
- inode->i_ads_entries[i].stream_name_nbytes);
- hash = inode_stream_hash(inode, i + 1);
- if (hash) {
- tprintf(T("Hash = 0x"));
- print_hash(hash, stdout);
- tputchar(T('\n'));
- }
- print_lookup_table_entry(inode_stream_lte(inode, i + 1, lookup_table),
- stdout);
- }
- return 0;
-}
-
-/* Initializations done on every `struct wim_dentry'. */
-static void
-dentry_common_init(struct wim_dentry *dentry)
-{
- memset(dentry, 0, sizeof(struct wim_dentry));
-}
-
-struct wim_inode *
-new_timeless_inode(void)
-{
- struct wim_inode *inode = CALLOC(1, sizeof(struct wim_inode));
- if (inode) {
- inode->i_security_id = -1;
- inode->i_nlink = 1;
- inode->i_next_stream_id = 1;
- inode->i_not_rpfixed = 1;
- INIT_LIST_HEAD(&inode->i_list);
- #ifdef WITH_FUSE
- if (pthread_mutex_init(&inode->i_mutex, NULL) != 0) {
- ERROR_WITH_ERRNO("Error initializing mutex");
- FREE(inode);
- return NULL;
- }
- #endif
- INIT_LIST_HEAD(&inode->i_dentry);
- }
- return inode;
-}
-
-static struct wim_inode *
-new_inode(void)
-{
- struct wim_inode *inode = new_timeless_inode();
- if (inode) {
- u64 now = get_wim_timestamp();
- inode->i_creation_time = now;
- inode->i_last_access_time = now;
- inode->i_last_write_time = now;
- }
- return inode;
-}
-
-/* Creates an unlinked directory entry. */
-int
-new_dentry(const tchar *name, struct wim_dentry **dentry_ret)
-{
- struct wim_dentry *dentry;
- int ret;
-
- dentry = MALLOC(sizeof(struct wim_dentry));
- if (!dentry)
- return WIMLIB_ERR_NOMEM;
-
- dentry_common_init(dentry);
- ret = set_dentry_name(dentry, name);
- if (ret == 0) {
- dentry->parent = dentry;
- *dentry_ret = dentry;
- } else {
- FREE(dentry);
- ERROR("Failed to set name on new dentry with name \"%"TS"\"",
- name);
- }
- return ret;
-}
-
-
-static int
-_new_dentry_with_inode(const tchar *name, struct wim_dentry **dentry_ret,
- bool timeless)
-{
- struct wim_dentry *dentry;
- int ret;
-
- ret = new_dentry(name, &dentry);
- if (ret)
- return ret;
-
- if (timeless)
- dentry->d_inode = new_timeless_inode();
- else
- dentry->d_inode = new_inode();
- if (!dentry->d_inode) {
- free_dentry(dentry);
- return WIMLIB_ERR_NOMEM;
- }
-
- inode_add_dentry(dentry, dentry->d_inode);
- *dentry_ret = dentry;