aboutsummaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2019-07-12Add generic support for reading files without fragmentsDavid Oberhollenzer
This commit extends the special case handling for sparse files to generically support reading files that don't have a fragment but instead have a trunkated final block. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-12Simplify writer code for files without a fragmentDavid Oberhollenzer
The data writer sparse block code can take advantage that it can add a block size instead of a fragment and doesn't have to initialize the framgent location. In return, the tree node to inode serialization code doesn't need a special case for sparse file anymore and can now also handle files that are forced to not have a fragment. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-12fstree: mknode: initialize fragment data, add extra blocksize slotDavid Oberhollenzer
This commit makes sure that regular file tree nodes have one more slot than necessary to support files that don't have fragments. Also, it initializes the fragment data, which should help to deduplicate some code ahead. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-10Fix dirindex writing for ext dir inodeDavid Oberhollenzer
This commit makes sure we write the index count to the inode before writing out the inode itself. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-10libsqfs: eleminate use of temporary fileDavid Oberhollenzer
Tell the directory writer to keep the directory blocks in memory, then write them out once everything is done and the inodes are all written out. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-10Add a way to keep meta data blocks in memoryDavid Oberhollenzer
Instead of writing meta data blocks directly to disk, the writer can now alternatively keep the blocks in memory until explicitly told to write to disk. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-10Make coverity happyDavid Oberhollenzer
The string is actually always null-terminated, since the calloc above adds one more byte than what we tell readlink about. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-09Sanity check id table size read from super blockDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-07Fix regression in fstree_from_file device node formatDavid Oberhollenzer
The format is documented as "<c|b> major minor" but the parser was accidentally changed to require a colon in between. Fixes: 9864ea5b2045f4bd72633152d71dd1c7f8b0b7f9 Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-07Actually encode/decode directory inode difference as signedDavid Oberhollenzer
The directory listing stores a signed difference of the inode number. Actually treating it as signed saves emitting extra headers if hard links or file deduplication are finally implemented. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-07read_inode: determine mode bits from inode typeDavid Oberhollenzer
Instead of insisting that mode bits and inode type match up, determine ignore the mode bits and determine them from the inode type. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-07Cleanup: merge inode type selection in inode writerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-06Cleanup: split off inode writer block list and dir index codeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04Fix: simplify deduction logic for squashfs inode typeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04Fix: check block_log range before deriving block size from itDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04Fix: possible out of bounds read in libcompress.aDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04Fix: actually check return value when writing xattrsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04tar2sqfs: repack extended attributes into squashfs filesystemDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04libtar: add support for xattr extensionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-04Fix composition order of prefix + name for ustarDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-03cleanup: move tree node from path function to libfstree.aDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-03Add no-skip option to sqfs2tarDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-03tar writer: replace PAX headers with GNU extensionsDavid Oberhollenzer
Some experiments seem to indicate that the various GNU extensions are more widely supported than their POSIX equivalents[1]. Possibly because they are easier to implement and possibly because of the wide spread use of GNU tar. This commit replaces the PAX writer in the write_tar_header implementation with a GNU extension based writer. The writer is also cleaned up by removing all global state. The record counter is moved outside into the tar2sqfs program and passed in as function argument. [1] https://dev.gentoo.org/~mgorny/articles/portability-of-tar-features.html Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-03Fix: don't blindly strcpy() the tar header nameDavid Oberhollenzer
If the tar header name is exactely 100 bytes long, it does not have a trailing null byte. Using strlen/strcpy on it effectively concatenates the following fields contents to it. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-02Add missing htole32 transformationsDavid Oberhollenzer
Assuming this code will ever see a big endian platform. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-02Fix directory index offset calculationDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01cleanup: split tar code up, remove some duplicationsDavid Oberhollenzer
This commit attempts to split some of the monolitic tar parsing code up into multiple functions in seperate files. Also, some code duplication (like reading a record into memory which was implemented twice) is removed. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Make sure fragment and id tables are initializedDavid Oberhollenzer
In case the tables are not completely filled by reading from the squashfs image. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Remove unused variable assignment from tar header writerDavid Oberhollenzer
Mainly to make scan-build happy. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Remove never used overflow error message in fstree_from_fileDavid Oberhollenzer
Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Fix double free in GNU tar sparse file parserDavid Oberhollenzer
The intention was to free the temporary object in addition to the list. Since the temp pointer is also used for iterating the list, this resulted in a double free instead of the intended. This commit fixes the double free by replacing the recycled variable based list free with the helper function intended to do this. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Fix pax header parser to bail if parsing a number failsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Fix uninitialize return status in fstree_relabel_selinuxDavid Oberhollenzer
Should the inode table theoretically be empty, the function returns an undefined value. This commit fixes that case by initializing the return status to 0, so it returns success status in that case. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Fix use of uninitialized xattr structureDavid Oberhollenzer
The refactor of the xattr table grow code merged all allocation code paths into realloc(), including the initial allocation. This means that the xattr structure is used uninitialized. This commit makes sure the reallocated structure is alwayes cleared. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Fix alloca'd memory being freed in fstree_from_dirDavid Oberhollenzer
Most code path that use 'extra' allocate it using calloc/malloc/strdup and then converge into a common path that uses free() on extra. This commit removes a stray one that uses alloca for symlink targets, so we don't free() a stack buffer further down in the common path. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-07-01Fix memory leak in gzip compressorDavid Oberhollenzer
Don't allocate the compressor structure twice. Bug found using scan-build. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-30Add support for gnu pax sparse file formats 0.1 and 1.0David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-30Add support for gnu pax sparse file format 0.0David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-30libtar: clarify actual size vs on-disk record sizeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-30Add support for repacking condensed sparse filesDavid Oberhollenzer
This commit broadly does the following things: - Rename and move the sparse mapping structure to libutil - Add a function to the data writer for writing condensed versions of sparse files, given the mapping. - This shares code with the already existing function for regular files. The shared code is moved to a common helper function. - Add support to tar2sqfs for repacking sparse files. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-30tar reader: also store condensed size of sparse filesDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-29Add support for reading old style GNU sparse tar file formatDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-29tar reader: propperly cleanup on failureDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-28Add support for unpacking sparse files as sparse filesDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-28Add support for packing sparse filesDavid Oberhollenzer
This commit adds support for packing sparse files into squashfs images as follows: - In the data writer: simply detect zero blocks and write a zero to the block size field and don't emit any data. Record the number of bytes saved this way. For fragments, set the fragment offset to invalid. - In the inode writer: write out the number of bytes saved for sparse files. If there should be a fragment but there is none, append a block count of 0. - In the data reader: if the block size is 0, read nothing from disk and emit an empty block. Do the same if the fragment is missing. - In the inode reader: restore the number of bytes saved for sparse files. The sparse files can be packed and unpacked, but the unpacking will not create sparse files for now. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-28Ommit fragment table if there really are no fragmentsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-28Fix inode fragment & sparse counter initializationDavid Oberhollenzer
The sparse attribute should be initialized with 0. It is subtracted from the file size in the kernel to determine the file size on disk to report to stat(2). So it actually didn't matter anyway (just for correctness sake). Second, the fragment index and offset should be set to 0xFFFFFFFF in the rare case that no fragments exist. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-28Add basic support for the GNU tar formatDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-27Relax tar header parser to accept pre-posix formatsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-06-26Add support for negative timestamps in pax headerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>