2 fuse_xattrs - Add xattrs support using sidecar files
4 Copyright (C) 2016 Felipe Barriga Richards <felipe {at} felipebarriga.cl>
6 This program can be distributed under the terms of the GNU GPL.
18 char *get_sidecar_path(const char *path)
20 const size_t path_len = strlen(path);
21 const size_t sidecar_ext_len = strlen(SIDECAR_EXT); // this can be optimized
22 const size_t sidecar_path_len = path_len + sidecar_ext_len + 1;
23 char *sidecar_path = (char *) malloc(sidecar_path_len);
24 memset(sidecar_path, '\0', sidecar_path_len);
25 memcpy(sidecar_path, path, path_len);
26 memcpy(sidecar_path + path_len, SIDECAR_EXT, sidecar_ext_len);
31 // TODO: make it work for binary data
32 char *sanitize_value(const char *value, size_t value_size)
34 char *sanitized = malloc(value_size + 1);
35 memcpy(sanitized, value, value_size);
36 sanitized[value_size] = '\0';
40 enum namespace get_namespace(const char *name) {
41 if (strncmp(name, "user.", strlen("user.")) == 0) {
45 if (strncmp(name, "system.", strlen("system.")) == 0) {
49 if (strncmp(name, "security.", strlen("security.")) == 0) {
53 if (strncmp(name, "trusted.", strlen("trusted.")) == 0) {
57 error_print("invalid namespace for key: %s\n", name);