debug_winbindd.sh: add "n" to ps options to avoid name translation
[slow/toolbox.git] / ea.c
1 #include <stdio.h>
2 #include <errno.h>
3 #include <string.h>
4 #include <sys/types.h>
5
6 #ifdef LINUX
7 #include <attr/xattr.h>
8 #else
9 #include <sys/stat.h>
10 #include <fcntl.h>
11 #endif
12
13 int main(int argc, char **argv)
14 {
15     int fd;
16     char buf[4];
17
18     if (argc != 2) {
19         printf("usage: ea FILE\n");
20         return(1);
21     }
22
23     printf("Setting ea on \"%s\"\n", argv[1]);
24
25 #ifdef LINUX
26     if (setxattr(argv[1], "user.test", buf, sizeof(buf), 0) != 0) {
27         printf("setxattr: %s, %d\n", strerror(errno), errno);
28     }
29
30     if (lsetxattr(argv[1], "user.test", buf, sizeof(buf), 0) != 0) {
31         printf("lsetxattr: %s, %d\n", strerror(errno), errno);
32     }
33
34     if (llistxattr(argv[1], NULL, 0) == -1) {
35         printf("llistxattr: %s, %d\n", strerror(errno), errno);
36     }
37 #else
38     if ((fd = attropen(argv[1], "ea", O_RDWR | O_NOFOLLOW, 0)) == -1) {
39         printf("attropen(AT_SYMLINK_NOFOLLOW): %s, %d\n", strerror(errno), errno);
40     }
41
42     if ((fd = open(argv[1], O_RDONLY | O_NOFOLLOW)) == -1) {
43         printf("open(O_NOFOLLOW): %s, %d\n", strerror(errno), errno);
44     }
45 #endif
46
47
48     return 0;
49 }