aboutsummaryrefslogtreecommitdiff
path: root/include/sqfs
AgeCommit message (Collapse)Author
2020-01-19Cleanup: remove the payload pointers from sqfs_inode_generic_tDavid Oberhollenzer
There are 3 types of extra payload: - Directory index - File block sizes - Symlink target This commit removes the type specific pointers and modifies the code to use the payload area directly. To simplify the file block case and mitigate alignment issues, the type of the extra field is changed to sqfs_u32. For symlink target, the extra field can simply be cast to a character pointer (it had to be cast anyway for most uses). For block sizes, probably the most common usecase, it can be used as is. For directory indices, there is a helper function anyway. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-19Update explanation on directory index accountingDavid Oberhollenzer
Tests with the Debian image (which is generated with squashfs-tools, so should be interpreted as ground truth) have showed that the count is not stored off-by-one. The code was already doing the right thing, but the documentation was wrong. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-19Add a helper function to unpack directory index entriesDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-12Add a start anchor parameter to sqfs_dir_reader_find_by_pathDavid Oberhollenzer
It optionally allows code that does tree traversal to start at an inode that it obtained previously and makes it easier to keep state externally. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-01-12Add an inode deep copy helper function to libsquashfsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-12-19Fix spelling mistakes found by lintianBenjamin Drung
Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
2019-12-16Add ability to sqfs_dir_writer to create an export tableDavid Oberhollenzer
If the dir writer is used to create the directory table, it neccessarily sees every single inode number and coresponding location for all inodes that are referenced by the filesystem tree. This means it can easily collect that information internally to create an export table later on. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-28Cleanup: Return combined return value from compressor id by nameDavid Oberhollenzer
Instead of returning the ID through a pointer and an error code as return status, return a single int that could be a compressor ID (positive values) or an error code (negative values). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-24Cleanup libsquashfs invalid argument error codesDavid Oberhollenzer
- Add an explicit "you're holding it wrong" error code. - Consistently return error codes and not have some special places where -1 is returned. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-24Cleanup: remove the entirely redundant sqfs_has_xattr functionDavid 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-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-03Add a counter-part to sqfs_inode_get_xattr_indexDavid Oberhollenzer
Combines all the type depenend attribute setting and inode type promotion into a single function. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-03Store directory index in generic inode structureDavid Oberhollenzer
This commit modifies the dir writer to store the directory index directly in the payload area of the inode it creates. The size of the index in bytes is stored in a seperate field. Storing the index is moved to the write inode function. The read inode function is in turn also modified to read the directory index from disk and actually store it in the inode structure in memory for later use. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-30Add flag field to directory writer begin for future expansionDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-29Cleanup: rename "compress.h" to "compressor.h"David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-29Bring back the don't fragment flagDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-29Make the data writer padding hookableDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-28Add header with declarations for the sqfs_xattr_writer_tDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-28Move declarations for sqfs_xattr_reader_t to a seperate headerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Add a header for platform compatibillity fluffDavid Oberhollenzer
- We don't have "endian.h" everywhere. On some BSDs its in sys and on some BSDs the macros have different names. - We definitely don't have sysmacros.h on non-Unix-like systems. - Likewise for sys/types.h, sys/stat.h and their contents. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Replace usage of mode_t in libsquashfs with sqfs_u16David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Add enum with inode permissions for compatibility with non-POSIX systemsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Remove use of ssize_t from library APIDavid Oberhollenzer
ssize_t is only available on POSIX platforms and even there it is only defined to hold at least -1 in the range of negative numbers. This commit replaces ssize_t return types with sqfs_s32 and the coresponding function arguments with sqfs_u32. Because the range of positiv numbers for a signed 32 bit number is only half that of the unsigned version, additional checks have to be added. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Cleanup: replace fixed with data types with typedefsDavid Oberhollenzer
This is a fully automated search and replace, i.e. I ran this: git grep -l uint8_t | xargs sed -i 's/uint8_t/sqfs_u8/g' git grep -l uint16_t | xargs sed -i 's/uint16_t/sqfs_u16/g' git grep -l uint32_t | xargs sed -i 's/uint32_t/sqfs_u32/g' git grep -l uint64_t | xargs sed -i 's/uint64_t/sqfs_u64/g' git grep -l int8_t | xargs sed -i 's/int8_t/sqfs_s8/g' git grep -l int16_t | xargs sed -i 's/int16_t/sqfs_s16/g' git grep -l int32_t | xargs sed -i 's/int32_t/sqfs_s32/g' git grep -l int64_t | xargs sed -i 's/int64_t/sqfs_s64/g' and than added the appropriate definitions to sqfs/predef.h The whole point being better compatibillity with platforms that may not have an stdint.h with the propper definitions. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Fix typo in error enumeratorDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Add missing comments on error enumeratorDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Cleanup: merge data.h into block.hDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-26Update documentation on sqfs_data_writer_tDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-26Remove the create I/O block from sqfs_file_t functionDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-26Replace the data writer enqueue with "append buffer to current file"David Oberhollenzer
This commit turns the file interface into an actual, generic file interface and does away with having to move around blocks outside the data writer. Instead the data writer takes over full control and responsibility of dividing the input data up into blocks propperly. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-26Add file API stub to sqfs data writerDavid Oberhollenzer
Basically move the state tracking from the old data writer over to the new one. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-25Remove condensed sparse file handling from libsquashfsDavid Oberhollenzer
This only exists for tar2sqfs. Move the sparse file map to libtar and add the ability to do this into the stind sqfs_file_t abstraction, so it acts like a normal file but internally stitches the data together from the sparse implementation. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-25Cleanup: move the stdin sqfs_file_t wrapper out of libsquashfsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-25Add the ability to hook into the data writer block writingDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-25Move sqfs_block_t to its own headerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-25Rename block processor to sqfs_data_writer_tDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-24Move entire fragment processing from data writer to block processorDavid Oberhollenzer
So far, this is mostly a direct port from the block processor. The actual fragment checksumming is not done through the thread pool. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-23Cleanup block processor error handlingDavid Oberhollenzer
If an error happpens, immediately stop everything and report only the first error that happened. This also fixes a memory leak in the error paths of the serial and pthread based block processors. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-23Cleanup block processor flag handlingDavid Oberhollenzer
First, remove the "Don't checksum" flag, fragment blocks also need to be checksumed and are also subject to deduplication. For sentinel blocks, instead check if the size is zero. Second, cleanly seperate the user settable flags from the non-user settable flags and reject any block that has non-user settable or unknown flags set. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-23Move the bulk of the work from the data writer to the block processorDavid Oberhollenzer
Instead of calling a callback, the block processor now takes care of writing the data blocks to the file in the correct order, keeping track of fragment blocks and deduplicating blocks. Some cleanup work remains to be done and the statistics have to be repaired (yet again). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-23Replace user pointer in sqfs_block_t with explicit inode pointerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-22Move data writer custom flags over to block processorDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-22Add helper functions for working with inodesDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-20Integrate the data reader into libsquashfsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-20Cleanup: split "dir.h" into "dir_reader.h" and "dir_writer.h"David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-20Move data_reader_dump function out of data readerDavid Oberhollenzer
This commit adds two new functions for getting a file block by index, or a files fragment. The data_reader_dump function is rewritten in terms of those two functions and moved to a seperate file. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-20Add fstree like tree deserialization function to dir readerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-19Add directory reader data structureDavid Oberhollenzer
This moves a lot of the stuff that is done manually in the tree deserializer to a generic helper in libsquashfs. Due to how the fstree is implemented, as a work around, the inode needs to be temporarily stored in the tree node, but some of the directory details could be removed. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>