diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/rdsquashfs/src/fill_files.c | 16 | ||||
-rw-r--r-- | bin/rdsquashfs/src/rdsquashfs.c | 17 | ||||
-rw-r--r-- | bin/sqfs2tar/src/write_tree.c | 19 | ||||
-rw-r--r-- | bin/sqfsdiff/src/extract.c | 16 |
4 files changed, 56 insertions, 12 deletions
diff --git a/bin/rdsquashfs/src/fill_files.c b/bin/rdsquashfs/src/fill_files.c index 7087883..b26041a 100644 --- a/bin/rdsquashfs/src/fill_files.c +++ b/bin/rdsquashfs/src/fill_files.c @@ -137,6 +137,7 @@ static int fill_files(sqfs_data_reader_t *data, int flags) { int ret, openflags; sqfs_ostream_t *fp; + sqfs_istream_t *in; size_t i; openflags = SQFS_FILE_OPEN_OVERWRITE; @@ -154,8 +155,19 @@ static int fill_files(sqfs_data_reader_t *data, int flags) if (!(flags & UNPACK_QUIET)) printf("unpacking %s\n", files[i].path); - ret = sqfs_data_reader_dump(files[i].path, data, files[i].inode, - fp, block_size); + ret = sqfs_data_reader_create_stream(data, files[i].inode, + files[i].path, &in); + if (ret) { + sqfs_perror(files[i].path, NULL, ret); + return -1; + } + + do { + ret = sqfs_istream_splice(in, fp, block_size); + } while (ret > 0); + + sqfs_drop(in); + if (ret == 0) ret = fp->flush(fp); diff --git a/bin/rdsquashfs/src/rdsquashfs.c b/bin/rdsquashfs/src/rdsquashfs.c index 77dc5ba..9d8f3ba 100644 --- a/bin/rdsquashfs/src/rdsquashfs.c +++ b/bin/rdsquashfs/src/rdsquashfs.c @@ -208,11 +208,13 @@ int main(int argc, char **argv) break; case OP_CAT: { sqfs_ostream_t *fp; + sqfs_istream_t *in; int ret; - if (!S_ISREG(n->inode->base.mode)) { - fprintf(stderr, "/%s: not a regular file\n", - opt.cmdpath); + ret = sqfs_data_reader_create_stream(data, n->inode, + opt.cmdpath, &in); + if (ret) { + sqfs_perror(opt.cmdpath, NULL, ret); goto out; } @@ -222,8 +224,13 @@ int main(int argc, char **argv) goto out; } - ret = sqfs_data_reader_dump(opt.cmdpath, data, n->inode, - fp, super.block_size); + do { + ret = sqfs_istream_splice(in, fp, super.block_size); + if (ret < 0) + sqfs_perror(opt.cmdpath, "splicing data", ret); + } while (ret > 0); + + sqfs_drop(in); sqfs_drop(fp); if (ret) goto out; diff --git a/bin/sqfs2tar/src/write_tree.c b/bin/sqfs2tar/src/write_tree.c index dc3ac72..ed82173 100644 --- a/bin/sqfs2tar/src/write_tree.c +++ b/bin/sqfs2tar/src/write_tree.c @@ -157,13 +157,26 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) } if (S_ISREG(sb.st_mode)) { - if (sqfs_data_reader_dump(name, data, n->inode, out_file, - super.block_size)) { + sqfs_istream_t *in; + int ret; + + ret = sqfs_data_reader_create_stream(data, n->inode, name, &in); + if (ret) { + sqfs_perror(name, NULL, ret); sqfs_free(name); return -1; } - ret = padd_file(out_file, sb.st_size); + do { + ret = sqfs_istream_splice(in, out_file, + super.block_size); + } while (ret > 0); + + sqfs_drop(in); + + if (ret == 0) + ret = padd_file(out_file, sb.st_size); + if (ret) { sqfs_perror(name, NULL, ret); sqfs_free(name); diff --git a/bin/sqfsdiff/src/extract.c b/bin/sqfsdiff/src/extract.c index cbc4381..df74f0f 100644 --- a/bin/sqfsdiff/src/extract.c +++ b/bin/sqfsdiff/src/extract.c @@ -11,6 +11,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, { char *ptr, *temp; sqfs_ostream_t *fp; + sqfs_istream_t *in; int ret; temp = alloca(strlen(prefix) + strlen(path) + 2); @@ -28,12 +29,23 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode, return -1; } - if (sqfs_data_reader_dump(path, data, inode, fp, block_size)) { + ret = sqfs_data_reader_create_stream(data, inode, path, &in); + if (ret) { sqfs_drop(fp); return -1; } - ret = fp->flush(fp); + do { + ret = sqfs_istream_splice(in, fp, block_size); + if (ret < 0) + sqfs_perror(path, "splicing data", ret); + } while (ret > 0); + + sqfs_drop(in); + + if (ret == 0) + ret = fp->flush(fp); + if (ret) { sqfs_perror(fp->get_filename(fp), NULL, ret); sqfs_drop(fp); |