diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-15 17:56:07 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-15 17:59:00 +0200 |
commit | 8ee3ee9c71418dbdb73d4350c17056024fb7ec41 (patch) | |
tree | 28416eda2893ed28750c29b41b64d783a1aaa35d /mkfs | |
parent | ab2d7fd8bfb1eafc61953e74757e84ed407b1f21 (diff) |
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 <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r-- | mkfs/mkfs.c | 13 |
1 files changed, 8 insertions, 5 deletions
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; } |