]> wimlib.net Git - wimlib/blobdiff - src/extract.c
Ensure WIM has filename before doing WIMBoot extraction
[wimlib] / src / extract.c
index 3cc9959d27df0ebf57bd98853adcff152e1a52fd..edac626e4e6eb94331d46435caf9d1360785ce39 100644 (file)
@@ -217,7 +217,7 @@ load_streams_from_pipe(struct apply_ctx *ctx,
                        lte_unbind_wim_resource_spec(found_lte);
                        lte_bind_wim_resource_spec(needed_lte, rspec);
 
-                       ret = (*cbs->begin_stream)(needed_lte, 0,
+                       ret = (*cbs->begin_stream)(needed_lte,
                                                   cbs->begin_stream_ctx);
                        if (ret) {
                                lte_unbind_wim_resource_spec(needed_lte);
@@ -306,18 +306,17 @@ retry:
 }
 
 static int
-begin_extract_stream_wrapper(struct wim_lookup_table_entry *lte,
-                            u32 flags, void *_ctx)
+begin_extract_stream_wrapper(struct wim_lookup_table_entry *lte, void *_ctx)
 {
        struct apply_ctx *ctx = _ctx;
 
        ctx->cur_stream = lte;
+       ctx->cur_stream_offset = 0;
 
        if (unlikely(lte->out_refcnt > MAX_OPEN_STREAMS))
                return create_temporary_file(&ctx->tmpfile_fd, &ctx->tmpfile_name);
        else
-               return (*ctx->saved_cbs->begin_stream)(lte, flags,
-                                                      ctx->saved_cbs->begin_stream_ctx);
+               return (*ctx->saved_cbs->begin_stream)(lte, ctx->saved_cbs->begin_stream_ctx);
 }
 
 static int
@@ -327,9 +326,13 @@ extract_chunk_wrapper(const void *chunk, size_t size, void *_ctx)
        union wimlib_progress_info *progress = &ctx->progress;
        int ret;
 
+       ctx->cur_stream_offset += size;
+
        if (likely(ctx->supported_features.hard_links)) {
                progress->extract.completed_bytes +=
                        (u64)size * ctx->cur_stream->out_refcnt;
+               if (ctx->cur_stream_offset == ctx->cur_stream->size)
+                       progress->extract.completed_streams += ctx->cur_stream->out_refcnt;
        } else {
                const struct stream_owner *owners = stream_owners(ctx->cur_stream);
                for (u32 i = 0; i < ctx->cur_stream->out_refcnt; i++) {
@@ -341,6 +344,8 @@ extract_chunk_wrapper(const void *chunk, size_t size, void *_ctx)
                                            d_extraction_alias_node)
                        {
                                progress->extract.completed_bytes += size;
+                               if (ctx->cur_stream_offset == ctx->cur_stream->size)
+                                       progress->extract.completed_streams++;
                        }
                }
        }
@@ -424,8 +429,7 @@ extract_from_tmpfile(const tchar *tmpfile_name, struct apply_ctx *ctx)
                 * because it needs the original stream location in order to
                 * create the external backing reference.  */
 
-               ret = (*cbs->begin_stream)(orig_lte, 0,
-                                          cbs->begin_stream_ctx);
+               ret = (*cbs->begin_stream)(orig_lte, cbs->begin_stream_ctx);
                if (ret)
                        return ret;
 
@@ -964,7 +968,7 @@ ref_stream(struct wim_lookup_table_entry *lte, u32 stream_idx,
                return 0;
 
        ctx->progress.extract.total_bytes += lte->size;
-       ctx->progress.extract.num_streams++;
+       ctx->progress.extract.total_streams++;
 
        if (inode->i_visited)
                return 0;
@@ -1507,12 +1511,16 @@ check_extract_flags(const WIMStruct *wim, int *extract_flags_p)
        }
 #endif
 
-#ifndef __WIN32__
        if (extract_flags & WIMLIB_EXTRACT_FLAG_WIMBOOT) {
+#ifdef __WIN32__
+               if (!wim->filename)
+                       return WIMLIB_ERR_NO_FILENAME;
+#else
                ERROR("WIMBoot extraction is only supported on Windows!");
                return WIMLIB_ERR_UNSUPPORTED;
-       }
 #endif
+       }
+
 
        if ((extract_flags & (WIMLIB_EXTRACT_FLAG_RPFIX |
                              WIMLIB_EXTRACT_FLAG_NORPFIX |