#define WRITE_RESOURCE_FLAG_SEND_DONE_WITH_FILE 0x00000008
#define WRITE_RESOURCE_FLAG_SOLID_SORT 0x00000010
-static inline int
+static int
write_flags_to_resource_flags(int write_flags)
{
int write_resource_flags = 0;
if (write_flags & WIMLIB_WRITE_FLAG_RECOMPRESS)
write_resource_flags |= WRITE_RESOURCE_FLAG_RECOMPRESS;
+
if (write_flags & WIMLIB_WRITE_FLAG_PIPABLE)
write_resource_flags |= WRITE_RESOURCE_FLAG_PIPABLE;
+
if (write_flags & WIMLIB_WRITE_FLAG_SOLID)
write_resource_flags |= WRITE_RESOURCE_FLAG_SOLID;
+
if (write_flags & WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES)
write_resource_flags |= WRITE_RESOURCE_FLAG_SEND_DONE_WITH_FILE;
+
if ((write_flags & (WIMLIB_WRITE_FLAG_SOLID |
WIMLIB_WRITE_FLAG_NO_SOLID_SORT)) ==
WIMLIB_WRITE_FLAG_SOLID)
write_resource_flags |= WRITE_RESOURCE_FLAG_SOLID_SORT;
+
return write_resource_flags;
}
return 0;
}
-/* Rewrite a blob that was just written compressed as uncompressed instead.
- */
+/* Rewrite a blob that was just written compressed (as a non-solid WIM resource)
+ * as uncompressed instead. */
static int
write_blob_uncompressed(struct blob_descriptor *blob, struct filedes *out_fd)
{
* seeked to the end of the compressed resource, so
* don't issue a hard error; just keep the compressed
* resource instead. */
- WARNING("Recovered compressed blob of "
+ WARNING("Recovered compressed resource of "
"size %"PRIu64", continuing on.", blob->size);
return 0;
}
static int
-wim_write_blob_list(WIMStruct *wim,
- struct list_head *blob_list,
- int write_flags,
- unsigned num_threads,
- struct filter_context *filter_ctx)
+write_file_data_blobs(WIMStruct *wim,
+ struct list_head *blob_list,
+ int write_flags,
+ unsigned num_threads,
+ struct filter_context *filter_ctx)
{
int out_ctype;
u32 out_chunk_size;
for (unsigned i = 0; i < inode->i_num_streams; i++) {
struct blob_descriptor *blob;
+ const u8 *hash;
blob = stream_blob(&inode->i_streams[i], table);
- if (blob)
+ if (blob) {
reference_blob_for_write(blob, blob_list, inode->i_nlink);
- else if (!is_zero_hash(stream_hash(&inode->i_streams[i])))
- return WIMLIB_ERR_RESOURCE_NOT_FOUND;
+ } else {
+ hash = stream_hash(&inode->i_streams[i]);
+ if (!is_zero_hash(hash))
+ return blob_not_found_error(inode, hash);
+ }
}
return 0;
}
}
static int
-write_file_blobs(WIMStruct *wim, int image, int write_flags,
- unsigned num_threads,
- struct list_head *blob_list_override,
- struct list_head *blob_table_list_ret)
+write_file_data(WIMStruct *wim, int image, int write_flags,
+ unsigned num_threads,
+ struct list_head *blob_list_override,
+ struct list_head *blob_table_list_ret)
{
int ret;
struct list_head _blob_list;
}
}
- return wim_write_blob_list(wim,
- blob_list,
- write_flags,
- num_threads,
- filter_ctx);
+ return write_file_data_blobs(wim,
+ blob_list,
+ write_flags,
+ num_threads,
+ filter_ctx);
}
static int
&& wim_has_integrity_table(wim))
{
old_blob_table_end = wim->hdr.blob_table_reshdr.offset_in_wim +
- wim->hdr.blob_table_reshdr.size_in_wim;
+ wim->hdr.blob_table_reshdr.size_in_wim;
(void)read_integrity_table(wim,
old_blob_table_end - WIM_HEADER_DISK_SIZE,
&old_integrity_table);
* reading the WIM from a pipe. This copy of the XML data is ignored if the
* WIM is read from a seekable file (not a pipe).
*
+ * - Solid resources are not allowed. Each blob is always stored in its own
+ * resource.
+ *
* - The format of resources, or blobs, has been modified to allow them to be
* used before the "blob table" has been read. Each blob is prefixed with a
* `struct pwm_blob_hdr' that is basically an abbreviated form of `struct
WARNING("Creating a pipable WIM, which will "
"be incompatible\n"
- " with Microsoft's software (wimgapi/imagex/Dism).");
+ " with Microsoft's software (WIMGAPI/ImageX/DISM).");
/* At this point, the header at the beginning of the file has already
* been written. */
/* For efficiency, when wimlib adds an image to the WIM with
- * wimlib_add_image(), the SHA-1 message digests of files is not
+ * wimlib_add_image(), the SHA-1 message digests of files are not
* calculated; instead, they are calculated while the files are being
* written. However, this does not work when writing a pipable WIM,
* since when writing a blob to a pipable WIM, its SHA-1 message digest
if (ret)
return ret;
- /* Write blobs needed for the image(s) being included in the output WIM,
- * or blobs needed for the split WIM part. */
- return write_file_blobs(wim, image, write_flags,
- num_threads, blob_list_override,
- blob_table_list_ret);
+ /* Write file data needed for the image(s) being included in the output
+ * WIM, or file data needed for the split WIM part. */
+ return write_file_data(wim, image, write_flags,
+ num_threads, blob_list_override,
+ blob_table_list_ret);
/* The blob table, XML data, and header at end are handled by
* finish_write(). */
if (write_flags & WIMLIB_WRITE_FLAG_SOLID)
DEBUG("\tSOLID");
+ if (write_flags & WIMLIB_WRITE_FLAG_SEND_DONE_WITH_FILE_MESSAGES)
+ DEBUG("\tSEND_DONE_WITH_FILE_MESSAGES");
+
+ if (write_flags & WIMLIB_WRITE_FLAG_NO_SOLID_SORT)
+ DEBUG("\tNO_SOLID_SORT");
+
if (write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR)
DEBUG("\tFILE_DESCRIPTOR");
if (total_parts != 1)
wim->hdr.boot_idx = 0;
- /* Initialize output file descriptor. */
+ /* Set up output file descriptor. */
if (write_flags & WIMLIB_WRITE_FLAG_FILE_DESCRIPTOR) {
- /* File descriptor was explicitly provided. Return error if
- * file descriptor is not seekable, unless writing a pipable WIM
- * was requested. */
- wim->out_fd.fd = *(const int*)path_or_fd;
- wim->out_fd.offset = 0;
+ /* File descriptor was explicitly provided. */
+ filedes_init(&wim->out_fd, *(const int *)path_or_fd);
if (!filedes_is_seekable(&wim->out_fd)) {
+ /* The file descriptor is a pipe. */
ret = WIMLIB_ERR_INVALID_PARAM;
if (!(write_flags & WIMLIB_WRITE_FLAG_PIPABLE))
goto out_restore_hdr;
if (ret)
goto out_restore_hdr;
- /* Write file blobs and metadata resources. */
+ /* Write file data and metadata resources. */
if (!(write_flags & WIMLIB_WRITE_FLAG_PIPABLE)) {
/* Default case: create a normal (non-pipable) WIM. */
- ret = write_file_blobs(wim, image, write_flags,
- num_threads,
- blob_list_override,
- &blob_table_list);
+ ret = write_file_data(wim, image, write_flags,
+ num_threads,
+ blob_list_override,
+ &blob_table_list);
if (ret)
goto out_restore_hdr;
goto out_restore_physical_hdr;
}
- ret = wim_write_blob_list(wim, &blob_list, write_flags,
- num_threads, &filter_ctx);
+ ret = write_file_data_blobs(wim, &blob_list, write_flags,
+ num_threads, &filter_ctx);
if (ret)
goto out_truncate;