summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/fstree.h6
-rw-r--r--include/highlevel.h3
-rw-r--r--include/util.h7
-rw-r--r--lib/fstree/Makemodule.am4
-rw-r--r--lib/fstree/node_from_path.c46
-rw-r--r--lib/fstree/node_stat.c49
-rw-r--r--lib/sqfshelper/Makemodule.am1
-rw-r--r--lib/sqfshelper/xattr_reader.c113
-rw-r--r--lib/util/Makemodule.am2
-rw-r--r--lib/util/read_data_at.c39
10 files changed, 3 insertions, 267 deletions
diff --git a/include/fstree.h b/include/fstree.h
index a93fd7c..4c68afe 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -280,18 +280,12 @@ void fstree_gen_file_list(fstree_t *fs);
*/
char *fstree_get_path(tree_node_t *node);
-/* get a struct stat from a tree node */
-void fstree_node_stat(fstree_t *fs, tree_node_t *node, struct stat *sb);
-
/* ASCIIbetically sort a linked list of tree nodes */
tree_node_t *tree_node_list_sort(tree_node_t *head);
/* ASCIIbetically sort all sub directories recursively */
void tree_node_sort_recursive(tree_node_t *root);
-/* resolve a path to a tree node. Returns NULL on failure and sets errno */
-tree_node_t *fstree_node_from_path(fstree_t *fs, const char *path);
-
/*
If the environment variable SOURCE_DATE_EPOCH is set to a parsable number
that fits into an unsigned 32 bit value, return its value. Otherwise,
diff --git a/include/highlevel.h b/include/highlevel.h
index 6d4b4e6..5067c07 100644
--- a/include/highlevel.h
+++ b/include/highlevel.h
@@ -104,9 +104,6 @@ int compressor_cfg_init_options(sqfs_compressor_config_t *cfg,
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, sqfs_id_table_t *idtbl,
tree_node_t *node);
diff --git a/include/util.h b/include/util.h
index 26c54e2..ab57c04 100644
--- a/include/util.h
+++ b/include/util.h
@@ -58,13 +58,6 @@ SQFS_INTERNAL
int read_data(const char *errstr, int fd, void *buffer, size_t size);
/*
- Similar to read_data but wrapps pread() instead of read().
-*/
-SQFS_INTERNAL
-int read_data_at(const char *errstr, off_t location,
- int fd, void *buffer, size_t size);
-
-/*
A common implementation of the '--version' command line flag.
Prints out version information. The program name is extracted from the
diff --git a/lib/fstree/Makemodule.am b/lib/fstree/Makemodule.am
index d282de7..6d3498a 100644
--- a/lib/fstree/Makemodule.am
+++ b/lib/fstree/Makemodule.am
@@ -1,9 +1,9 @@
libfstree_a_SOURCES = lib/fstree/fstree.c lib/fstree/fstree_from_file.c
libfstree_a_SOURCES += lib/fstree/fstree_sort.c lib/fstree/fstree_from_dir.c
libfstree_a_SOURCES += lib/fstree/gen_inode_table.c lib/fstree/get_path.c
-libfstree_a_SOURCES += lib/fstree/node_stat.c lib/fstree/mknode.c
+libfstree_a_SOURCES += lib/fstree/mknode.c
libfstree_a_SOURCES += lib/fstree/add_by_path.c lib/fstree/xattr.c
-libfstree_a_SOURCES += lib/fstree/node_from_path.c include/fstree.h
+libfstree_a_SOURCES += include/fstree.h
libfstree_a_SOURCES += lib/fstree/gen_file_list.c
libfstree_a_SOURCES += lib/fstree/source_date_epoch.c
libfstree_a_CFLAGS = $(AM_CFLAGS) $(LIBSELINUX_CFLAGS)
diff --git a/lib/fstree/node_from_path.c b/lib/fstree/node_from_path.c
deleted file mode 100644
index 9140b2d..0000000
--- a/lib/fstree/node_from_path.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * node_from_path.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "fstree.h"
-
-#include <string.h>
-#include <errno.h>
-
-tree_node_t *fstree_node_from_path(fstree_t *fs, const char *path)
-{
- tree_node_t *n = fs->root;
- const char *end;
- size_t len;
-
- while (path != NULL && *path != '\0') {
- if (!S_ISDIR(n->mode)) {
- errno = ENOTDIR;
- return NULL;
- }
-
- end = strchrnul(path, '/');
- len = end - path;
-
- for (n = n->data.dir->children; n != NULL; n = n->next) {
- if (strncmp(path, n->name, len) != 0)
- continue;
- if (n->name[len] != '\0')
- continue;
- break;
- }
-
- if (n == NULL) {
- errno = ENOENT;
- return NULL;
- }
-
- path = *end ? (end + 1) : end;
- }
-
- return n;
-}
diff --git a/lib/fstree/node_stat.c b/lib/fstree/node_stat.c
deleted file mode 100644
index d17d244..0000000
--- a/lib/fstree/node_stat.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * node_stat.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "fstree.h"
-
-#include <string.h>
-
-void fstree_node_stat(fstree_t *fs, tree_node_t *node, struct stat *sb)
-{
- tree_node_t *n;
-
- *sb = fs->defaults;
- sb->st_ino = node->inode_num;
- sb->st_mode = node->mode;
- sb->st_nlink = 1;
- sb->st_uid = node->uid;
- sb->st_gid = node->gid;
- sb->st_mtime = node->mod_time;
- sb->st_atime = node->mod_time;
- sb->st_ctime = node->mod_time;
-
- switch (node->mode & S_IFMT) {
- case S_IFDIR:
- sb->st_nlink = 2;
-
- for (n = node->data.dir->children; n != NULL; n = n->next)
- sb->st_nlink += 1;
-
- sb->st_size = node->data.dir->size;
- break;
- case S_IFREG:
- sb->st_size = node->data.file->size;
- break;
- case S_IFLNK:
- sb->st_size = strlen(node->data.slink_target);
- break;
- case S_IFBLK:
- case S_IFCHR:
- sb->st_rdev = node->data.devno;
- break;
- }
-
- sb->st_blocks = sb->st_size / fs->block_size;
-}
diff --git a/lib/sqfshelper/Makemodule.am b/lib/sqfshelper/Makemodule.am
index 67f81a4..5078f69 100644
--- a/lib/sqfshelper/Makemodule.am
+++ b/lib/sqfshelper/Makemodule.am
@@ -6,7 +6,6 @@ libsqfshelper_a_SOURCES += lib/sqfshelper/sqfs_reader.c
libsqfshelper_a_SOURCES += lib/sqfshelper/tree_node_to_inode.c
libsqfshelper_a_SOURCES += lib/sqfshelper/write_export_table.c
libsqfshelper_a_SOURCES += lib/sqfshelper/print_version.c
-libsqfshelper_a_SOURCES += lib/sqfshelper/xattr_reader.c
libsqfshelper_a_SOURCES += lib/sqfshelper/inode_stat.c
libsqfshelper_a_SOURCES += lib/sqfshelper/compress.c lib/sqfshelper/comp_opt.c
libsqfshelper_a_SOURCES += include/data_reader.h lib/sqfshelper/data_reader.c
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;
-}
diff --git a/lib/util/Makemodule.am b/lib/util/Makemodule.am
index 2692c01..1d77fd5 100644
--- a/lib/util/Makemodule.am
+++ b/lib/util/Makemodule.am
@@ -3,7 +3,7 @@ libutil_la_SOURCES += lib/util/read_data.c include/util.h
libutil_la_SOURCES += lib/util/mkdir_p.c
libutil_la_SOURCES += lib/util/str_table.c include/str_table.h
libutil_la_SOURCES += lib/util/dirstack.c lib/util/padd_file.c
-libutil_la_SOURCES += lib/util/read_data_at.c lib/util/alloc.c
+libutil_la_SOURCES += lib/util/alloc.c
libutil_la_SOURCES += lib/util/canonicalize_name.c
libutil_la_CFLAGS = $(AM_CFLAGS)
libutil_la_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/lib/util/read_data_at.c b/lib/util/read_data_at.c
deleted file mode 100644
index 058909a..0000000
--- a/lib/util/read_data_at.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: LGPL-3.0-or-later */
-/*
- * read_data_at.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include "util.h"
-
-int read_data_at(const char *errstr, off_t location, int fd,
- void *buffer, size_t size)
-{
- ssize_t ret;
-
- while (size > 0) {
- ret = pread(fd, buffer, size, location);
- if (ret < 0) {
- if (errno == EINTR)
- continue;
- perror(errstr);
- return -1;
- }
- if (ret == 0) {
- fprintf(stderr, "%s: short read\n", errstr);
- return -1;
- }
-
- size -= ret;
- buffer = (char *)buffer + ret;
- location += ret;
- }
-
- return 0;
-}