summaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/block.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/mkfs/block.c b/mkfs/block.c
index 545df53..de2c962 100644
--- a/mkfs/block.c
+++ b/mkfs/block.c
@@ -211,8 +211,25 @@ static int find_and_process_files(sqfs_info_t *info, tree_node_t *n,
int write_data_to_image(sqfs_info_t *info)
{
+ bool need_restore = false;
+ const char *ptr;
int ret;
+ if (info->opt.packdir != NULL) {
+ if (pushd(info->opt.packdir))
+ return -1;
+ need_restore = true;
+ } else {
+ ptr = strrchr(info->opt.infile, '/');
+
+ if (ptr != NULL) {
+ if (pushdn(info->opt.infile, ptr - info->opt.infile))
+ return -1;
+
+ need_restore = true;
+ }
+ }
+
info->block = malloc(info->super.block_size);
if (info->block == NULL) {
@@ -245,5 +262,9 @@ int write_data_to_image(sqfs_info_t *info)
info->block = NULL;
info->fragment = NULL;
info->scratch = NULL;
+
+ if (need_restore)
+ ret = popd();
+
return ret;
}