summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 03:38:15 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 18:34:16 +0200
commit08c22510ba901d73f2841434e7e6a2a688b31fa8 (patch)
treed47ec6fa8c5d61739a71468efa5a3046336c513f
parent9293e4ed36ace256666cddee1b96381b456b0ce7 (diff)
Remove xattr restore & rest of rdtree flags
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--difftool/sqfsdiff.c4
-rw-r--r--include/highlevel.h12
-rw-r--r--lib/sqfshelper/deserialize_fstree.c84
-rw-r--r--lib/sqfshelper/sqfs_reader.c9
4 files changed, 15 insertions, 94 deletions
diff --git a/difftool/sqfsdiff.c b/difftool/sqfsdiff.c
index 05a7bfe..777678b 100644
--- a/difftool/sqfsdiff.c
+++ b/difftool/sqfsdiff.c
@@ -28,7 +28,7 @@ int main(int argc, char **argv)
if (errno == ENOTDIR) {
sd.old_is_dir = false;
- if (sqfs_reader_open(&sd.sqfs_old, sd.old_path, 0))
+ if (sqfs_reader_open(&sd.sqfs_old, sd.old_path))
return 2;
} else {
perror(sd.old_path);
@@ -54,7 +54,7 @@ int main(int argc, char **argv)
if (errno == ENOTDIR) {
sd.new_is_dir = false;
- if (sqfs_reader_open(&sd.sqfs_new, sd.new_path, 0)) {
+ if (sqfs_reader_open(&sd.sqfs_new, sd.new_path)) {
status = 2;
goto out_sqfs_old;
}
diff --git a/include/highlevel.h b/include/highlevel.h
index 0ace08e..6d4b4e6 100644
--- a/include/highlevel.h
+++ b/include/highlevel.h
@@ -34,10 +34,6 @@ typedef struct {
fstree_t fs;
} sqfs_reader_t;
-enum RDTREE_FLAGS {
- RDTREE_READ_XATTR = 0x20,
-};
-
/*
High level helper function to serialize an entire file system tree to
a squashfs inode table and directory table.
@@ -63,13 +59,12 @@ tree_node_t *tree_node_from_inode(sqfs_inode_generic_t *inode,
const char *name);
/*
- Restore a file system tree from a squashfs image. The given flags are a
- combination of RDTREE_FLAGS.
+ Restore a file system tree from a squashfs image.
Returns 0 on success. Prints error messages to stderr on failure.
*/
int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
- sqfs_compressor_t *cmp, sqfs_file_t *file, int flags);
+ sqfs_compressor_t *cmp, sqfs_file_t *file);
/*
Generate a squahfs xattr table from a file system tree.
@@ -94,8 +89,7 @@ void sqfs_print_statistics(sqfs_super_t *super, data_writer_stats_t *stats);
construct datastructures we need to access its contents.
Returns 0 on success. Prints error messages to stderr on failure.
*/
-int sqfs_reader_open(sqfs_reader_t *rd, const char *filename,
- int rdtree_flags);
+int sqfs_reader_open(sqfs_reader_t *rd, const char *filename);
/* Cleanup after a successfull sqfs_reader_open */
void sqfs_reader_close(sqfs_reader_t *rd);
diff --git a/lib/sqfshelper/deserialize_fstree.c b/lib/sqfshelper/deserialize_fstree.c
index ee06103..411711b 100644
--- a/lib/sqfshelper/deserialize_fstree.c
+++ b/lib/sqfshelper/deserialize_fstree.c
@@ -15,36 +15,6 @@
#include <string.h>
#include <stdio.h>
-static int restore_xattr(sqfs_xattr_reader_t *xr, fstree_t *fs,
- tree_node_t *node, sqfs_inode_generic_t *inode)
-{
- uint32_t idx;
-
- switch (inode->base.type) {
- case SQFS_INODE_EXT_DIR:
- idx = inode->data.dir_ext.xattr_idx;
- break;
- case SQFS_INODE_EXT_FILE:
- idx = inode->data.file_ext.xattr_idx;
- break;
- case SQFS_INODE_EXT_SLINK:
- idx = inode->data.slink_ext.xattr_idx;
- break;
- case SQFS_INODE_EXT_BDEV:
- case SQFS_INODE_EXT_CDEV:
- idx = inode->data.dev_ext.xattr_idx;
- break;
- case SQFS_INODE_EXT_FIFO:
- case SQFS_INODE_EXT_SOCKET:
- idx = inode->data.ipc_ext.xattr_idx;
- break;
- default:
- return 0;
- }
-
- return xattr_reader_restore_node(xr, fs, node, idx);
-}
-
static bool node_would_be_own_parent(tree_node_t *root, tree_node_t *n)
{
while (root != NULL) {
@@ -74,7 +44,7 @@ fail:
static int fill_dir(sqfs_dir_reader_t *dr,
tree_node_t *root, sqfs_id_table_t *idtbl,
- fstree_t *fs, sqfs_xattr_reader_t *xr, int flags)
+ fstree_t *fs)
{
sqfs_inode_generic_t *inode;
sqfs_dir_entry_t *ent;
@@ -116,15 +86,6 @@ static int fill_dir(sqfs_dir_reader_t *dr,
continue;
}
- if (flags & RDTREE_READ_XATTR) {
- if (restore_xattr(xr, fs, n, inode)) {
- free(n);
- free(ent);
- free(inode);
- return -1;
- }
- }
-
free(ent);
n->inode = inode;
@@ -139,7 +100,7 @@ static int fill_dir(sqfs_dir_reader_t *dr,
if (err)
return -1;
- if (fill_dir(dr, n, idtbl, fs, xr, flags))
+ if (fill_dir(dr, n, idtbl, fs))
return -1;
}
@@ -151,10 +112,9 @@ static int fill_dir(sqfs_dir_reader_t *dr,
}
int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
- sqfs_compressor_t *cmp, sqfs_file_t *file, int flags)
+ sqfs_compressor_t *cmp, sqfs_file_t *file)
{
sqfs_inode_generic_t *root;
- sqfs_xattr_reader_t *xr;
sqfs_id_table_t *idtbl;
sqfs_dir_reader_t *dr;
int status = -1;
@@ -170,22 +130,15 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
if (sqfs_id_table_read(idtbl, file, super, cmp))
goto out_id;
- xr = sqfs_xattr_reader_create(file, super, cmp);
- if (xr == NULL)
- goto out_id;
-
- if (sqfs_xattr_reader_load_locations(xr))
- goto out_xr;
-
if (sqfs_dir_reader_get_root_inode(dr, &root))
- goto out_xr;
+ goto out_id;
if (root->base.type != SQFS_INODE_DIR &&
root->base.type != SQFS_INODE_EXT_DIR) {
free(root);
fputs("File system root inode is not a directory inode!\n",
stderr);
- goto out_xr;
+ goto out_id;
}
memset(out, 0, sizeof(*out));
@@ -199,26 +152,7 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
if (out->root == NULL) {
free(root);
- goto out_xr;
- }
-
- if (flags & RDTREE_READ_XATTR) {
- if (str_table_init(&out->xattr_keys,
- FSTREE_XATTR_KEY_BUCKETS)) {
- free(root);
- goto fail_fs;
- }
-
- if (str_table_init(&out->xattr_values,
- FSTREE_XATTR_VALUE_BUCKETS)) {
- free(root);
- goto fail_fs;
- }
-
- if (restore_xattr(xr, out, out->root, root)) {
- free(root);
- goto fail_fs;
- }
+ goto out_id;
}
if (sqfs_dir_reader_open_dir(dr, root)) {
@@ -228,14 +162,12 @@ int deserialize_fstree(fstree_t *out, sqfs_super_t *super,
free(root);
- if (fill_dir(dr, out->root, idtbl, out, xr, flags))
+ if (fill_dir(dr, out->root, idtbl, out))
goto fail_fs;
tree_node_sort_recursive(out->root);
status = 0;
-out_xr:
- sqfs_xattr_reader_destroy(xr);
out_id:
sqfs_id_table_destroy(idtbl);
out_dr:
@@ -243,5 +175,5 @@ out_dr:
return status;
fail_fs:
fstree_cleanup(out);
- goto out_xr;
+ goto out_id;
}
diff --git a/lib/sqfshelper/sqfs_reader.c b/lib/sqfshelper/sqfs_reader.c
index e9c9c33..b947cf7 100644
--- a/lib/sqfshelper/sqfs_reader.c
+++ b/lib/sqfshelper/sqfs_reader.c
@@ -12,7 +12,7 @@
#include <unistd.h>
#include <fcntl.h>
-int sqfs_reader_open(sqfs_reader_t *rd, const char *filename, int rdtree_flags)
+int sqfs_reader_open(sqfs_reader_t *rd, const char *filename)
{
sqfs_compressor_config_t cfg;
@@ -43,13 +43,8 @@ int sqfs_reader_open(sqfs_reader_t *rd, const char *filename, int rdtree_flags)
goto fail_cmp;
}
- if (rd->super.flags & SQFS_FLAG_NO_XATTRS)
- rdtree_flags &= ~RDTREE_READ_XATTR;
-
- if (deserialize_fstree(&rd->fs, &rd->super, rd->cmp, rd->file,
- rdtree_flags)) {
+ if (deserialize_fstree(&rd->fs, &rd->super, rd->cmp, rd->file))
goto fail_cmp;
- }
fstree_gen_file_list(&rd->fs);