14 int bkselect(char *path, int s)
25 if((al = getxattr(path, "user.bkselect", ab, sizeof(ab))) < 0) {
26 if(errno == ENODATA) {
27 } else if(errno == EPERM) {
28 /* Ignore for now because of weird effects... */
29 } else if(errno == E2BIG) {
30 fprintf(stderr, "warning: bad bkselect value on %s", path);
37 if(!strcmp(ab, "y")) {
39 } else if(!strcmp(ab, "n")) {
42 fprintf(stderr, "warning: bad bkselect value on %s", path);
46 if((d = opendir(path)) == NULL) {
53 pb = malloc(pbl = pl + 2);
56 while((de = readdir(d)) != NULL) {
57 if(!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
59 if(strlen(de->d_name) + pl + 2 > pbl) {
60 pbl = strlen(de->d_name) + pl + 2;
61 pb = realloc(pb, pbl);
63 strcpy(pb + pl + 1, de->d_name);
68 if(S_ISDIR(sb.st_mode)) {
71 } else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
86 fprintf(stderr, "usage: bkselect [-hsqo] [path...]\n");
89 int main(int argc, char **argv)
94 while((c = getopt(argc, argv, "hsqo")) >= 0) {
108 exit((c == 'h')?0:1);
111 if(argc - optind < 1) {
112 r = bkselect(".", s);
115 for(i = optind; i < argc; i++) {
116 if(bkselect(argv[i], s))
121 printf("%lli\n", tsize);