8 #include <attr/xattr.h>
9 #include <attr/attributes.h>
11 int bkselect(char *path, int s)
22 if(attr_get(path, "bkselect", ab, &al, 0)) {
23 if(errno == ENOATTR) {
24 } else if(errno == EPERM) {
25 /* Ignore for now because of weird effects... */
26 } else if(errno == E2BIG) {
27 fprintf(stderr, "warning: bad bkselect value on %s", path);
34 if(!strcmp(ab, "y")) {
36 } else if(!strcmp(ab, "n")) {
39 fprintf(stderr, "warning: bad bkselect value on %s", path);
43 if((d = opendir(path)) == NULL) {
50 pb = malloc(pbl = pl + 2);
53 while((de = readdir(d)) != NULL) {
54 if(!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
56 if(strlen(de->d_name) + pl + 2 > pbl) {
57 pbl = strlen(de->d_name) + pl + 2;
58 pb = realloc(pb, pbl);
60 strcpy(pb + pl + 1, de->d_name);
65 if(S_ISDIR(sb.st_mode)) {
68 } else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
78 int main(int argc, char **argv)
83 fprintf(stderr, "usage: bkselect path...\n");
87 for(i = 1; i < argc; i++) {
88 if(bkselect(argv[i], 0))