aboutsummaryrefslogtreecommitdiff
path: root/lib/sqfshelper/xattr_reader.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 03:52:49 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-20 18:34:17 +0200
commitc106a290ed07fa89b39072925b1a2258071511a8 (patch)
tree973dc9a4d7eceec0925ee9196d7683cb396d83f2 /lib/sqfshelper/xattr_reader.c
parent9486151f186e3664c8dd429fba94f9e539377d87 (diff)
Large round of dead code removal
Remove all the library functions that no longer have any users. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfshelper/xattr_reader.c')
-rw-r--r--lib/sqfshelper/xattr_reader.c113
1 files changed, 0 insertions, 113 deletions
diff --git a/lib/sqfshelper/xattr_reader.c b/lib/sqfshelper/xattr_reader.c
deleted file mode 100644
index 376fdb2..0000000
--- a/lib/sqfshelper/xattr_reader.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * xattr_reader.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "highlevel.h"
-#include "util.h"
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-static int restore_kv_pairs(sqfs_xattr_reader_t *xr, fstree_t *fs,
- tree_node_t *node)
-{
- size_t i, key_idx, val_idx;
- sqfs_xattr_entry_t *key;
- sqfs_xattr_value_t *val;
- int ret;
-
- for (i = 0; i < node->xattr->num_attr; ++i) {
- if (sqfs_xattr_reader_read_key(xr, &key))
- return -1;
-
- if (sqfs_xattr_reader_read_value(xr, key, &val))
- goto fail_key;
-
- ret = str_table_get_index(&fs->xattr_keys,
- (const char *)key->key, &key_idx);
- if (ret)
- goto fail_kv;
-
- ret = str_table_get_index(&fs->xattr_values,
- (const char *)val->value, &val_idx);
- if (ret)
- goto fail_kv;
-
- if (sizeof(size_t) > sizeof(uint32_t)) {
- if (key_idx > 0xFFFFFFFFUL) {
- fputs("too many unique xattr keys\n", stderr);
- goto fail_kv;
- }
-
- if (val_idx > 0xFFFFFFFFUL) {
- fputs("too many unique xattr values\n", stderr);
- goto fail_kv;
- }
- }
-
- node->xattr->attr[i].key_index = key_idx;
- node->xattr->attr[i].value_index = val_idx;
-
- free(key);
- free(val);
- }
-
- return 0;
-fail_kv:
- free(val);
-fail_key:
- free(key);
- return -1;
-}
-
-int xattr_reader_restore_node(sqfs_xattr_reader_t *xr, fstree_t *fs,
- tree_node_t *node, uint32_t xattr)
-{
- sqfs_xattr_id_t desc;
- tree_xattr_t *it;
-
- for (it = fs->xattr; it != NULL; it = it->next) {
- if (it->index == xattr) {
- node->xattr = it;
- return 0;
- }
- }
-
- if (sqfs_xattr_reader_get_desc(xr, xattr, &desc))
- return -1;
-
- if (desc.count == 0 || desc.size == 0)
- return 0;
-
- node->xattr = alloc_flex(sizeof(*node->xattr),
- sizeof(node->xattr->attr[0]), desc.count);
- if (node->xattr == NULL) {
- perror("creating xattr structure");
- return -1;
- }
-
- node->xattr->num_attr = desc.count;
- node->xattr->max_attr = desc.count;
- node->xattr->size = desc.size;
- node->xattr->index = xattr;
- node->xattr->owner = node;
-
- if (sqfs_xattr_reader_seek_kv(xr, &desc))
- return -1;
-
- if (restore_kv_pairs(xr, fs, node)) {
- free(node->xattr);
- return -1;
- }
-
- node->xattr->next = fs->xattr;
- fs->xattr = node->xattr;
- return 0;
-}