summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2019-11-24Cleanup: remove the entirely redundant sqfs_has_xattr functionDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-24Fix: Move LZO compressor from libsquashfs to libcommonDavid Oberhollenzer
The liblzo2 library is licensed under GPLv2, so it is not possible to distribute binaries of libsquashfs that link against liblzo2 under LGPL. This commit moves the LZO compressor implementation to libcommon, where this isn't a problem, since the tools themselves are licensed under GPLv3. It removes the ability of libsquashfs to read or generate LZO compressed SquashFS images, but the tools still can. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Fix: add missing null-terminator in getline implementationDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Add windows implementation for chdir in libcompatDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Move some unix header inclusions to compat.hDavid Oberhollenzer
In most cases, including unistd.h and fcntl.h was a left over anyway. In the cases where it was not, move it to compat.h. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-22Add fchownat/fchmodat mockups to libcompat for WindowsDavid Oberhollenzer
Not pretty, but definitely prettier than #ifdef hell. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-22Cleanup: move all the compatibillity fluff to a dedicated "libcompat"David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-22Ensure that tar2sqfs & sqfs2tar set stdin/out to binary modeDavid Oberhollenzer
As usual, Windows has things different and is the platform where the problem was actually discovered. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-18Add Windows implementation for mkdir_pDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-18Convert the remaining size_t printf format specifiers in libcommonDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-18Remove directory stack codeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-15Extend is_filename_sane reserved character/name checkDavid Oberhollenzer
- Instead of an open coded version, check against a list of bad names. On windows, the comparison needs to be done case insensitive. - If compiling for Windows, include the magic DOS device names in that list. - Also classify filenames as 'insane' if they contain back slashes, on all platforms. - If compiling for Windows, check for reserved characters. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-15Fix build on BSD systemsAlyssa Ross
I tested FreeBSD, DragonflyBSD, NetBSD and OpenBSD and the endian macros weren't necessary (and in fact caused errors) on all of them. Because OpenBSD ships with an ancient GCC that doesn't support the checked addition/multiplication builtins, the build there would fail unless built with CC=cc or CC=clang. I changed configure.ac to prefer cc over gcc, so that the distribution's compiler preference is respected. (The default is [gcc cc]). I had to move AC_PROG_CC above LT_INIT because otherwise LT_INIT would run AC_PROG_CC first, and we wouldn't have a chance to use non-default parameters.
2019-11-06Cleanup: remove some no longer needed header inclusionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Cleanup: remove BSD style __prognameDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Cleanup: remove unused stdout sqfs_file_t wrapperDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Fix: use size_t printf macro in tar PAX header writerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Remove raw file descriptors from tar read pathDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-06Remove raw file descriptors from unpack write pathsDavid Oberhollenzer
Instead, use stdio FILE pointers. On POSIX systems, use fileno to get the file descriptor and hopefully create sparase files. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-28Add macro for printf format specifier for size_tDavid Oberhollenzer
The MSVC runtime is a wierdo C89 platform with some cherry picked features from C99 (which does not include the "%zu" format specifier). This commit adds a macro with a size dependend format specifier to be used instead. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-28Add fallback implementation for getsubopt()David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-28Add a minimal fallback implementation for getline()David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-28Add libutil implementation for strndup in case it isn't availableDavid Oberhollenzer
"Some" "non-POSIX systems" don't have that. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-23For Windows builds, remove the so-version, link libgcc staticallyDavid Oberhollenzer
The -static-libgcc flag has to be passed through the compiler with a "-Wc," prefix, because libtool tries to be clever about linker flags. If added directly to LDFLAGS, libtool removes it. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-23Fix sqfs_dir_writer_add_entry behaviour on empty stringsDavid Oberhollenzer
SquashFS cannot represent empty string file names in the directory entry structure, so reject them and report an error. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-23bugfix: Check no_xattr flagUzi Erdenebileg
2019-10-11Add the required libtool magic to build a Windows DLLDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-11Remove usage of strchrnul from libsquashfsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-11Add Windows implementation for sqfs_file_tDavid Oberhollenzer
This commit moves the generic unix implementation into a "unix" subdirectory and adds a "win32" subdirectory with a winapi based implementation. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Remove maximum queue backlog guestimation.David Oberhollenzer
Partially revers 2b7df394057c013fd042b85a4d5fd0104ba4a9be. Making the queue fill the entire RAM had some unintended side effects that need further investigation. For now, revert back to the old behaviour. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Fix: propperly clear index entryDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Fix storing of the directory index in the inode, size accountingDavid Oberhollenzer
After the last modification, the directory index size counter no longer counts the size, but the number of index entries. To avoid future confusion, remove the thing entirely and compute the size on the fly. Furthermore, eliminate unaligned memory writes and fix the darn counter once again. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Fix recovery of directory index in inode readerDavid Oberhollenzer
Apparently mksquashfs writes an actual usage count (1 = 1 entry, 2 = 2 entries; i.e. NOT off by one). Also, if it does happen to be garbage, guard against an overflow. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Fix unaligned reads in write_dir_indexDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-08Make sure the statistics counters are initialized to 0David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: consistent, fixed size data types for generic flag fieldsDavid Oberhollenzer
Instead of using int or unsigned int for generic function flag arguments, consistently use an unsigned, fixed size type. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Do an explicit "is filename sane" checkDavid Oberhollenzer
Until now, filenames containing '/' or being equal to '..' or '.' where not handled explicitly, because they are canonicalized later, which will then fail. This commit adds an explicit check to make those fail immediately with a clear, specific error message. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move libutil related headers to "util" sub directoryDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move write_data to libtarDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Replace write_data in libcommon with less generic, opencoded oneDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Move print_version declaration from util.h to common.hDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move directory handling code to libcommonDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move read_data function to libtarDavid Oberhollenzer
Its the only user. The other code doesn't touch raw file descriptors anymore. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: Move padd_file function to libtarDavid Oberhollenzer
It's only ever used for padding tarballs. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Add an implementation for an sqfs_file_t writing to stdoutDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Rename libsqfshelper to libcommonDavid Oberhollenzer
That is IMO less confusing and express what it is (i.e. what it has become) more clearly, i.e. common code shared by the utilities. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Rename "hihglevel.h" to the more appropriate "common.h"David Oberhollenzer
It only contains helpers for _common_ stuff for all the utilities. The actual high level stuff has been moved to libsquashfs a while ago. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Fix spelling of "align"David Oberhollenzer
Before the misspelled version has a chance to become stable API. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Improve ABI backward & forward compatibillityDavid Oberhollenzer
- Padd the compressor config union - 128 bytes aught to be enough for everyone, i.e. future compressors. - Insist that the padding space is initialized to 0. If a field gets added to an existing compressor, it can test for 0 as a sentinel value. - Add a size field to the hook structure, aka "the Microsoft way". - The explanation is in the comment. - Don't make the Microsoft mistake of checking for >=, insist on *exact* size match. Future users will need a fallback if their hooks are rejected. But at least they will be rejected instead of silently not being used. - Add an unsupported flag check to the dir tree reader. - Add a basic abi unit test that, for now, checks the size of the compressor config struct fields. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-06Fix missing stdlib.h includeDavid Oberhollenzer
Problem only showed up on a different machine and went unnoticed earlier. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>