From 23a3f10ab62abadf5adcfb9540f2180275ab5b0c Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 1 Aug 2019 13:50:05 +0200 Subject: Add xattr reader implementation to recover xattrs from squashfs Signed-off-by: David Oberhollenzer --- include/meta_reader.h | 3 +++ include/squashfs.h | 6 ++++++ include/xattr_reader.h | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 include/xattr_reader.h (limited to 'include') diff --git a/include/meta_reader.h b/include/meta_reader.h index 2d790d8..8369ad3 100644 --- a/include/meta_reader.h +++ b/include/meta_reader.h @@ -24,6 +24,9 @@ void meta_reader_destroy(meta_reader_t *m); int meta_reader_seek(meta_reader_t *m, uint64_t block_start, size_t offset); +void meta_reader_get_position(meta_reader_t *m, uint64_t *block_start, + size_t *offset); + /* Returns 0 on success. Internally prints to stderr on failure */ int meta_reader_read(meta_reader_t *m, void *data, size_t size); diff --git a/include/squashfs.h b/include/squashfs.h index bd3db7b..fb60049 100644 --- a/include/squashfs.h +++ b/include/squashfs.h @@ -256,6 +256,12 @@ int sqfs_super_write(sqfs_super_t *super, int fd); /* Returns 0 on success. Prints error messages to stderr on failure. */ int sqfs_super_read(sqfs_super_t *super, int fd); +/* Get id from xattr key prefix or -1 if not supported */ +int sqfs_get_xattr_prefix_id(const char *key); + +/* Get a prefix string from the ID or NULL if unknown */ +const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id); + /* Check if a given xattr key can be encoded in squashfs at all. */ bool sqfs_has_xattr(const char *key); diff --git a/include/xattr_reader.h b/include/xattr_reader.h new file mode 100644 index 0000000..a71f0f0 --- /dev/null +++ b/include/xattr_reader.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +/* + * xattr_reader.h + * + * Copyright (C) 2019 David Oberhollenzer + */ +#ifndef XATTR_READER_H +#define XATTR_READER_H + +#include "config.h" + +#include "squashfs.h" +#include "compress.h" +#include "fstree.h" + +typedef struct xattr_reader_t xattr_reader_t; + +void xattr_reader_destroy(xattr_reader_t *xr); + +xattr_reader_t *xattr_reader_create(int sqfsfd, sqfs_super_t *super, + compressor_t *cmp); + +int xattr_reader_restore_node(xattr_reader_t *xr, fstree_t *fs, + tree_node_t *node, uint32_t xattr); + +#endif /* XATTR_READER_H */ -- cgit v1.2.3