summaryrefslogtreecommitdiff
path: root/bin/gensquashfs/mkfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-02-18 22:05:48 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-02-18 23:50:46 +0100
commitd9549b3d288a9cb053ab5198f3bc2d277b72600f (patch)
tree706703ac00a27ceae211a2e230f519fbc1bb73e8 /bin/gensquashfs/mkfs.c
parent9e510d4ae6dbad555a3416fbe041f4aa8189cbde (diff)
gensquashfs: always construct input path during option processing
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/mkfs.c')
-rw-r--r--bin/gensquashfs/mkfs.c38
1 files changed, 4 insertions, 34 deletions
diff --git a/bin/gensquashfs/mkfs.c b/bin/gensquashfs/mkfs.c
index 4120242..2885d84 100644
--- a/bin/gensquashfs/mkfs.c
+++ b/bin/gensquashfs/mkfs.c
@@ -6,39 +6,6 @@
*/
#include "mkfs.h"
-static int set_working_dir(options_t *opt)
-{
- const char *ptr;
- char *path;
-
- if (opt->packdir != NULL) {
- if (chdir(opt->packdir)) {
- perror(opt->packdir);
- return -1;
- }
- return 0;
- }
-
- ptr = strrchr(opt->infile, '/');
- if (ptr == NULL)
- return 0;
-
- path = strndup(opt->infile, ptr - opt->infile);
- if (path == NULL) {
- perror("constructing input directory path");
- return -1;
- }
-
- if (chdir(path)) {
- perror(path);
- free(path);
- return -1;
- }
-
- free(path);
- return 0;
-}
-
static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
options_t *opt)
{
@@ -52,8 +19,10 @@ static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
int flags;
int ret;
- if (set_working_dir(opt))
+ if (opt->packdir != NULL && chdir(opt->packdir) != 0) {
+ perror(opt->packdir);
return -1;
+ }
for (fi = fs->files; fi != NULL; fi = fi->next) {
if (fi->input_file == NULL) {
@@ -224,5 +193,6 @@ out:
sqfs_writer_cleanup(&sqfs, status);
if (sehnd != NULL)
selinux_close_context_file(sehnd);
+ free(opt.packdir);
return status;
}