summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/fstree.h4
-rw-r--r--lib/fstree/fstree.c5
-rw-r--r--mkfs/mkfs.c6
-rw-r--r--tar/tar2sqfs.c2
-rw-r--r--tests/add_by_path.c2
-rw-r--r--tests/fstree_from_file.c2
-rw-r--r--tests/fstree_fuzz.c2
-rw-r--r--tests/fstree_init.c8
-rw-r--r--tests/gen_inode_table.c4
-rw-r--r--tests/get_path.c2
10 files changed, 17 insertions, 20 deletions
diff --git a/include/fstree.h b/include/fstree.h
index b355f06..a63c593 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -98,15 +98,13 @@ struct fstree_t {
Initializing means copying over the default values and creating a root node.
On error, an error message is written to stderr.
- `block_size` is the the data block size for regular files.
-
The string `defaults` can specify default attributes (mode, uid, gid, mtime)
as a comma seperated list of key value paris (<key>=<value>[,...]). The string
is passed to getsubopt and will be altered.
Returns 0 on success.
*/
-int fstree_init(fstree_t *fs, size_t block_size, char *defaults);
+int fstree_init(fstree_t *fs, char *defaults);
void fstree_cleanup(fstree_t *fs);
diff --git a/lib/fstree/fstree.c b/lib/fstree/fstree.c
index efb6a78..c18ffba 100644
--- a/lib/fstree/fstree.c
+++ b/lib/fstree/fstree.c
@@ -106,13 +106,12 @@ static void free_recursive(tree_node_t *n)
free(n);
}
-int fstree_init(fstree_t *fs, size_t block_size, char *defaults)
+int fstree_init(fstree_t *fs, char *defaults)
{
memset(fs, 0, sizeof(*fs));
fs->defaults.st_mode = S_IFDIR | 0755;
- fs->defaults.st_blksize = block_size;
+ fs->defaults.st_blksize = 512;
fs->defaults.st_mtime = get_source_date_epoch();
- fs->block_size = block_size;
if (defaults != NULL && process_defaults(&fs->defaults, defaults) != 0)
return -1;
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index fe3fa02..dc6d082 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -54,8 +54,8 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
filesize = file->get_size(file);
- max_blk_count = filesize / fs->block_size;
- if (filesize % fs->block_size)
+ max_blk_count = filesize / opt->blksz;
+ if (filesize % opt->blksz)
++max_blk_count;
inode = alloc_flex(sizeof(*inode), sizeof(sqfs_u32),
@@ -174,7 +174,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- if (fstree_init(&fs, opt.blksz, opt.fs_defaults))
+ if (fstree_init(&fs, opt.fs_defaults))
return EXIT_FAILURE;
if (sqfs_super_init(&super, opt.blksz, fs.defaults.st_mtime,
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index 98c0489..e0ffa99 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -446,7 +446,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- if (fstree_init(&fs, block_size, fs_defaults))
+ if (fstree_init(&fs, fs_defaults))
goto out_fd;
cmp = sqfs_compressor_create(&cfg);
diff --git a/tests/add_by_path.c b/tests/add_by_path.c
index afed438..af8dd88 100644
--- a/tests/add_by_path.c
+++ b/tests/add_by_path.c
@@ -21,7 +21,7 @@ int main(void)
char *opts;
opts = strdup("mode=0755,uid=21,gid=42");
- assert(fstree_init(&fs, 512, opts) == 0);
+ assert(fstree_init(&fs, opts) == 0);
free(opts);
memset(&sb, 0, sizeof(sb));
diff --git a/tests/fstree_from_file.c b/tests/fstree_from_file.c
index 76e378a..b5ac2a3 100644
--- a/tests/fstree_from_file.c
+++ b/tests/fstree_from_file.c
@@ -37,7 +37,7 @@ int main(void)
fp = fmemopen(ptr, strlen(ptr), "r");
assert(fp != NULL);
- assert(fstree_init(&fs, 512, NULL) == 0);
+ assert(fstree_init(&fs, NULL) == 0);
assert(fstree_from_file(&fs, "testfile", fp) == 0);
tree_node_sort_recursive(fs.root);
diff --git a/tests/fstree_fuzz.c b/tests/fstree_fuzz.c
index a9df1ab..42d8942 100644
--- a/tests/fstree_fuzz.c
+++ b/tests/fstree_fuzz.c
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
- if (fstree_init(&fs, 512, NULL))
+ if (fstree_init(&fs, NULL))
goto out_fp;
if (fstree_from_file(&fs, argv[1], fp))
diff --git a/tests/fstree_init.c b/tests/fstree_init.c
index 1a56256..ae559dd 100644
--- a/tests/fstree_init.c
+++ b/tests/fstree_init.c
@@ -20,7 +20,7 @@ int main(void)
str = strdup("mtime=1337,uid=1000,gid=100,mode=0321");
assert(str != NULL);
- assert(fstree_init(&fs, 512, str) == 0);
+ assert(fstree_init(&fs, str) == 0);
free(str);
assert(fs.defaults.st_mtime == 1337);
assert(fs.defaults.st_uid == 1000);
@@ -28,7 +28,7 @@ int main(void)
assert(fs.defaults.st_mode == (S_IFDIR | 0321));
fstree_cleanup(&fs);
- assert(fstree_init(&fs, 512, NULL) == 0);
+ assert(fstree_init(&fs, NULL) == 0);
assert(fs.defaults.st_mtime == 0);
assert(fs.defaults.st_uid == 0);
assert(fs.defaults.st_gid == 0);
@@ -37,13 +37,13 @@ int main(void)
str = strdup("mode=07777");
assert(str != NULL);
- assert(fstree_init(&fs, 512, str) == 0);
+ assert(fstree_init(&fs, str) == 0);
free(str);
fstree_cleanup(&fs);
str = strdup("mode=017777");
assert(str != NULL);
- assert(fstree_init(&fs, 512, str) != 0);
+ assert(fstree_init(&fs, str) != 0);
free(str);
return EXIT_SUCCESS;
diff --git a/tests/gen_inode_table.c b/tests/gen_inode_table.c
index cf140c8..55f543e 100644
--- a/tests/gen_inode_table.c
+++ b/tests/gen_inode_table.c
@@ -54,7 +54,7 @@ int main(void)
fstree_t fs;
// inode table for the empty tree
- assert(fstree_init(&fs, 0, NULL) == 0);
+ assert(fstree_init(&fs, NULL) == 0);
assert(fstree_gen_inode_table(&fs) == 0);
assert(fs.inode_tbl_size == 3);
assert(fs.root->inode_num == 2);
@@ -64,7 +64,7 @@ int main(void)
fstree_cleanup(&fs);
// tree with 2 levels under root, fan out 3
- assert(fstree_init(&fs, 0, NULL) == 0);
+ assert(fstree_init(&fs, NULL) == 0);
a = gen_node(fs.root, "a");
b = gen_node(fs.root, "b");
diff --git a/tests/get_path.c b/tests/get_path.c
index 7ce6aeb..7d37f4c 100644
--- a/tests/get_path.c
+++ b/tests/get_path.c
@@ -19,7 +19,7 @@ int main(void)
fstree_t fs;
char *str;
- assert(fstree_init(&fs, 512, NULL) == 0);
+ assert(fstree_init(&fs, NULL) == 0);
memset(&sb, 0, sizeof(sb));
sb.st_mode = S_IFDIR | 0750;