summaryrefslogtreecommitdiff
path: root/unpack
diff options
context:
space:
mode:
Diffstat (limited to 'unpack')
-rw-r--r--unpack/options.c10
-rw-r--r--unpack/rdsquashfs.c19
-rw-r--r--unpack/rdsquashfs.h1
3 files changed, 29 insertions, 1 deletions
diff --git a/unpack/options.c b/unpack/options.c
index c281415..e5e0389 100644
--- a/unpack/options.c
+++ b/unpack/options.c
@@ -9,6 +9,7 @@
static struct option long_opts[] = {
{ "list", required_argument, NULL, 'l' },
{ "cat", required_argument, NULL, 'c' },
+ { "xattr", required_argument, NULL, 'x' },
{ "unpack-root", required_argument, NULL, 'p' },
{ "unpack-path", required_argument, NULL, 'u' },
{ "no-dev", no_argument, NULL, 'D' },
@@ -26,7 +27,7 @@ static struct option long_opts[] = {
{ "version", no_argument, NULL, 'V' },
};
-static const char *short_opts = "l:c:u:p:DSFLCOEZj:dqhV";
+static const char *short_opts = "l:c:u:p:x:DSFLCOEZj:dqhV";
static const char *help_string =
"Usage: %s [OPTIONS] <squashfs-file>\n"
@@ -39,6 +40,8 @@ static const char *help_string =
" the squashfs image.\n"
" --cat, -c <path> If the specified path is a regular file in the,\n"
" image, dump its contents to stdout.\n"
+" --xattr, -x <path> Enumerate extended attributes associated with\n"
+" an inode that the given path resolves to.\n"
" --unpack-path, -u <path> Unpack this sub directory from the image. To\n"
" unpack everything, simply specify /.\n"
" --describe, -d Produce a file listing from the image.\n"
@@ -152,6 +155,11 @@ void process_command_line(options_t *opt, int argc, char **argv)
free(opt->cmdpath);
opt->cmdpath = NULL;
break;
+ case 'x':
+ opt->op = OP_RDATTR;
+ opt->rdtree_flags |= RDTREE_READ_XATTR;
+ opt->cmdpath = get_path(opt->cmdpath, optarg);
+ break;
case 'l':
opt->op = OP_LS;
opt->cmdpath = get_path(opt->cmdpath, optarg);
diff --git a/unpack/rdsquashfs.c b/unpack/rdsquashfs.c
index 4b2dc6c..5eb10f2 100644
--- a/unpack/rdsquashfs.c
+++ b/unpack/rdsquashfs.c
@@ -6,6 +6,21 @@
*/
#include "rdsquashfs.h"
+static void dump_xattrs(fstree_t *fs, tree_xattr_t *xattr)
+{
+ const char *key, *value;
+ size_t i;
+
+ for (i = 0; i < xattr->num_attr; ++i) {
+ key = str_table_get_string(&fs->xattr_keys,
+ xattr->attr[i].key_index);
+ value = str_table_get_string(&fs->xattr_values,
+ xattr->attr[i].value_index);
+
+ printf("%s=%s\n", key, value);
+ }
+}
+
int main(int argc, char **argv)
{
int status = EXIT_FAILURE;
@@ -106,6 +121,10 @@ int main(int argc, char **argv)
case OP_DESCRIBE:
describe_tree(fs.root, opt.unpack_root);
break;
+ case OP_RDATTR:
+ if (n->xattr != NULL)
+ dump_xattrs(&fs, n->xattr);
+ break;
}
status = EXIT_SUCCESS;
diff --git a/unpack/rdsquashfs.h b/unpack/rdsquashfs.h
index b7c2fdf..5990ab9 100644
--- a/unpack/rdsquashfs.h
+++ b/unpack/rdsquashfs.h
@@ -45,6 +45,7 @@ enum {
OP_CAT,
OP_UNPACK,
OP_DESCRIBE,
+ OP_RDATTR,
};
typedef struct {