Eric Biggers [Tue, 16 Dec 2014 00:20:29 +0000 (18:20 -0600)]
Remove support for --enable-more-assertions configure option
The only uses of wimlib_assert2() were in compression code (where
problems are relatively easy to detect), and this option was disabled by
default anyway. Simplify by just having one kind of assertion.
Eric Biggers [Sun, 14 Dec 2014 01:40:02 +0000 (19:40 -0600)]
tagged_items.c: length should be rounded up when adding item
Also 0-fill the new item, including the padding.
These changes have no effect on the only caller of
inode_add_tagged_item() but should be made for correctness in case this
function gets more callers in the future.
Eric Biggers [Sat, 13 Dec 2014 19:38:31 +0000 (13:38 -0600)]
new internal image deletion helper
Define a new helper function delete_wim_image() and use in
wimlib_delete_image() and in the error path of
wimlib_add_image_multisource().
This fixes a bug: current_image wasn't being reset to WIMLIB_NO_IMAGE in
the error path of wimlib_add_image_multisource(). Bad things would
happen if the library user then continued to use the same WIMStruct.
Eric Biggers [Wed, 10 Dec 2014 01:40:17 +0000 (19:40 -0600)]
portability and compression cleanups
- Split compiler.h into compiler.h and compiler-gcc.h
- Compile with -std=c99. Some GCC extensions are still used but they are
explicitly defined in compiler-gcc.h.
- Add get_unaligned_uXX_le() and put_unaligned_uXX_le() helpers
- Faster lz_copy() in some cases
- Faster lz_extend() in some cases
- New bitops.h header
Eric Biggers [Fri, 7 Nov 2014 00:50:18 +0000 (18:50 -0600)]
wimlib_export_image(): cleanups and fixes for rollback
- rollback setting of wimboot flag correctly (actually, don't even set it
until we've succeeded)
- on rollback, free wim_lookup_table_entries in the destination if and
only if they were exported. Before it was possible for one to be freed
if it happened to have had 0 reference count before.
Eric Biggers [Wed, 5 Nov 2014 01:25:55 +0000 (19:25 -0600)]
Fix for rewriting uncompressed resources when exporting from solid WIM
The changes from commit 1ba2a3422b ("Workaround for WOF incompatibility")
are resulting in excessive, expensive decompressions when exporting small
incompressible files from solid blocks. For now, add an optimization for
single chunk resources which prevents this common case from triggering
the degenerate behavior.
Eric Biggers [Sun, 26 Oct 2014 23:47:12 +0000 (18:47 -0500)]
Remove "memory exhausted" error messages
Calling code checks for NULL returns anyway, and in the case of
allocating chunk compressors there is a fallback so there shouldn't
be an error message.
Eric Biggers [Tue, 14 Oct 2014 02:26:40 +0000 (21:26 -0500)]
wimboot.c: Dynamically size extents and drive_info arrays
I figured a limit of 8 partitions is good enough, but for some reason
Windows returns 4 times as many partitions as there actually are.
Whatever, just remove the fixed limit.
It isn't necessary to check for permission to modify a WIM for in-memory
operations such as wimlib_add_image(), wimlib_update_image(), and
wimlib_delete_image(). It is only when the user attempts to modify an
on-disk WIM file using wimlib_overwrite() --- or when the user explicitly
opens an on-disk WIM file for write access --- that write permissions
need to be checked.
This change prevents the library from getting in the way of "unusual" use
cases, such as making last-minute changes to a WIM before extracting it
even when the underlying file is located on read-only media, which
otherwise are fully supported by the existing code.
Also part of this change is the removal of can_delete_from_wim(). This
function did a lot of work (decompressing each metadata resource) that
usually turns out to be a waste of time. And it turns out that it really
needs to be called for any 'wimlib_update_command', including "add" and
"rename", because both "add" and "rename" can cause files to be deleted
(specifically, replaced). But this is gone too far. Instead, just get
rid of can_delete_from_wim() completely: it's not needed if we retain
0-reference streams when not recalculating reference counts as part of
wimlib_write() anyway.
Eric Biggers [Sun, 28 Sep 2014 03:55:57 +0000 (22:55 -0500)]
Workaround for WOF incompatibility
If a stream has compressed_size == uncompressed_size, WOF assumes it's
uncompressed. As a workaround, we need to re-write the stream as uncompressed
if this ever happens.
This requires adjusting the DONE_WITH_FILE messages to be fired after writing
each stream, not after reading each stream.
We also need to loosen the check for whether the input stream is in a solid
block or not.
Finally, this commit also makes the DONE_WITH_FILE messages work in more cases
--- when appending to a WIM, and when the file hashes are already known.
Eric Biggers [Sat, 6 Sep 2014 06:08:03 +0000 (01:08 -0500)]
lzx-decompress.c: Don't allow using offsets of 0
This can happen if an uncompressed block is present, since then the match
offset LRU queue is filled directly from the input buffer. Too-large
offsets were already checked later, but offsets of 0 would cause
uninitialized memory to remain in the output buffer.