Eric Biggers [Thu, 20 Feb 2014 01:59:17 +0000 (19:59 -0600)]
mount_image.c: Don't assume inode is resolved
The code should no longer assume that all streams have been resolved
before mounting, since now errors are issued when accessing files with
missing streams.
However this line still appeared to work correctly because FUSE seems to
always call getattr(), which results in stream resolution in
wim_pathname_to_stream(), before unlinking.
Eric Biggers [Mon, 20 Jan 2014 06:55:28 +0000 (00:55 -0600)]
init_upcase(): Fix and cleanup
The previous code used the wrong array size and consequently left 0's in
entries 0x8000 and above. This would incorrectly cause all characters in
that range to be considered equal to each other case-insensitively. Fix
it and clean up the code.
Note: the code still does not do real UTF-16 case folding.
Eric Biggers [Wed, 15 Jan 2014 18:07:06 +0000 (12:07 -0600)]
win32_apply.c: Simplify and fix win32_create_file()
win32_create_file() can be simplified by using CREATE_NEW and attempting
to delete the existing file if it exists.
This commit also adds FILE_FLAG_OPEN_REPARSE_POINT to the CreateFile()
call. This is the equivalent to the O_NOFOLLOW addition to the UNIX
version in the previous commit.
Note that MS has contradictory documentation for the combination of
CREATE_ALWAYS and FILE_FLAG_OPEN_REPARSE_POINT, which further supports
the CREATE_NEW method changed to in this commit.
Eric Biggers [Wed, 15 Jan 2014 17:33:55 +0000 (11:33 -0600)]
unix_apply.c: Use O_NOFOLLOW when opening files
If the destination directory contained a symbolic link and wimlib
attempted to extract a regular file to the same location, it would write
the file to the target of the symbolic link, which could point to an
arbitrary location. Fix this by passing O_NOFOLLOW to open().
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.