Eric Biggers [Tue, 14 Jan 2014 22:15:40 +0000 (16:15 -0600)]
Refactor read_dentry_tree()
read_dentry_tree() now includes code previously in
read_metadata_resource(), and wraps around read_dentry_tree_recursive()
which is similar to the old read_dentry_tree().
This removes the declaration of a 'struct wim_dentry' on the stack in
read_dentry_tree() and a subsequent copy of the structure, and also
condenses two dentry allocation sites into one.
This also moves the check for '.' and '..' entries to immediately when
reading the dentry tree rather than just before extraction.
Eric Biggers [Tue, 14 Jan 2014 20:46:18 +0000 (14:46 -0600)]
read_metadata_resource(): Don't decrement stream refcnts in error path
If a metadata resource could not be fully read, the code would decrement
the reference counts of streams referenced by the tree. However this
should not be done, as there is no corresponding increment.
Eric Biggers [Mon, 13 Jan 2014 04:50:01 +0000 (22:50 -0600)]
Refactor some of the dentry, inode, and lookup table code
- Remove hardlink.c. Its code is now split between inode.c and
inode_fixup.c.
- Factor inode-related code out of dentry.h and dentry.c and place in
inode.h and inode.c.
- Move wimlib_reference_resource_files() and wimlib_reference_resources()
implementations to reference.c.
- Move wimlib_iterate_dir_tree() implementation to iterate_dir.c.
- Move wimlib_reference_template_image() to template.c.
- Move wim_pathname_to_stream() to dentry.c as it deals primarily with
path walking.
- Remove 'unhashed_streams' member from 'struct wim_lookup_table'. It
now is stored separately in 'struct add_image_params'.
- Rename some *resource functions to *stream.
- Rename set_dentry_name() => dentry_set_name().
- Move 'struct ntfs_location' definition to ntfs_3g.h.
- Move UNIX data definitions to new header unix_data.h.
- Move case sensitivity definitions to new header case.h.
Eric Biggers [Sun, 12 Jan 2014 22:49:09 +0000 (16:49 -0600)]
LZMS: Do not do x86 translations starting in last 16 bytes
The value used before (last 11 bytes) was wrong; based on tests with the
MS implementation no translation can occur following an opcode starting
in the last 16 bytes of a data block.
Tested with two different length opcodes to make sure that it's the start
of the opcode that matters, not the start of the translated address.
Eric Biggers [Thu, 9 Jan 2014 21:04:11 +0000 (15:04 -0600)]
lz_sarray: Use 16-bit length
This saves 4 bytes of memory per position and only decreases the
compression ratio on very repetitive files (with matches of length >
65535), and even then only slightly. Performance is not significantly
affected but may be slightly improved due to better use of cache.
Eric Biggers [Tue, 7 Jan 2014 20:33:56 +0000 (14:33 -0600)]
Handle streams with uncompressed size 4 GiB consistently
The read code went to 8-byte chunk entries for uncompressed size > 4294967296, whereas the write code went to 8-byte chunk entries for
uncompressed size >= 4294967296. Change both to >= 4294967296.
Confirmed that WIMGAPI (Windows 7) seems to have this behavior.
Eric Biggers [Tue, 7 Jan 2014 19:20:38 +0000 (13:20 -0600)]
read_stream_list(): Spill huge data ranges array onto heap
There can be thousands of streams packed into a single resource, so it's
a good idea to check if the data_ranges array is really small enough to
be allocated on the stack or not, and if not, allocate it on the heap
instead.
For readability and to create a temporary frame for alloca(), place the
relevant code in a new function read_packed_streams().