# ----------------------------- Other options ---------------------------------
-AC_MSG_CHECKING([whether to include debugging messages])
-AC_ARG_ENABLE([debug],
- AS_HELP_STRING([--enable-debug], [include debugging messages]),
- [ENABLE_DEBUG=$enableval],
- [ENABLE_DEBUG=no])
-AC_MSG_RESULT([$ENABLE_DEBUG])
-if test "$ENABLE_DEBUG" = "yes"; then
- AC_DEFINE([ENABLE_DEBUG], [1], [Define to 1 if including debug messages])
-fi
-
AC_MSG_CHECKING([whether to include error messages])
AC_ARG_ENABLE([error_messages],
AS_HELP_STRING([--disable-error-messages], [do not compile in error messsages]),
# define WARNING_WITH_ERRNO(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
#endif /* !ENABLE_ERROR_MESSAGES */
-#ifdef ENABLE_DEBUG
-extern void
-wimlib_debug(const tchar *file, int line, const char *func,
- const tchar *format, ...);
-# define DEBUG(format, ...) \
- wimlib_debug(T(__FILE__), __LINE__, __func__, T(format), ## __VA_ARGS__)
-
-#else
-# define DEBUG(format, ...) dummy_tprintf(T(format), ## __VA_ARGS__)
-#endif /* !ENABLE_DEBUG */
-
extern void
print_byte_field(const u8 *field, size_t len, FILE *out);
BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZX != 2);
BUILD_BUG_ON(WIMLIB_COMPRESSION_TYPE_LZMS != 3);
rdesc->compression_type = le32_to_cpu(hdr.compression_format);
-
rdesc->chunk_size = le32_to_cpu(hdr.chunk_size);
-
- DEBUG("Solid resource %zu/%zu: %"PRIu64" => %"PRIu64" "
- "(%"TS"/%"PRIu32") @ +%"PRIu64"",
- i + 1, num_rdescs,
- rdesc->uncompressed_size,
- rdesc->size_in_wim,
- wimlib_get_compression_type_string(rdesc->compression_type),
- rdesc->chunk_size,
- rdesc->offset_in_wim);
}
return 0;
}
struct wim_resource_descriptor **cur_solid_rdescs = NULL;
size_t cur_num_solid_rdescs = 0;
- DEBUG("Reading blob table.");
-
/* Calculate the number of entries in the blob table. */
num_entries = wim->hdr.blob_table_reshdr.uncompressed_size /
sizeof(struct blob_descriptor_disk);
/* Get the resource header */
get_wim_reshdr(&disk_entry->reshdr, &reshdr);
- DEBUG("reshdr: size_in_wim=%"PRIu64", "
- "uncompressed_size=%"PRIu64", "
- "offset_in_wim=%"PRIu64", "
- "flags=0x%02x",
- reshdr.size_in_wim, reshdr.uncompressed_size,
- reshdr.offset_in_wim, reshdr.flags);
-
/* Ignore SOLID flag if it isn't supposed to be used in this WIM
* version. */
if (wim->hdr.wim_version == WIM_VERSION_DEFAULT)
* this overrides the actual locations of the metadata
* resources themselves in the WIM file as well as any
* information written in the XML data. */
- DEBUG("Found metadata resource for image %"PRIu32" at "
- "offset %"PRIu64".",
- image_index + 1,
- reshdr.offset_in_wim);
-
wim->image_metadata[image_index++]->metadata_blob = cur_blob;
} else {
/* Blob table entry for a non-metadata blob. */
num_wrong_part_blobs);
}
- DEBUG("Done reading blob table.");
wim->blob_table = table;
ret = 0;
goto out_free_buf;
}
}
- DEBUG("Writing WIM blob table (size=%zu, offset=%"PRIu64")",
- table_size, out_fd->offset);
-
table_buf = MALLOC(table_size);
if (table_buf == NULL) {
ERROR("Failed to allocate %zu bytes for temporary blob table",
NULL,
write_resource_flags);
FREE(table_buf);
- DEBUG("ret=%d", ret);
return ret;
}
return;
if (ctx->num_started_threads != 0) {
- DEBUG("Terminating %u compressor threads", ctx->num_started_threads);
message_queue_terminate(&ctx->chunks_to_compress_queue);
for (i = 0; i < ctx->num_started_threads; i++)
if (num_threads == 0)
num_threads = get_available_cpus();
- if (num_threads == 1) {
- DEBUG("Only 1 thread; Not bothering with "
- "parallel chunk compressor.");
+ if (num_threads == 1)
return -1;
- }
if (max_memory == 0)
max_memory = get_available_memory();
desired_num_threads, num_threads);
}
- if (num_threads == 1) {
- DEBUG("Only 1 thread; Not bothering with "
- "parallel chunk compressor.");
+ if (num_threads == 1)
return -2;
- }
ret = WIMLIB_ERR_NOMEM;
ctx = CALLOC(1, sizeof(*ctx));
ctx->num_started_threads < num_threads;
ctx->num_started_threads++)
{
- DEBUG("pthread_create thread %u of %u",
- ctx->num_started_threads + 1, num_threads);
ret = pthread_create(&ctx->thread_data[ctx->num_started_threads].thread,
NULL,
compressor_thread_proc,
int ret;
struct wim_dentry *root;
- DEBUG("Reading dentry tree (root_offset=%"PRIu64")", root_offset);
-
ret = read_dentry(buf, buf_len, &root_offset, &root);
if (ret)
return ret;
u8 *
write_dentry_tree(struct wim_dentry *root, u8 *p)
{
- DEBUG("Writing dentry tree.");
-
- wimlib_assert(root != NULL);
-
/* write root dentry and end-of-directory entry following it */
p = write_dentry(root, p);
*(u64*)p = 0;
bool wimlib_print_errors = false;
FILE *wimlib_error_file = NULL; /* Set in wimlib_global_init() */
static bool wimlib_owns_error_file = false;
-#endif
-#if defined(ENABLE_ERROR_MESSAGES) || defined(ENABLE_DEBUG)
static void
wimlib_vmsg(const tchar *tag, const tchar *format, va_list va, bool perror)
{
-#ifndef ENABLE_DEBUG
if (!wimlib_print_errors)
return;
-#endif
int errno_save = errno;
fflush(stdout);
tfputs(tag, wimlib_error_file);
fflush(wimlib_error_file);
errno = errno_save;
}
-#endif
-#ifdef ENABLE_ERROR_MESSAGES
void
wimlib_error(const tchar *format, ...)
{
wimlib_vmsg(T("\r[WARNING] "), format, va, true);
va_end(va);
}
-
-#endif
-
-#ifdef ENABLE_DEBUG
-void wimlib_debug(const tchar *filename, int line, const char *func,
- const tchar *format, ...)
-{
- va_list va;
- tchar buf[tstrlen(filename) + strlen(func) + 30];
-
- tsprintf(buf, T("[%"TS" %d] %s(): "), filename, line, func);
- va_start(va, format);
- wimlib_vmsg(buf, format, va, false);
- va_end(va);
-}
-#endif
+#endif /* ENABLE_ERROR_MESSAGES */
void
print_byte_field(const u8 *field, size_t len, FILE *out)
BUILD_BUG_ON(sizeof(struct wim_header_disk) != WIM_HEADER_DISK_SIZE);
- DEBUG("Reading WIM header from \"%"TS"\"", filename);
-
ret = full_read(in_fd, &disk_hdr, sizeof(disk_hdr));
if (ret)
goto read_error;
hdr->image_count = le32_to_cpu(disk_hdr.image_count);
- DEBUG("part_number = %u, total_parts = %u, image_count = %u",
- hdr->part_number, hdr->total_parts, hdr->image_count);
-
if (unlikely(hdr->image_count > MAX_IMAGES)) {
ERROR("\"%"TS"\": Invalid image count (%u)",
filename, hdr->image_count);
struct wim_header_disk disk_hdr _aligned_attribute(8);
int ret;
- DEBUG("Writing %sWIM header at offset %"PRIu64,
- ((hdr->magic == PWM_MAGIC) ? "pipable " : ""),
- offset);
-
disk_hdr.magic = cpu_to_le64(hdr->magic);
disk_hdr.hdr_size = cpu_to_le32(sizeof(struct wim_header_disk));
disk_hdr.wim_version = cpu_to_le32(hdr->wim_version);
if (wim->hdr.integrity_table_reshdr.uncompressed_size < 8)
goto invalid;
- DEBUG("Reading integrity table.");
-
ret = wim_reshdr_to_data(&wim->hdr.integrity_table_reshdr, wim, &buf);
if (ret)
return ret;
table->num_entries = le32_to_cpu(table->num_entries);
table->chunk_size = le32_to_cpu(table->chunk_size);
- DEBUG("table->size = %u, table->num_entries = %u, "
- "table->chunk_size = %u",
- table->size, table->num_entries, table->chunk_size);
-
if (table->size != wim->hdr.integrity_table_reshdr.uncompressed_size ||
table->size != (u64)table->num_entries * SHA1_HASH_SIZE + 12 ||
table->chunk_size == 0 ||
int ret;
u32 new_table_size;
- DEBUG("Writing integrity table "
- "(new_blob_table_end=%"PRIu64", old_blob_table_end=%"PRIu64")",
- new_blob_table_end, old_blob_table_end);
-
wimlib_assert(old_blob_table_end <= new_blob_table_end);
ret = calculate_integrity_table(&wim->out_fd, new_blob_table_end,
NULL,
0);
FREE(new_table);
- DEBUG("ret=%d", ret);
return ret;
}
struct integrity_table *table;
u64 end_blob_table_offset;
- if (!wim_has_integrity_table(wim)) {
- DEBUG("No integrity information.");
+ if (!wim_has_integrity_table(wim))
return WIM_INTEGRITY_NONEXISTENT;
- }
end_blob_table_offset = wim->hdr.blob_table_reshdr.offset_in_wim +
wim->hdr.blob_table_reshdr.size_in_wim;
metadata_blob = imd->metadata_blob;
- DEBUG("Reading metadata resource (size=%"PRIu64").", metadata_blob->size);
-
/* Read the metadata resource into memory. (It may be compressed.) */
ret = read_blob_into_alloc_buf(metadata_blob, &buf);
if (ret)
imd->root_dentry = root;
imd->security_data = sd;
INIT_LIST_HEAD(&imd->unhashed_blobs);
- DEBUG("Done parsing metadata resource.");
return 0;
out_free_dentry_tree:
struct wim_security_data *sd;
struct wim_image_metadata *imd;
- DEBUG("Preparing metadata resource for image %d", image);
-
ret = select_wim_image(wim, image);
if (ret)
return ret;
sd->total_length = le32_to_cpu(sd_disk->total_length);
sd->num_entries = le32_to_cpu(sd_disk->num_entries);
- DEBUG("Reading security data: num_entries=%u, total_length=%u",
- sd->num_entries, sd->total_length);
-
/* Length field of 0 is a special case that really means length
* of 8. */
if (sd->total_length == 0)
write_wim_security_data(const struct wim_security_data * restrict sd,
u8 * restrict p)
{
- DEBUG("Writing security data (total_length = %"PRIu32", num_entries "
- "= %"PRIu32")", sd->total_length, sd->num_entries);
-
u8 *orig_p = p;
struct wim_security_data_disk *sd_disk = (struct wim_security_data_disk*)p;
u32 num_entries = sd->num_entries;
*p++ = 0;
wimlib_assert(p - orig_p == sd->total_length);
-
- DEBUG("Successfully wrote security data.");
return p;
}
sd->descriptors[sd->num_entries] = descr_copy;
sd->sizes[sd->num_entries] = size;
sd->num_entries++;
- DEBUG("There are now %u security descriptors", sd->num_entries);
bret = insert_sd_node(sd_set, new);
wimlib_assert(bret);
security_id = new->security_id;
wim_target_path = add_cmd->add.wim_target_path;
config_file = add_cmd->add.config_file;
- DEBUG("fs_source_path=\"%"TS"\", wim_target_path=\"%"TS"\", add_flags=%#x",
- fs_source_path, wim_target_path, add_flags);
-
memset(¶ms, 0, sizeof(params));
#ifdef WITH_NTFS_3G
flags = delete_cmd->delete_.delete_flags;
wim_path = delete_cmd->delete_.wim_path;
- DEBUG("Deleting WIM path \"%"TS"\" (flags=%#x)", wim_path, flags);
-
tree = get_dentry(wim, wim_path, WIMLIB_CASE_PLATFORM_DEFAULT);
if (!tree) {
/* Path to delete does not exist in the WIM. */
return ret;
}
-static inline const tchar *
-update_op_to_str(int op)
-{
- switch (op) {
- case WIMLIB_UPDATE_OP_ADD:
- return T("add");
- case WIMLIB_UPDATE_OP_DELETE:
- return T("delete");
- case WIMLIB_UPDATE_OP_RENAME:
- return T("rename");
- default:
- wimlib_assert(0);
- return NULL;
- }
-}
-
static bool
have_command_type(const struct wimlib_update_command *cmds, size_t num_cmds,
enum wimlib_update_op op)
info.update.total_commands = num_cmds;
ret = 0;
for (size_t i = 0; i < num_cmds; i++) {
- DEBUG("Executing update command %zu of %zu (op=%"TS")",
- i + 1, num_cmds, update_op_to_str(cmds[i].op));
info.update.command = &cmds[i];
if (update_flags & WIMLIB_UPDATE_FLAG_SEND_PROGRESS) {
ret = call_progress(wim->progfunc,
if (update_flags & ~WIMLIB_UPDATE_FLAG_SEND_PROGRESS)
return WIMLIB_ERR_INVALID_PARAM;
- DEBUG("Updating image %d with %zu commands", image, num_cmds);
-
/* Load the metadata for the image to modify (if not loaded already) */
ret = select_wim_image(wim, image);
if (ret)
goto out;
- DEBUG("Preparing %zu update commands", num_cmds);
-
/* Make a copy of the update commands, in the process doing certain
* canonicalizations on paths (e.g. translating backslashes to forward
* slashes). This is done to avoid modifying the caller's copy of the
goto out_free_cmds_copy;
/* Actually execute the update commands. */
- DEBUG("Executing %zu update commands", num_cmds);
ret = execute_update_commands(wim, cmds_copy, num_cmds, update_flags);
if (ret)
goto out_free_cmds_copy;
struct image_info *image_info;
int ret;
- DEBUG("Copying XML data between WIM files for source image %d.", image);
-
wimlib_assert(old_wim_info != NULL);
wimlib_assert(image >= 1 && image <= old_wim_info->num_images);
wim_info = *wim_info_p;
wimlib_assert(image >= 1 && image <= wim_info->num_images);
- DEBUG("Deleting image %d from the XML data.", image);
destroy_image_info(&wim_info->images[image - 1]);
out_buffer_free:
xmlBufferFree(buf);
out:
- DEBUG("ret=%d", ret);
return ret;
out_write_error:
u8 *xml_data;
size_t xml_len;
- DEBUG("Writing WIM XML data (image=%d, offset=%"PRIu64")",
- image, wim->out_fd.offset);
-
ret = prepare_wim_xml_data(wim, image, total_bytes,
&xml_data, &xml_len);
if (ret)
NULL,
write_resource_flags);
FREE(xml_data);
- DEBUG("ret=%d", ret);
return ret;
}
xml_reshdr = &wim->hdr.xml_data_reshdr;
- DEBUG("Reading XML data.");
*bufsize_ret = xml_reshdr->uncompressed_size;
return wim_reshdr_to_data(xml_reshdr, wim, buf_ret);
}