summaryrefslogtreecommitdiff
path: root/src/cmd/setxattr.c
blob: c2e422e497c75a2abcac13dd87221f98ba459f04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <camellia.h>
#include <camellia/syscalls.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

int
main(int argc, char **argv)
{
	if (argc != 4) {
		fprintf(stderr, "usage: setxattr file key value\n");
		return 1;
	}
	hid_t h = camellia_open(argv[1], OPEN_WRITE);
	if (h < 0) err(1, "open");

	ssize_t ret = _sys_setxattr(h, argv[2], argv[3], strlen(argv[3]), 0);
	if (ret < 0) {
		errno = -ret;
		err(1, "setxattr");
	}
}