return -ENOSPC;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
#ifdef DEBUG
char *sanitized_value = sanitize_value(value, size);
return -ERANGE;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
debug_print("path=%s name=%s size=%zu\n", _path, name, size);
int rtval = binary_storage_read_key(_path, name, value, size);
free(_path);
return -E2BIG;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
debug_print("path=%s size=%zu\n", _path, size);
int rtval = binary_storage_list_keys(_path, list, size);
free(_path);
return -ERANGE;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
debug_print("path=%s name=%s\n", _path, name);
int rtval = binary_storage_remove_key(_path, name);
free(_path);
case FUSE_OPT_KEY_NONOPT:
if (!xattrs_config.source_dir) {
xattrs_config.source_dir = sanitized_source_directory(arg);
+ xattrs_config.source_dir_size = strlen(xattrs_config.source_dir);
return 0;
}
break;
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = lstat(_path, stbuf);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = access(_path, mask);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = readlink(_path, buf, size - 1);
free(_path);
(void) offset;
(void) fi;
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
dp = opendir(_path);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
/* On Linux this could just be 'mknod(path, mode, rdev)' but this
is more portable */
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = mkdir(_path, mode);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = unlink(_path);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = rmdir(_path);
free(_path);
}
}
- char *_to = prepend_source_directory(xattrs_config.source_dir, to);
+ char *_to = prepend_source_directory(to);
res = symlink(from, _to);
free(_to);
}
}
- char *_from = prepend_source_directory(xattrs_config.source_dir, from);
- char *_to = prepend_source_directory(xattrs_config.source_dir, to);
+ char *_from = prepend_source_directory(from);
+ char *_to = prepend_source_directory(to);
res = rename(_from, _to);
free(_from);
free(_to);
}
}
- char *_from = prepend_source_directory(xattrs_config.source_dir, from);
- char *_to = prepend_source_directory(xattrs_config.source_dir, to);
+ char *_from = prepend_source_directory(from);
+ char *_to = prepend_source_directory(to);
res = link(_from, _to);
free(_from);
free(_to);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = chmod(_path, mode);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = lchown(_path, uid, gid);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = truncate(_path, size);
free(_path);
(void) fi;
int res;
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
/* don't use utime/utimes since they follow symlinks */
res = utimensat(0, _path, ts, AT_SYMLINK_NOFOLLOW);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = open(_path, fi->flags);
free(_path);
int res;
(void) fi;
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
fd = open(_path, O_RDONLY);
free(_path);
int res;
(void) fi;
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
fd = open(_path, O_WRONLY);
free(_path);
return -ENOENT;
}
- char *_path = prepend_source_directory(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
res = statvfs(_path, stbuf);
free(_path);
if (mode)
return -EOPNOTSUPP;
- char *_path = concat(xattrs_config.source_dir, path);
+ char *_path = prepend_source_directory(path);
fd = open(_path, O_WRONLY);
free(_path);
#include "utils.h"
#include "fuse_xattrs_config.h"
+#include "xattrs_config.h"
-char *prepend_source_directory(const char *a, const char *b) {
- size_t len = strlen(a) + strlen(b) + 1;
- char *dst = (char*) malloc(sizeof(char) * len);
- sprintf(dst, "%s%s", a, b);
+/* TODO: re-use memory to avoid calling malloc every time */
+char *prepend_source_directory(const char *b) {
+ const size_t b_size = strlen(b);
+ const size_t dst_len = xattrs_config.source_dir_size + b_size + 1;
+ char *dst = (char*) malloc(sizeof(char) * dst_len);
+
+ memcpy(dst, xattrs_config.source_dir, xattrs_config.source_dir_size);
+ memcpy(dst+xattrs_config.source_dir_size, b, b_size + 1); // include '\0'
+ //sprintf(dst, "%s%s", a, b);
return dst;
}