aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-11 01:57:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-06-11 15:36:08 +0200
commit259a98985b4f93347923d1b2c3aaa535397aaa89 (patch)
tree0a008ffc3d59cfaeffaf0aed7e79d53dd7eef081
parentec5ba7eb521626a85d2ab22e97eb1298b2ff6f55 (diff)
Add flags to functions that might logically be expanded in the future
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--bin/gensquashfs/dirscan_xattr.c2
-rw-r--r--bin/gensquashfs/mkfs.c2
-rw-r--r--bin/rdsquashfs/rdsquashfs.c4
-rw-r--r--bin/sqfs2tar/sqfs2tar.c4
-rw-r--r--bin/sqfsdiff/sqfsdiff.c4
-rw-r--r--bin/tar2sqfs/process_tarball.c2
-rw-r--r--extras/list_files.c2
-rw-r--r--include/sqfs/data_reader.h4
-rw-r--r--include/sqfs/dir_reader.h8
-rw-r--r--include/sqfs/xattr_writer.h7
-rw-r--r--lib/common/writer.c2
-rw-r--r--lib/sqfs/data_reader.c9
-rw-r--r--lib/sqfs/dir_reader.c17
-rw-r--r--lib/sqfs/read_tree.c6
-rw-r--r--lib/sqfs/xattr/xattr_writer.c8
-rw-r--r--lib/sqfs/xattr/xattr_writer_record.c5
16 files changed, 58 insertions, 28 deletions
diff --git a/bin/gensquashfs/dirscan_xattr.c b/bin/gensquashfs/dirscan_xattr.c
index 3995a19..5ed3c9c 100644
--- a/bin/gensquashfs/dirscan_xattr.c
+++ b/bin/gensquashfs/dirscan_xattr.c
@@ -128,7 +128,7 @@ static int xattr_xcan_dfs(const char *path_prefix, void *selinux_handle,
char *path;
int ret;
- ret = sqfs_xattr_writer_begin(xwr);
+ ret = sqfs_xattr_writer_begin(xwr, 0);
if (ret) {
sqfs_perror(node->name, "recoding xattr key-value pairs\n",
ret);
diff --git a/bin/gensquashfs/mkfs.c b/bin/gensquashfs/mkfs.c
index 87778d9..66e10a9 100644
--- a/bin/gensquashfs/mkfs.c
+++ b/bin/gensquashfs/mkfs.c
@@ -114,7 +114,7 @@ static int relabel_tree_dfs(const char *filename, sqfs_xattr_writer_t *xwr,
return -1;
}
- ret = sqfs_xattr_writer_begin(xwr);
+ ret = sqfs_xattr_writer_begin(xwr, 0);
if (ret) {
sqfs_perror(filename, "recording xattr key-value pairs", ret);
return -1;
diff --git a/bin/rdsquashfs/rdsquashfs.c b/bin/rdsquashfs/rdsquashfs.c
index fa2bbb4..78f54ba 100644
--- a/bin/rdsquashfs/rdsquashfs.c
+++ b/bin/rdsquashfs/rdsquashfs.c
@@ -80,14 +80,14 @@ int main(int argc, char **argv)
goto out_id;
}
- dirrd = sqfs_dir_reader_create(&super, cmp, file);
+ dirrd = sqfs_dir_reader_create(&super, cmp, file, 0);
if (dirrd == NULL) {
sqfs_perror(opt.image_name, "creating dir reader",
SQFS_ERROR_ALLOC);
goto out_id;
}
- data = sqfs_data_reader_create(file, super.block_size, cmp);
+ data = sqfs_data_reader_create(file, super.block_size, cmp, 0);
if (data == NULL) {
sqfs_perror(opt.image_name, "creating data reader",
SQFS_ERROR_ALLOC);
diff --git a/bin/sqfs2tar/sqfs2tar.c b/bin/sqfs2tar/sqfs2tar.c
index aa2a5b7..8c5f631 100644
--- a/bin/sqfs2tar/sqfs2tar.c
+++ b/bin/sqfs2tar/sqfs2tar.c
@@ -171,7 +171,7 @@ int main(int argc, char **argv)
goto out_id;
}
- data = sqfs_data_reader_create(file, super.block_size, cmp);
+ data = sqfs_data_reader_create(file, super.block_size, cmp, 0);
if (data == NULL) {
sqfs_perror(filename, "creating data reader",
SQFS_ERROR_ALLOC);
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
goto out_data;
}
- dr = sqfs_dir_reader_create(&super, cmp, file);
+ dr = sqfs_dir_reader_create(&super, cmp, file, 0);
if (dr == NULL) {
sqfs_perror(filename, "creating dir reader",
SQFS_ERROR_ALLOC);
diff --git a/bin/sqfsdiff/sqfsdiff.c b/bin/sqfsdiff/sqfsdiff.c
index b543c00..0673f8d 100644
--- a/bin/sqfsdiff/sqfsdiff.c
+++ b/bin/sqfsdiff/sqfsdiff.c
@@ -67,7 +67,7 @@ static int open_sfqs(sqfs_state_t *state, const char *path)
}
state->dr = sqfs_dir_reader_create(&state->super, state->cmp,
- state->file);
+ state->file, 0);
if (state->dr == NULL) {
sqfs_perror(path, "creating directory reader",
SQFS_ERROR_ALLOC);
@@ -83,7 +83,7 @@ static int open_sfqs(sqfs_state_t *state, const char *path)
state->data = sqfs_data_reader_create(state->file,
state->super.block_size,
- state->cmp);
+ state->cmp, 0);
if (state->data == NULL) {
sqfs_perror(path, "creating data reader", SQFS_ERROR_ALLOC);
goto fail_tree;
diff --git a/bin/tar2sqfs/process_tarball.c b/bin/tar2sqfs/process_tarball.c
index 3863014..415e362 100644
--- a/bin/tar2sqfs/process_tarball.c
+++ b/bin/tar2sqfs/process_tarball.c
@@ -42,7 +42,7 @@ static int copy_xattr(sqfs_writer_t *sqfs, tree_node_t *node,
tar_xattr_t *xattr;
int ret;
- ret = sqfs_xattr_writer_begin(sqfs->xwr);
+ ret = sqfs_xattr_writer_begin(sqfs->xwr, 0);
if (ret) {
sqfs_perror(hdr->name, "beginning xattr block", ret);
return -1;
diff --git a/extras/list_files.c b/extras/list_files.c
index 4862a22..434601a 100644
--- a/extras/list_files.c
+++ b/extras/list_files.c
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
}
/* create a directory reader and scan the entire directory hiearchy */
- dr = sqfs_dir_reader_create(&super, cmp, file);
+ dr = sqfs_dir_reader_create(&super, cmp, file, 0);
if (dr == NULL) {
fprintf(stderr, "%s: error creating directory reader.\n",
argv[1]);
diff --git a/include/sqfs/data_reader.h b/include/sqfs/data_reader.h
index 58022c9..c967a70 100644
--- a/include/sqfs/data_reader.h
+++ b/include/sqfs/data_reader.h
@@ -62,13 +62,15 @@ extern "C" {
* underlying filesystem image.
* @param block_size The data block size from the super block.
* @param cmp A compressor to use for uncompressing blocks read from disk.
+ * @param flags Currently must be 0 or the function will fail.
*
* @return A pointer to a new data reader object. NULL means
* allocation failure.
*/
SQFS_API sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
size_t block_size,
- sqfs_compressor_t *cmp);
+ sqfs_compressor_t *cmp,
+ sqfs_u32 flags);
/**
* @brief Read and decode the fragment table from disk.
diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h
index 52e97fd..cf9f2a1 100644
--- a/include/sqfs/dir_reader.h
+++ b/include/sqfs/dir_reader.h
@@ -161,12 +161,14 @@ extern "C" {
* resolving table positions.
* @param cmp A compressor to use for unpacking meta data blocks.
* @param file The input file to read from.
+ * @param flags Currently must be zero or the function fails.
*
* @return A new directory reader on success, NULL on allocation failure.
*/
SQFS_API sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
sqfs_compressor_t *cmp,
- sqfs_file_t *file);
+ sqfs_file_t *file,
+ sqfs_u32 flags);
/**
* @brief Navigate a directory reader to the location of a directory
@@ -181,11 +183,13 @@ SQFS_API sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
*
* @param rd A pointer to a directory reader.
* @param inode An directory or extended directory inode.
+ * @param flags Currently must be zero or the function fails.
*
* @return Zero on success, an @ref SQFS_ERROR value on failure.
*/
SQFS_API int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd,
- const sqfs_inode_generic_t *inode);
+ const sqfs_inode_generic_t *inode,
+ sqfs_u32 flags);
/**
* @brief Reset a directory reader back to the beginning of the listing.
diff --git a/include/sqfs/xattr_writer.h b/include/sqfs/xattr_writer.h
index 4b93118..8820e51 100644
--- a/include/sqfs/xattr_writer.h
+++ b/include/sqfs/xattr_writer.h
@@ -61,9 +61,11 @@ extern "C" {
*
* @memberof sqfs_xattr_writer_t
*
+ * @param flags Currently must be zero or the function fails.
+ *
* @return A pointer to a new xattr writer, NULL on allocation failure.
*/
-SQFS_API sqfs_xattr_writer_t *sqfs_xattr_writer_create(void);
+SQFS_API sqfs_xattr_writer_t *sqfs_xattr_writer_create(sqfs_u32 flags);
/**
* @brief Begin recording a block of key-value pairs.
@@ -74,10 +76,11 @@ SQFS_API sqfs_xattr_writer_t *sqfs_xattr_writer_create(void);
* @ref sqfs_xattr_writer_end when you are done.
*
* @param xwr A pointer to an xattr writer instance.
+ * @param flags Currently must be zero, or the function will fail.
*
* @return Zero on success, a negative @ref SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_xattr_writer_begin(sqfs_xattr_writer_t *xwr);
+SQFS_API int sqfs_xattr_writer_begin(sqfs_xattr_writer_t *xwr, sqfs_u32 flags);
/**
* @brief Add a key-value pair to the current block.
diff --git a/lib/common/writer.c b/lib/common/writer.c
index a446c41..9032a99 100644
--- a/lib/common/writer.c
+++ b/lib/common/writer.c
@@ -155,7 +155,7 @@ int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg)
}
if (!wrcfg->no_xattr) {
- sqfs->xwr = sqfs_xattr_writer_create();
+ sqfs->xwr = sqfs_xattr_writer_create(0);
if (sqfs->xwr == NULL) {
sqfs_perror(wrcfg->filename, "creating xattr writer",
diff --git a/lib/sqfs/data_reader.c b/lib/sqfs/data_reader.c
index cd9ad68..7148a53 100644
--- a/lib/sqfs/data_reader.c
+++ b/lib/sqfs/data_reader.c
@@ -184,10 +184,15 @@ fail_ftbl:
sqfs_data_reader_t *sqfs_data_reader_create(sqfs_file_t *file,
size_t block_size,
- sqfs_compressor_t *cmp)
+ sqfs_compressor_t *cmp,
+ sqfs_u32 flags)
{
- sqfs_data_reader_t *data = alloc_flex(sizeof(*data), 1, block_size);
+ sqfs_data_reader_t *data;
+ if (flags != 0)
+ return NULL;
+
+ data = alloc_flex(sizeof(*data), 1, block_size);
if (data == NULL)
return NULL;
diff --git a/lib/sqfs/dir_reader.c b/lib/sqfs/dir_reader.c
index 8e23ddb..49d1188 100644
--- a/lib/sqfs/dir_reader.c
+++ b/lib/sqfs/dir_reader.c
@@ -73,11 +73,16 @@ fail_mino:
sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
sqfs_compressor_t *cmp,
- sqfs_file_t *file)
+ sqfs_file_t *file,
+ sqfs_u32 flags)
{
- sqfs_dir_reader_t *rd = calloc(1, sizeof(*rd));
+ sqfs_dir_reader_t *rd;
sqfs_u64 start, limit;
+ if (flags != 0)
+ return NULL;
+
+ rd = calloc(1, sizeof(*rd));
if (rd == NULL)
return NULL;
@@ -115,11 +120,15 @@ sqfs_dir_reader_t *sqfs_dir_reader_create(const sqfs_super_t *super,
}
int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd,
- const sqfs_inode_generic_t *inode)
+ const sqfs_inode_generic_t *inode,
+ sqfs_u32 flags)
{
sqfs_u64 block_start;
size_t size, offset;
+ if (flags != 0)
+ return SQFS_ERROR_UNSUPPORTED;
+
if (inode->base.type == SQFS_INODE_DIR) {
size = inode->data.dir.size;
offset = inode->data.dir.offset;
@@ -274,7 +283,7 @@ int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd,
continue;
}
- ret = sqfs_dir_reader_open_dir(rd, inode);
+ ret = sqfs_dir_reader_open_dir(rd, inode, 0);
free(inode);
if (ret)
return ret;
diff --git a/lib/sqfs/read_tree.c b/lib/sqfs/read_tree.c
index 5464595..b668ef4 100644
--- a/lib/sqfs/read_tree.c
+++ b/lib/sqfs/read_tree.c
@@ -124,7 +124,7 @@ static int fill_dir(sqfs_dir_reader_t *dr, sqfs_tree_node_t *root,
if (n->inode->base.type == SQFS_INODE_DIR ||
n->inode->base.type == SQFS_INODE_EXT_DIR) {
if (!(flags & SQFS_TREE_NO_RECURSE)) {
- err = sqfs_dir_reader_open_dir(dr, n->inode);
+ err = sqfs_dir_reader_open_dir(dr, n->inode, 0);
if (err)
return err;
@@ -220,7 +220,7 @@ int sqfs_dir_reader_get_full_hierarchy(sqfs_dir_reader_t *rd,
continue;
}
- ret = sqfs_dir_reader_open_dir(rd, tail->inode);
+ ret = sqfs_dir_reader_open_dir(rd, tail->inode, 0);
if (ret)
goto fail;
@@ -280,7 +280,7 @@ int sqfs_dir_reader_get_full_hierarchy(sqfs_dir_reader_t *rd,
if (tail->inode->base.type == SQFS_INODE_DIR ||
tail->inode->base.type == SQFS_INODE_EXT_DIR) {
- ret = sqfs_dir_reader_open_dir(rd, tail->inode);
+ ret = sqfs_dir_reader_open_dir(rd, tail->inode, 0);
if (ret)
goto fail;
diff --git a/lib/sqfs/xattr/xattr_writer.c b/lib/sqfs/xattr/xattr_writer.c
index 9de3823..c33d366 100644
--- a/lib/sqfs/xattr/xattr_writer.c
+++ b/lib/sqfs/xattr/xattr_writer.c
@@ -81,10 +81,14 @@ static void xattr_writer_destroy(sqfs_object_t *obj)
free(xwr);
}
-sqfs_xattr_writer_t *sqfs_xattr_writer_create(void)
+sqfs_xattr_writer_t *sqfs_xattr_writer_create(sqfs_u32 flags)
{
- sqfs_xattr_writer_t *xwr = calloc(1, sizeof(*xwr));
+ sqfs_xattr_writer_t *xwr;
+ if (flags != 0)
+ return NULL;
+
+ xwr = calloc(1, sizeof(*xwr));
if (str_table_init(&xwr->keys, XATTR_KEY_BUCKETS))
goto fail_keys;
diff --git a/lib/sqfs/xattr/xattr_writer_record.c b/lib/sqfs/xattr/xattr_writer_record.c
index 7cc55b6..aa87246 100644
--- a/lib/sqfs/xattr/xattr_writer_record.c
+++ b/lib/sqfs/xattr/xattr_writer_record.c
@@ -37,8 +37,11 @@ static int compare_u64(const void *a, const void *b)
return (lhs < rhs ? -1 : (lhs > rhs ? 1 : 0));
}
-int sqfs_xattr_writer_begin(sqfs_xattr_writer_t *xwr)
+int sqfs_xattr_writer_begin(sqfs_xattr_writer_t *xwr, sqfs_u32 flags)
{
+ if (flags != 0)
+ return SQFS_ERROR_UNSUPPORTED;
+
xwr->kv_start = xwr->num_pairs;
return 0;
}