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 --- mkfs/mkfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'mkfs') diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index a046cbd..cb65eda 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -30,8 +30,9 @@ static int restore_working_dir(options_t *opt) static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt) { + sqfs_file_t *file; file_info_t *fi; - int ret, infd; + int ret; if (set_working_dir(opt)) return -1; @@ -40,14 +41,16 @@ static int pack_files(data_writer_t *data, fstree_t *fs, options_t *opt) if (!opt->quiet) printf("packing %s\n", fi->input_file); - infd = open(fi->input_file, O_RDONLY); - if (infd < 0) { + file = sqfs_open_file(fi->input_file, + SQFS_FILE_OPEN_READ_ONLY); + if (file == NULL) { perror(fi->input_file); return -1; } - ret = write_data_from_fd(data, fi, infd, 0); - close(infd); + ret = write_data_from_file(data, fi, file, 0); + file->destroy(file); + if (ret) return -1; } -- cgit v1.2.3