summaryrefslogtreecommitdiff
path: root/unpack/fill_files.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-23 16:46:42 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-07-25 22:10:24 +0200
commit2fcf04928a0eaf7332503753a4866a0f2031a50e (patch)
treefb7c5ae31faa21850ec283bd14d91818ceeb21a0 /unpack/fill_files.c
parent22fba34bcd0f2944def234fa684d1c9cc4d65310 (diff)
rdsquashfs: seperate creating of the hierarchy, unpacking and chmod/chown
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack/fill_files.c')
-rw-r--r--unpack/fill_files.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/unpack/fill_files.c b/unpack/fill_files.c
new file mode 100644
index 0000000..6584699
--- /dev/null
+++ b/unpack/fill_files.c
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+#include "config.h"
+#include "rdsquashfs.h"
+
+static int fill_files(data_reader_t *data, file_info_t *list, int flags)
+{
+ file_info_t *fi;
+ int fd;
+
+ for (fi = list; fi != NULL; fi = fi->next) {
+ if (fi->input_file == NULL)
+ continue;
+
+ fd = open(fi->input_file, O_WRONLY);
+ if (fd < 0) {
+ fprintf(stderr, "unpacking %s: %s\n",
+ fi->input_file, strerror(errno));
+ return -1;
+ }
+
+ if (!(flags & UNPACK_QUIET))
+ printf("unpacking %s\n", fi->input_file);
+
+ if (data_reader_dump_file(data, fi, fd,
+ (flags & UNPACK_NO_SPARSE) == 0)) {
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+ }
+
+ return 0;
+}
+
+int fill_unpacked_files(fstree_t *fs, data_reader_t *data, int flags)
+{
+ return fill_files(data, fs->files, flags);
+}