summaryrefslogtreecommitdiff
path: root/lib/sqfs/io.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-25 17:47:19 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-25 17:47:19 +0200
commit3511b1fa7c6f71c579e161951e945904e552e1d9 (patch)
tree55fa94e5daef7bcc8e4b650f27d05af49fd1b02d /lib/sqfs/io.c
parent4d79f55f4a626a3cfd8bd18673aa29b48b16e137 (diff)
Remove condensed sparse file handling from libsquashfs
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>
Diffstat (limited to 'lib/sqfs/io.c')
-rw-r--r--lib/sqfs/io.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/lib/sqfs/io.c b/lib/sqfs/io.c
index f4ffda2..0021a30 100644
--- a/lib/sqfs/io.c
+++ b/lib/sqfs/io.c
@@ -37,69 +37,3 @@ int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset,
*out = blk;
return 0;
}
-
-int sqfs_file_create_block_dense(sqfs_file_t *file, uint64_t offset,
- size_t size, sqfs_inode_generic_t *inode,
- uint32_t flags, const sqfs_sparse_map_t *map,
- sqfs_block_t **out)
-{
- sqfs_block_t *blk = alloc_flex(sizeof(*blk), 1, size);
- size_t dst_start, diff, count;
- const sqfs_sparse_map_t *it;
- uint64_t poffset, src_start;
- int err;
-
- if (blk == NULL)
- return SQFS_ERROR_ALLOC;
-
- poffset = 0;
-
- for (it = map; it != NULL; it = it->next) {
- if (it->offset + it->count <= offset) {
- poffset += it->count;
- continue;
- }
-
- if (it->offset >= offset + size) {
- poffset += it->count;
- continue;
- }
-
- count = size;
-
- if (offset + count >= it->offset + it->count)
- count = it->offset + it->count - offset;
-
- if (it->offset < offset) {
- diff = offset - it->offset;
-
- src_start = poffset + diff;
- dst_start = 0;
- count -= diff;
- } else if (it->offset > offset) {
- diff = it->offset - offset;
-
- src_start = poffset;
- dst_start = diff;
- } else {
- src_start = poffset;
- dst_start = 0;
- }
-
- err = file->read_at(file, src_start,
- blk->data + dst_start, count);
- if (err) {
- free(blk);
- return err;
- }
-
- poffset += it->count;
- }
-
- blk->inode = inode;
- blk->size = size;
- blk->flags = flags;
-
- *out = blk;
- return 0;
-}