4
* Copyright (C) 2002-2005 Novell/SUSE
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License as
8
* published by the Free Software Foundation, version 2 of the
11
#include <sys/xattr.h>
17
#define msgstring "hello"
18
#define msglen (strlen(msgstring)+1)
21
*DESCRIPTION this test does setxattr on a file
23
*argv[1] - file to test
24
*argv[2] - xattr namespace to test
25
*argv[3] - "read", "write", "remove"
27
int main(int argc, char *argv[])
34
fprintf(stderr, "usage: %s file xattr-name_space {read,write,remove}\n",
36
for (i=0; i < argc; i++) {
37
fprintf(stderr, "arg%d: %s\n", i, argv[i]);
42
snprintf(name, sizeof(name), "%s.sdtest", argv[2]);
43
if (strcmp(argv[3], "read") == 0) {
45
len = lgetxattr(argv[1], name, &value, 256);
47
fprintf(stderr, "FAIL: get of %s on %s. %s\n", name,
48
argv[1], strerror(errno));
51
} else if (strcmp(argv[3], "write") == 0) {
52
len = lsetxattr(argv[1], name, msgstring, msglen, 0);
54
fprintf(stderr, "FAIL: set of %s on %s. %s\n", name,
55
argv[1], strerror(errno));
58
} else if (strcmp(argv[3], "remove") == 0) {
59
len = lremovexattr(argv[1], name);
61
fprintf(stderr, "FAIL: remove of %s on %s. %s\n",
62
name, argv[1], strerror(errno));
66
fprintf(stderr, "usage: %s invalid option %s is not one of {read, write, remove}\n", argv[0], argv[3]);