diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-14 16:30:40 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-06-15 12:55:49 +0200 |
commit | 083fc146266a9eeb2dd407546c86c3bf725330c1 (patch) | |
tree | 92e4456c007dddc9ff800438c1e07bf1bbc07250 /lib/fstree/fstree.c | |
parent | 6f57519f06c9fe57bb91983e0ddb7fbf722dfaf6 (diff) |
libfstree.a: allow adding a file with no input source
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/fstree.c')
-rw-r--r-- | lib/fstree/fstree.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/fstree/fstree.c b/lib/fstree/fstree.c index 56ca528..91c32f8 100644 --- a/lib/fstree/fstree.c +++ b/lib/fstree/fstree.c @@ -156,16 +156,23 @@ tree_node_t *fstree_add_file(fstree_t *fs, const char *path, uint16_t mode, char *ptr; count = filesz / fs->block_size; - extra = sizeof(uint32_t) * count + strlen(input) + 1; + extra = sizeof(uint32_t) * count; + + if (input != NULL) + extra += strlen(input) + 1; mode &= 07777; node = fstree_add(fs, path, S_IFREG | mode, uid, gid, extra); if (node != NULL) { - ptr = (char *)(node->data.file->blocksizes + count); - strcpy(ptr, input); + if (input != NULL) { + ptr = (char *)(node->data.file->blocksizes + count); + strcpy(ptr, input); + node->data.file->input_file = ptr; + } else { + node->data.file->input_file = NULL; + } - node->data.file->input_file = ptr; node->data.file->size = filesz; } return node; |