diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-05 17:37:19 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-05 17:37:19 +0200 |
commit | f85394c5887350a9728e108e72d908e08fc4cb78 (patch) | |
tree | 76ee4e50a5ece365d1c429271bd735dca40f01ad | |
parent | a4b4c27bb01e64ff0072be78f7ddc0fa64193bfa (diff) |
Cleanup: add sqfs_* prefix to id table
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | include/highlevel.h | 6 | ||||
-rw-r--r-- | include/sqfs/id_table.h | 25 | ||||
-rw-r--r-- | lib/sqfs/id_table.c | 21 | ||||
-rw-r--r-- | lib/sqfshelper/deserialize_fstree.c | 11 | ||||
-rw-r--r-- | lib/sqfshelper/serialize_fstree.c | 2 | ||||
-rw-r--r-- | lib/sqfshelper/tree_node_from_inode.c | 6 | ||||
-rw-r--r-- | lib/sqfshelper/tree_node_to_inode.c | 6 | ||||
-rw-r--r-- | mkfs/mkfs.c | 8 | ||||
-rw-r--r-- | tar/tar2sqfs.c | 8 |
9 files changed, 48 insertions, 45 deletions
diff --git a/include/highlevel.h b/include/highlevel.h index cb0c5d0..701754a 100644 --- a/include/highlevel.h +++ b/include/highlevel.h @@ -53,7 +53,7 @@ enum RDTREE_FLAGS { Returns 0 on success. Prints error messages to stderr on failure. */ int sqfs_serialize_fstree(int outfd, sqfs_super_t *super, fstree_t *fs, - compressor_t *cmp, id_table_t *idtbl); + compressor_t *cmp, sqfs_id_table_t *idtbl); /* Convert a generic squashfs tree node to an fstree_t node. @@ -61,7 +61,7 @@ int sqfs_serialize_fstree(int outfd, sqfs_super_t *super, fstree_t *fs, Prints error messages to stderr on failure. */ tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode, - const id_table_t *idtbl, + const sqfs_id_table_t *idtbl, const char *name, size_t block_size); @@ -115,7 +115,7 @@ void compressor_print_help(E_SQFS_COMPRESSOR id); int xattr_reader_restore_node(sqfs_xattr_reader_t *xr, fstree_t *fs, tree_node_t *node, uint32_t xattr); -sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, id_table_t *idtbl, +sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, sqfs_id_table_t *idtbl, tree_node_t *node); #endif /* HIGHLEVEL_H */ diff --git a/include/sqfs/id_table.h b/include/sqfs/id_table.h index 951c55e..65e77bc 100644 --- a/include/sqfs/id_table.h +++ b/include/sqfs/id_table.h @@ -4,8 +4,8 @@ * * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> */ -#ifndef ID_TABLE_H -#define ID_TABLE_H +#ifndef SQFS_ID_TABLE_H +#define SQFS_ID_TABLE_H #include "config.h" @@ -14,35 +14,36 @@ #include "compress.h" -typedef struct id_table_t id_table_t; +typedef struct sqfs_id_table_t sqfs_id_table_t; #ifdef __cplusplus extern "C" { #endif /* Prints error message to stderr on failure. */ -id_table_t *id_table_create(void); +sqfs_id_table_t *sqfs_id_table_create(void); -void id_table_destroy(id_table_t *tbl); +void sqfs_id_table_destroy(sqfs_id_table_t *tbl); /* Resolve a 32 bit to a 16 bit table index. Returns 0 on success. Internally prints errors to stderr. */ -int id_table_id_to_index(id_table_t *tbl, uint32_t id, uint16_t *out); +int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out); /* Write an ID table to a SquashFS image. Returns 0 on success. Internally prints error message to stderr. */ -int id_table_write(id_table_t *tbl, int outfd, sqfs_super_t *super, - compressor_t *cmp); +int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd, sqfs_super_t *super, + compressor_t *cmp); /* Read an ID table from a SquashFS image. Returns 0 on success. Internally prints error messages to stderr. */ -int id_table_read(id_table_t *tbl, int fd, sqfs_super_t *super, - compressor_t *cmp); +int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd, sqfs_super_t *super, + compressor_t *cmp); -int id_table_index_to_id(const id_table_t *tbl, uint16_t index, uint32_t *out); +int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index, + uint32_t *out); #ifdef __cplusplus } #endif -#endif /* ID_TABLE_H */ +#endif /* SQFS_ID_TABLE_H */ diff --git a/lib/sqfs/id_table.c b/lib/sqfs/id_table.c index 75d5db4..2b8044c 100644 --- a/lib/sqfs/id_table.c +++ b/lib/sqfs/id_table.c @@ -13,15 +13,15 @@ #include <string.h> #include <stdio.h> -struct id_table_t { +struct sqfs_id_table_t { uint32_t *ids; size_t num_ids; size_t max_ids; }; -id_table_t *id_table_create(void) +sqfs_id_table_t *sqfs_id_table_create(void) { - id_table_t *tbl = calloc(1, sizeof(*tbl)); + sqfs_id_table_t *tbl = calloc(1, sizeof(*tbl)); if (tbl == NULL) perror("Creating ID table"); @@ -29,13 +29,13 @@ id_table_t *id_table_create(void) return tbl; } -void id_table_destroy(id_table_t *tbl) +void sqfs_id_table_destroy(sqfs_id_table_t *tbl) { free(tbl->ids); free(tbl); } -int id_table_id_to_index(id_table_t *tbl, uint32_t id, uint16_t *out) +int sqfs_id_table_id_to_index(sqfs_id_table_t *tbl, uint32_t id, uint16_t *out) { size_t i, sz; void *ptr; @@ -70,7 +70,8 @@ int id_table_id_to_index(id_table_t *tbl, uint32_t id, uint16_t *out) return 0; } -int id_table_index_to_id(const id_table_t *tbl, uint16_t index, uint32_t *out) +int sqfs_id_table_index_to_id(const sqfs_id_table_t *tbl, uint16_t index, + uint32_t *out) { if (index >= tbl->num_ids) { fputs("attempted out of bounds ID table access\n", stderr); @@ -81,8 +82,8 @@ int id_table_index_to_id(const id_table_t *tbl, uint16_t index, uint32_t *out) return 0; } -int id_table_read(id_table_t *tbl, int fd, sqfs_super_t *super, - compressor_t *cmp) +int sqfs_id_table_read(sqfs_id_table_t *tbl, int fd, sqfs_super_t *super, + compressor_t *cmp) { uint64_t upper_limit, lower_limit; size_t i; @@ -126,8 +127,8 @@ int id_table_read(id_table_t *tbl, int fd, sqfs_super_t *super, return 0; } -int id_table_write(id_table_t *tbl, int outfd, sqfs_super_t *super, - compressor_t *cmp) +int sqfs_id_table_write(sqfs_id_table_t *tbl, int outfd, sqfs_super_t *super, + compressor_t *cmp) { uint64_t start; size_t i; diff --git a/lib/sqfshelper/deserialize_fstree.c b/lib/sqfshelper/deserialize_fstree.c index 71cc57e..8d3c916 100644 --- a/lib/sqfshelper/deserialize_fstree.c +++ b/lib/sqfshelper/deserialize_fstree.c @@ -79,7 +79,8 @@ static bool node_would_be_own_parent(tree_node_t *root, tree_node_t *n) } static int fill_dir(sqfs_meta_reader_t *ir, sqfs_meta_reader_t *dr, - tree_node_t *root, sqfs_super_t *super, id_table_t *idtbl, + tree_node_t *root, sqfs_super_t *super, + sqfs_id_table_t *idtbl, fstree_t *fs, sqfs_xattr_reader_t *xr, int flags) { sqfs_inode_generic_t *inode; @@ -208,7 +209,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp, sqfs_meta_reader_t *ir, *dr; sqfs_inode_generic_t *root; sqfs_xattr_reader_t *xr; - id_table_t *idtbl; + sqfs_id_table_t *idtbl; int status = -1; size_t offset; @@ -228,11 +229,11 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp, if (dr == NULL) goto out_ir; - idtbl = id_table_create(); + idtbl = sqfs_id_table_create(); if (idtbl == NULL) goto out_dr; - if (id_table_read(idtbl, fd, super, cmp)) + if (sqfs_id_table_read(idtbl, fd, super, cmp)) goto out_id; xr = sqfs_xattr_reader_create(fd, super, cmp); @@ -297,7 +298,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super, compressor_t *cmp, out_xr: sqfs_xattr_reader_destroy(xr); out_id: - id_table_destroy(idtbl); + sqfs_id_table_destroy(idtbl); out_dr: sqfs_meta_reader_destroy(dr); out_ir: diff --git a/lib/sqfshelper/serialize_fstree.c b/lib/sqfshelper/serialize_fstree.c index 0a574a0..f400a53 100644 --- a/lib/sqfshelper/serialize_fstree.c +++ b/lib/sqfshelper/serialize_fstree.c @@ -42,7 +42,7 @@ static int write_dir_entries(sqfs_dir_writer_t *dirw, tree_node_t *node) } int sqfs_serialize_fstree(int outfd, sqfs_super_t *super, fstree_t *fs, - compressor_t *cmp, id_table_t *idtbl) + compressor_t *cmp, sqfs_id_table_t *idtbl) { sqfs_inode_generic_t *inode; sqfs_meta_writer_t *im, *dm; diff --git a/lib/sqfshelper/tree_node_from_inode.c b/lib/sqfshelper/tree_node_from_inode.c index d8b3361..68365d0 100644 --- a/lib/sqfshelper/tree_node_from_inode.c +++ b/lib/sqfshelper/tree_node_from_inode.c @@ -58,7 +58,7 @@ static void copy_block_sizes(sqfs_inode_generic_t *inode, tree_node_t *out, } tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode, - const id_table_t *idtbl, + const sqfs_id_table_t *idtbl, const char *name, size_t block_size) { @@ -70,12 +70,12 @@ tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode, return NULL; } - if (id_table_index_to_id(idtbl, inode->base.uid_idx, &out->uid)) { + if (sqfs_id_table_index_to_id(idtbl, inode->base.uid_idx, &out->uid)) { free(out); return NULL; } - if (id_table_index_to_id(idtbl, inode->base.gid_idx, &out->gid)) { + if (sqfs_id_table_index_to_id(idtbl, inode->base.gid_idx, &out->gid)) { free(out); return NULL; } diff --git a/lib/sqfshelper/tree_node_to_inode.c b/lib/sqfshelper/tree_node_to_inode.c index d3346e2..7de8abd 100644 --- a/lib/sqfshelper/tree_node_to_inode.c +++ b/lib/sqfshelper/tree_node_to_inode.c @@ -81,7 +81,7 @@ static int get_type(tree_node_t *node) assert(0); } -sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, id_table_t *idtbl, +sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, sqfs_id_table_t *idtbl, tree_node_t *node) { size_t i, extra = 0, block_count = 0; @@ -124,10 +124,10 @@ sqfs_inode_generic_t *tree_node_to_inode(fstree_t *fs, id_table_t *idtbl, } } - if (id_table_id_to_index(idtbl, node->uid, &uid_idx)) + if (sqfs_id_table_id_to_index(idtbl, node->uid, &uid_idx)) goto fail; - if (id_table_id_to_index(idtbl, node->gid, &gid_idx)) + if (sqfs_id_table_id_to_index(idtbl, node->gid, &gid_idx)) goto fail; if (node->xattr != NULL) diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index 75d4cd8..abd7422 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -94,10 +94,10 @@ int main(int argc, char **argv) { int status = EXIT_FAILURE, ret; compressor_config_t cfg; + sqfs_id_table_t *idtbl; data_writer_t *data; sqfs_super_t super; compressor_t *cmp; - id_table_t *idtbl; options_t opt; fstree_t fs; int outfd; @@ -117,7 +117,7 @@ int main(int argc, char **argv) goto out_fstree; } - idtbl = id_table_create(); + idtbl = sqfs_id_table_create(); if (idtbl == NULL) goto out_fstree; @@ -185,7 +185,7 @@ int main(int argc, char **argv) goto out_data; } - if (id_table_write(idtbl, outfd, &super, cmp)) + if (sqfs_id_table_write(idtbl, outfd, &super, cmp)) goto out_data; if (write_xattr(outfd, &fs, &super, cmp)) @@ -210,7 +210,7 @@ out_cmp: out_outfd: close(outfd); out_idtbl: - id_table_destroy(idtbl); + sqfs_id_table_destroy(idtbl); out_fstree: fstree_cleanup(&fs); return status; diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index fba1a31..22b7cda 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -356,10 +356,10 @@ int main(int argc, char **argv) { int outfd, status = EXIT_SUCCESS; compressor_config_t cfg; + sqfs_id_table_t *idtbl; data_writer_t *data; sqfs_super_t super; compressor_t *cmp; - id_table_t *idtbl; fstree_t fs; int ret; @@ -404,7 +404,7 @@ int main(int argc, char **argv) if (data == NULL) goto out_cmp; - idtbl = id_table_create(); + idtbl = sqfs_id_table_create(); if (idtbl == NULL) goto out_data; @@ -433,7 +433,7 @@ int main(int argc, char **argv) goto out; } - if (id_table_write(idtbl, outfd, &super, cmp)) + if (sqfs_id_table_write(idtbl, outfd, &super, cmp)) goto out; if (write_xattr(outfd, &fs, &super, cmp)) @@ -452,7 +452,7 @@ int main(int argc, char **argv) status = EXIT_SUCCESS; out: - id_table_destroy(idtbl); + sqfs_id_table_destroy(idtbl); out_data: data_writer_destroy(data); out_cmp: |