+ wim_timestamp_to_timeval(inode->last_access_time, &tv[0]);
+ wim_timestamp_to_timeval(inode->last_write_time, &tv[1]);
+ #ifdef HAVE_LUTIMES
+ ret = lutimes(output_path, tv);
+ #else
+ ret = -1;
+ errno = ENOSYS;
+ #endif
+ if (ret != 0) {
+ #ifdef HAVE_UTIME
+ if (errno == ENOSYS) {
+ struct utimbuf buf;
+ buf.actime = wim_timestamp_to_unix(inode->last_access_time);
+ buf.modtime = wim_timestamp_to_unix(inode->last_write_time);
+ if (utime(output_path, &buf) == 0)
+ return 0;
+ }
+ #endif
+ if (errno != ENOSYS || args->num_lutimes_warnings < 10) {
+ /*WARNING("Failed to set timestamp on file `%s': %s",*/
+ /*output_path, strerror(errno));*/
+ args->num_lutimes_warnings++;
+ }
+ }
+ return 0;
+}
+
+
+static int dentry_add_streams_for_extraction(struct dentry *dentry,
+ void *wim)
+{
+ WIMStruct *w = wim;
+ struct list_head *stream_list;
+ struct lookup_table_entry *lte;
+
+ lte = inode_unnamed_lte(dentry->d_inode, w->lookup_table);
+ if (lte) {
+ if (++lte->out_refcnt == 1) {
+ INIT_LIST_HEAD(<e->dentry_list);
+ stream_list = w->private;
+ list_add_tail(<e->staging_list, stream_list);
+ }
+ list_add_tail(&dentry->tmp_list, <e->dentry_list);
+ }
+ return 0;
+}
+
+static int cmp_streams_by_wim_position(const void *p1, const void *p2)
+{
+ const struct lookup_table_entry *lte1, *lte2;
+ lte1 = *(const struct lookup_table_entry**)p1;
+ lte2 = *(const struct lookup_table_entry**)p2;
+ if (lte1->resource_entry.offset < lte2->resource_entry.offset)
+ return -1;
+ else if (lte1->resource_entry.offset > lte2->resource_entry.offset)
+ return 1;
+ else
+ return 0;
+}
+
+static int sort_stream_list_by_wim_position(struct list_head *stream_list)
+{
+ struct list_head *cur;
+ size_t num_streams;
+ struct lookup_table_entry **array;
+ size_t i;
+ size_t array_size;
+
+ DEBUG("Sorting stream list by wim position");
+
+ num_streams = 0;
+ list_for_each(cur, stream_list)
+ num_streams++;
+ array_size = num_streams * sizeof(array[0]);
+
+ DEBUG("num_streams = %zu", num_streams);
+
+ array = MALLOC(array_size);
+ if (!array) {
+ ERROR("Failed to allocate %zu bytes to sort stream entries",
+ array_size);
+ return WIMLIB_ERR_NOMEM;
+ }
+ cur = stream_list->next;
+ for (i = 0; i < num_streams; i++) {
+ array[i] = container_of(cur, struct lookup_table_entry, staging_list);
+ cur = cur->next;