summaryrefslogtreecommitdiff
path: root/lib/fstree/fstree_from_file.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-22 23:18:36 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-22 23:18:36 +0200
commit56786917339c1ac2190b8b903eaf79e60d726973 (patch)
treec9a5f63a18df3fc570a90b84aadc54cc869af672 /lib/fstree/fstree_from_file.c
parent77bc1dd2116696b6d187cc3bf76de583f4f804fc (diff)
Cleanup: unify packdir/packfile based directory changes in gensquashfs
This commit removes the packdir/packfile based directory setup magic from fstree_from_file and moves it to gensquashfs. Over there, the common parts are deduplicated. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/fstree_from_file.c')
-rw-r--r--lib/fstree/fstree_from_file.c34
1 files changed, 1 insertions, 33 deletions
diff --git a/lib/fstree/fstree_from_file.c b/lib/fstree/fstree_from_file.c
index ded404a..0031c09 100644
--- a/lib/fstree/fstree_from_file.c
+++ b/lib/fstree/fstree_from_file.c
@@ -8,7 +8,6 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include <stdio.h>
#include <ctype.h>
#include <errno.h>
@@ -258,36 +257,12 @@ out_desc:
return -1;
}
-int fstree_from_file(fstree_t *fs, const char *filename, const char *rootdir)
+int fstree_from_file(fstree_t *fs, const char *filename, FILE *fp)
{
- FILE *fp = fopen(filename, "rb");
- bool need_restore = false;
size_t n, line_num = 0;
- const char *ptr;
ssize_t ret;
char *line;
- if (fp == NULL) {
- perror(filename);
- return -1;
- }
-
- if (rootdir == NULL) {
- ptr = strrchr(filename, '/');
-
- if (ptr != NULL) {
- if (pushdn(filename, ptr - filename)) {
- free(line);
- return -1;
- }
- need_restore = true;
- }
- } else {
- if (pushd(rootdir))
- return -1;
- need_restore = true;
- }
-
for (;;) {
line = NULL;
n = 0;
@@ -318,15 +293,8 @@ int fstree_from_file(fstree_t *fs, const char *filename, const char *rootdir)
free(line);
}
-
- fclose(fp);
-
- if (need_restore && popd() != 0)
- return -1;
-
return 0;
fail_line:
free(line);
- fclose(fp);
return -1;
}