return p;
}
+#ifdef WITH_FUSE
static FILE *wim_get_fp(WIMStruct *w)
{
pthread_mutex_lock(&w->fp_tab_mutex);
pthread_mutex_unlock(&w->fp_tab_mutex);
return ret;
}
+#endif
/*
* Reads some data from the resource corresponding to a WIM lookup table entry.
* or uncompressed. */
wimlib_assert(lte->wim != NULL);
+ #ifdef WITH_FUSE
if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
fp = wim_get_fp(lte->wim);
if (!fp)
return WIMLIB_ERR_OPEN;
- } else {
+ } else
+ #endif
+ {
+ wimlib_assert(!(flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED));
wimlib_assert(lte->wim->fp != NULL);
fp = lte->wim->fp;
}
lte->resource_entry.original_size,
lte->resource_entry.offset,
ctype, size, offset, buf);
+ #ifdef WITH_FUSE
if (flags & WIMLIB_RESOURCE_FLAG_MULTITHREADED) {
int ret2 = wim_release_fp(lte->wim, fp);
if (ret == 0)
ret = ret2;
}
+ #endif
break;
case RESOURCE_IN_STAGING_FILE:
case RESOURCE_IN_FILE_ON_DISK:
case RESOURCE_IN_NTFS_VOLUME:
wimlib_assert(lte->ntfs_loc != NULL);
wimlib_assert(lte->attr != NULL);
- {
- if (lte->ntfs_loc->is_reparse_point)
- offset += 8;
- if (ntfs_attr_pread(lte->attr, offset, size, buf) != size) {
- ERROR_WITH_ERRNO("Error reading NTFS attribute "
- "at `%s'",
- lte->ntfs_loc->path_utf8);
- ret = WIMLIB_ERR_NTFS_3G;
- }
- break;
+ if (lte->ntfs_loc->is_reparse_point)
+ offset += 8;
+ if (ntfs_attr_pread(lte->attr, offset, size, buf) != size) {
+ ERROR_WITH_ERRNO("Error reading NTFS attribute "
+ "at `%s'",
+ lte->ntfs_loc->path_utf8);
+ ret = WIMLIB_ERR_NTFS_3G;
}
+ break;
#endif
default:
wimlib_assert(0);
goto out_free_security_data;
}
+ DEBUG("Reading root dentry");
+
/* Allocate memory for the root dentry and read it into memory */
dentry = MALLOC(sizeof(struct dentry));
if (!dentry) {
ret = read_dentry(buf, metadata_len, dentry_offset, dentry);
- /* This is the root dentry, so set its parent to itself. */
- dentry->parent = dentry;
+
+ if (dentry->length == 0) {
+ ERROR("Metadata resource cannot begin with end-of-directory entry!");
+ ret = WIMLIB_ERR_INVALID_DENTRY;
+ }
if (ret != 0)
goto out_free_dentry_tree;
+
+ /* This is the root dentry, so set its parent to itself. */
+ dentry->parent = dentry;
+
inode_add_dentry(dentry, dentry->d_inode);
/* Now read the entire directory entry tree into memory. */
root = wim_root_dentry(w);
sd = wim_security_data(w);
- /* We do not allow the security data pointer to be NULL, although it may
- * point to an empty security data with no entries. */
- wimlib_assert(root != NULL);
- wimlib_assert(sd != NULL);
-
/* Offset of first child of the root dentry. It's equal to:
* - The total length of the security data, rounded to the next 8-byte
* boundary,
* - plus 8 bytes for an end-of-directory entry following the root
* dentry (shouldn't really be needed, but just in case...)
*/
- subdir_offset = ((sd->total_length + 7) & ~7) +
+ subdir_offset = (((u64)sd->total_length + 7) & ~7) +
dentry_correct_total_length(root) + 8;
/* Calculate the subdirectory offsets for the entire dentry tree. */
* it. */
lte = wim_metadata_lookup_table_entry(w);
- wimlib_assert(lte != NULL);
-
/* Write the metadata resource to the output WIM using the proper
* compression type. The lookup table entry for the metadata resource
* is updated. */
* */
lookup_table_unlink(w->lookup_table, lte);
lookup_table_insert(w->lookup_table, lte);
-
- wimlib_assert(lte->out_refcnt == 0);
lte->out_refcnt = 1;
- /* Make sure that the resource entry is written marked with the metadata
- * flag. */
+ /* Make sure that the lookup table entry for this metadata resource is
+ * marked with the metadata flag. */
lte->output_resource_entry.flags |= WIM_RESHDR_FLAG_METADATA;
out:
/* All the data has been written to the new WIM; no need for the buffer