summaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/add_by_path.c4
-rw-r--r--lib/fstree/fstree.c2
-rw-r--r--lib/fstree/fstree_from_dir.c2
-rw-r--r--lib/fstree/mknode.c32
4 files changed, 12 insertions, 28 deletions
diff --git a/lib/fstree/add_by_path.c b/lib/fstree/add_by_path.c
index fbc2ce7..87fa6ff 100644
--- a/lib/fstree/add_by_path.c
+++ b/lib/fstree/add_by_path.c
@@ -45,7 +45,7 @@ static tree_node_t *get_parent_node(fstree_t *fs, tree_node_t *root,
n = child_by_name(root, path, end - path);
if (n == NULL) {
- n = fstree_mknode(fs, root, path, end - path, NULL,
+ n = fstree_mknode(root, path, end - path, NULL,
&fs->defaults);
if (n == NULL)
return NULL;
@@ -89,5 +89,5 @@ tree_node_t *fstree_add_generic(fstree_t *fs, const char *path,
return child;
}
- return fstree_mknode(fs, parent, name, strlen(name), extra, sb);
+ return fstree_mknode(parent, name, strlen(name), extra, sb);
}
diff --git a/lib/fstree/fstree.c b/lib/fstree/fstree.c
index 6955c17..febf8af 100644
--- a/lib/fstree/fstree.c
+++ b/lib/fstree/fstree.c
@@ -125,7 +125,7 @@ int fstree_init(fstree_t *fs, size_t block_size, char *defaults)
return -1;
}
- fs->root = fstree_mknode(fs, NULL, "", 0, NULL, &fs->defaults);
+ fs->root = fstree_mknode(NULL, "", 0, NULL, &fs->defaults);
if (fs->root == NULL) {
perror("initializing file system tree");
diff --git a/lib/fstree/fstree_from_dir.c b/lib/fstree/fstree_from_dir.c
index 9aab5df..86f7fd8 100644
--- a/lib/fstree/fstree_from_dir.c
+++ b/lib/fstree/fstree_from_dir.c
@@ -180,7 +180,7 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, dev_t devstart,
if (!(flags & DIR_SCAN_KEEP_TIME))
sb.st_mtim = fs->defaults.st_mtim;
- n = fstree_mknode(fs, root, ent->d_name, strlen(ent->d_name),
+ n = fstree_mknode(root, ent->d_name, strlen(ent->d_name),
extra, &sb);
if (n == NULL) {
perror("creating tree node");
diff --git a/lib/fstree/mknode.c b/lib/fstree/mknode.c
index ace99f3..19df268 100644
--- a/lib/fstree/mknode.c
+++ b/lib/fstree/mknode.c
@@ -13,11 +13,11 @@
#include <stdlib.h>
#include <errno.h>
-tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name,
+tree_node_t *fstree_mknode(tree_node_t *parent, const char *name,
size_t name_len, const char *extra,
const struct stat *sb)
{
- size_t size = sizeof(tree_node_t), block_count = 0, total;
+ size_t size = sizeof(tree_node_t), total;
tree_node_t *n;
char *ptr;
@@ -37,19 +37,8 @@ tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name,
goto fail_ov;
break;
case S_IFREG:
- block_count = (sb->st_size / fs->block_size);
- if ((sb->st_size % fs->block_size) != 0)
- ++block_count;
-
- if (SZ_MUL_OV(block_count, sizeof(n->data.file->block_size[0]),
- &total)) {
- goto fail_ov;
- }
-
- if (SZ_ADD_OV(size, sizeof(*n->data.file), &size) ||
- SZ_ADD_OV(size, total, &size)) {
+ if (SZ_ADD_OV(size, sizeof(*n->data.file), &size))
goto fail_ov;
- }
if (extra != NULL) {
if (SZ_ADD_OV(size, strlen(extra), &size) ||
@@ -86,16 +75,11 @@ tree_node_t *fstree_mknode(fstree_t *fs, tree_node_t *parent, const char *name,
break;
case S_IFREG:
n->data.file = (file_info_t *)n->payload;
- n->data.file->size = sb->st_size;
- n->data.file->fragment = 0xFFFFFFFF;
- n->data.file->fragment_offset = 0xFFFFFFFF;
- if (extra == NULL)
- break;
-
- ptr = (char *)n->data.file->block_size;
- ptr += block_count * sizeof(n->data.file->block_size[0]);
- n->data.file->input_file = ptr;
- strcpy(n->data.file->input_file, extra);
+ if (extra != NULL) {
+ ptr = (char *)n->payload + sizeof(file_info_t);
+ n->data.file->input_file = ptr;
+ strcpy(n->data.file->input_file, extra);
+ }
break;
case S_IFLNK:
n->mode = S_IFLNK | 0777;