blob: 909a9a575f497bc7aeeaf8e857bd0406bea2c09a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
* write_xattr.c
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*/
#define SQFS_BUILDING_DLL
#include "config.h"
#include "sqfs/xattr.h"
#include "sqfs/error.h"
#include <string.h>
static const struct {
const char *prefix;
E_SQFS_XATTR_TYPE type;
} xattr_types[] = {
{ "user.", SQFS_XATTR_USER },
{ "trusted.", SQFS_XATTR_TRUSTED },
{ "security.", SQFS_XATTR_SECURITY },
};
int sqfs_get_xattr_prefix_id(const char *key)
{
size_t i, len;
for (i = 0; i < sizeof(xattr_types) / sizeof(xattr_types[0]); ++i) {
len = strlen(xattr_types[i].prefix);
if (strncmp(key, xattr_types[i].prefix, len) == 0 &&
strlen(key) > len) {
return xattr_types[i].type;
}
}
return SQFS_ERROR_UNSUPPORTED;
}
const char *sqfs_get_xattr_prefix(E_SQFS_XATTR_TYPE id)
{
size_t i;
for (i = 0; i < sizeof(xattr_types) / sizeof(xattr_types[0]); ++i) {
if (xattr_types[i].type == id)
return xattr_types[i].prefix;
}
return NULL;
}
|