aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfs/dir_writer.c
AgeCommit message (Collapse)Author
2021-06-25Add default cases for every switch blockDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-23Unify the payload counters in the sqfs_inode_generic_tDavid Oberhollenzer
Instead of having seperate counters for blocks, dir index bytes and having to fiddle out the link target size, simply use a single value that stores the number of payload bytes used. A seperate "payload bytes available" is used for dynamically growing inodes during processing. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-02-12Implement a more explicit object systemDavid Oberhollenzer
Make every dynamically allocated, opaque data structure inherit from a common sqfs_object_t structure with common entry points (e.g. destroy). This removes tons of public API functions and replaces them with a simple sqfs_destroy instead. If semantics of the (until now implicit) object system need to be extended, it can be much more conveniantely done this way. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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>
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-25Cleanup: move overflow safe alloc code into libsquashfsDavid Oberhollenzer
There were only a hand full of instances outside libsquashfs that used the alloc code. In most cases, the thing allocated hat its size derived from something already in memory anyway, so it is safe to assume its size fits into a size_t. At the same time, the opencoded Windows path conversion functions are all unified into a single helper function. 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-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-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-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-07Cleanup: move libutil related headers to "util" sub directoryDavid Oberhollenzer
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-28Fix dir writer size accountingDavid Oberhollenzer
Count the *corrent* entry structure size, i.e. the on-disk one, not the in-memory one. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-28Fix dir writer: the index size is stored off-by-oneDavid 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-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-27Cleanup: merge data.h into block.hDavid 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-15Add helper function to directory writer to create a basic inodeDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-10Cleanup: mark arguments const where possibleDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-09Change license of libsquashfs.soDavid Oberhollenzer
This this commit, the code that is compiled and linked to produce libsquashfs.so (and *only* libsquashfs.so) is released under the terms and conditions of the GNU Lesser General Public license, allowing 3rd party programs to dynamically link against it and still being able to release their programs under a license of their choosing. The libutil library is also relicensed, because it is statically linked into libsquashfs.so. This does not affect the command line programs that remain under the GPLv3. At the current time, the two libraries do not contain any 3rd party contributions and thus do not require anybodys consent other than mine to change the licensing terms (unlike e.g. libfstree.a). The libfstree.a and libsqfshelper.a utility libraries will also remain under the GPLv3 license. Going forward, some parts of libsqfshelper.a will be moved to libsquashfs.so. The parts absorbed by libsquashfs.so will then also have their licensing conditions changed *at that time*. For the public headers, this commit adds the full boiler-plate comment about the license, for the source files and internal headers, only the SPDX identifier is changed. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-07Remove printing to stderr in libsquashfs with returning error numbersDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-07Move data structure forward declarations to predef headerDavid Oberhollenzer
This in turn allows for removing most of the header inclusions within the public headers. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-05Fix API visibility for libsquashfs.soDavid Oberhollenzer
This commit adds a "predef.h" header to libsquashfs that exposes two macros, SQFS_API and SQFS_INTERNAL that are used to explicilty set the visibiliy of stuff that ends up in libsquashfs to default or hidden. For compatibillity with Windows which may at some point eventually be considered, the SQFS_API define is set to dllexport IF the cpp symbol SQFS_BUILDING_DLL is defined and set to import otherwise. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-05Cleanup: add sqfs_* prefix to meta writerDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-04Add fstree independend directory writer to libsquashfs.soDavid Oberhollenzer
This commit adds a directory writer to libsquashfs that wrapps a meta data writer and provides a higher-level interface for writing directory entries. Under the hood it enforces the rules that squashfs insists upon. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>