From 56786917339c1ac2190b8b903eaf79e60d726973 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 22 Jun 2019 23:18:36 +0200 Subject: 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 --- lib/fstree/fstree_from_file.c | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'lib') 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 #include #include -#include #include #include @@ -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; } -- cgit v1.2.3