summaryrefslogtreecommitdiff
path: root/bin/sqfsdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-04 19:26:31 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-09-16 09:34:35 +0200
commit0a0cbefc6ebb6174aad3e6f0b8a6dea87aed49da (patch)
tree7b1a69382f7480e442620b6176c1673abcf81b3c /bin/sqfsdiff
parent4b994ac359757098ebc09263fff9e2290a58de71 (diff)
Remodel file extraction tools to use libfstream
This commit rewrites the libtar write paths to use libfstream insead of a FILE pointer. Also, the libcommon file extraction function is remodeled to use libfstream. In accordance, rdsquashfs, sqfs2tar and sqfsdiff have some minor adjustments made to work with the ported libtar and libcommon. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/sqfsdiff')
-rw-r--r--bin/sqfsdiff/Makemodule.am4
-rw-r--r--bin/sqfsdiff/extract.c13
2 files changed, 9 insertions, 8 deletions
diff --git a/bin/sqfsdiff/Makemodule.am b/bin/sqfsdiff/Makemodule.am
index b5de502..8331f25 100644
--- a/bin/sqfsdiff/Makemodule.am
+++ b/bin/sqfsdiff/Makemodule.am
@@ -4,8 +4,8 @@ sqfsdiff_SOURCES += bin/sqfsdiff/compare_dir.c bin/sqfsdiff/node_compare.c
sqfsdiff_SOURCES += bin/sqfsdiff/compare_files.c bin/sqfsdiff/super.c
sqfsdiff_SOURCES += bin/sqfsdiff/extract.c
sqfsdiff_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)
-sqfsdiff_LDADD = libcommon.a libsquashfs.la libcompat.a $(LZO_LIBS) libfstree.a
-sqfsdiff_LDADD += $(PTHREAD_LIBS)
+sqfsdiff_LDADD = libcommon.a libsquashfs.la libfstream.a libcompat.a
+sqfsdiff_LDADD += $(LZO_LIBS) libfstree.a $(PTHREAD_LIBS)
dist_man1_MANS += bin/sqfsdiff/sqfsdiff.1
bin_PROGRAMS += sqfsdiff
diff --git a/bin/sqfsdiff/extract.c b/bin/sqfsdiff/extract.c
index 979572a..0c68918 100644
--- a/bin/sqfsdiff/extract.c
+++ b/bin/sqfsdiff/extract.c
@@ -10,7 +10,7 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,
const char *prefix, const char *path, size_t block_size)
{
char *ptr, *temp;
- FILE *fp;
+ ostream_t *fp;
temp = alloca(strlen(prefix) + strlen(path) + 2);
sprintf(temp, "%s/%s", prefix, path);
@@ -21,19 +21,20 @@ static int extract(sqfs_data_reader_t *data, const sqfs_inode_generic_t *inode,
return -1;
*ptr = '/';
- fp = fopen(temp, "wb");
+ fp = ostream_open_file(temp, OSTREAM_OPEN_OVERWRITE |
+ OSTREAM_OPEN_SPARSE);
if (fp == NULL) {
perror(temp);
return -1;
}
- if (sqfs_data_reader_dump(path, data, inode, fp, block_size, true)) {
- fclose(fp);
+ if (sqfs_data_reader_dump(path, data, inode, fp, block_size)) {
+ sqfs_destroy(fp);
return -1;
}
- fflush(fp);
- fclose(fp);
+ ostream_flush(fp);
+ sqfs_destroy(fp);
return 0;
}