8 #include <attr/xattr.h>
9 #include <attr/attributes.h>
15 int bkselect(char *path, int s)
26 if(attr_get(path, "bkselect", ab, &al, 0)) {
27 if(errno == ENOATTR) {
28 } else if(errno == EPERM) {
29 /* Ignore for now because of weird effects... */
30 } else if(errno == E2BIG) {
31 fprintf(stderr, "warning: bad bkselect value on %s", path);
38 if(!strcmp(ab, "y")) {
40 } else if(!strcmp(ab, "n")) {
43 fprintf(stderr, "warning: bad bkselect value on %s", path);
47 if((d = opendir(path)) == NULL) {
54 pb = malloc(pbl = pl + 2);
57 while((de = readdir(d)) != NULL) {
58 if(!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
60 if(strlen(de->d_name) + pl + 2 > pbl) {
61 pbl = strlen(de->d_name) + pl + 2;
62 pb = realloc(pb, pbl);
64 strcpy(pb + pl + 1, de->d_name);
69 if(S_ISDIR(sb.st_mode)) {
72 } else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
85 fprintf(stderr, "usage: bkselect [-hsq] path...\n");
88 int main(int argc, char **argv)
92 while((c = getopt(argc, argv, "hsq")) >= 0) {
103 exit((c == 'h')?0:1);
106 if(argc - optind < 1) {
111 for(i = optind; i < argc; i++) {
112 if(bkselect(argv[i], 0))
116 printf("%lli\n", tsize);