From 8ee3ee9c71418dbdb73d4350c17056024fb7ec41 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 15 Sep 2019 17:56:07 +0200 Subject: Replace file descriptor IO in data_writer with sqfs_file_t First, this commit moves the create-blocks-from-fd function over to libsquashfs and ports it to work on an sqfs_file_t instead. Second, the function in the data_writer that reads from a file descriptor is adjusted to use an sqfs_file_t instead. Finally, the tools that use it have to be adjusted accordingly. Signed-off-by: David Oberhollenzer --- tar/tar2sqfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tar') diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index 13276b8..d693aa1 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -225,6 +225,7 @@ fail_arg: static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, data_writer_t *data) { + sqfs_file_t *file; int ret; if (hdr->sparse != NULL) { @@ -236,9 +237,16 @@ static int write_file(tar_header_decoded_t *hdr, file_info_t *fi, return skip_padding(STDIN_FILENO, hdr->record_size); } - if (write_data_from_fd(data, fi, STDIN_FILENO, 0)) + file = sqfs_get_stdin_file(fi->size); + if (file == NULL) { + perror("packing files"); + return -1; + } + + if (write_data_from_file(data, fi, file, 0)) return -1; + file->destroy(file); return skip_padding(STDIN_FILENO, fi->size); } -- cgit v1.2.3