Dolda2000 GitWeb
/
utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Make info file updates atomic.
[utils.git]
/
bkselect.c
diff --git
a/bkselect.c
b/bkselect.c
index
7912898
..
96f3ad9
100644
(file)
--- a/
bkselect.c
+++ b/
bkselect.c
@@
-5,8
+5,7
@@
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
-#include <attr/xattr.h>
-#include <attr/attributes.h>
+#include <sys/xattr.h>
int printsize = 0;
int printnames = 1;
int printsize = 0;
int printnames = 1;
@@
-23,8
+22,8
@@
int bkselect(char *path, int s)
int pbl, pl, al;
al = sizeof(ab) - 1;
int pbl, pl, al;
al = sizeof(ab) - 1;
- if(
attr_get(path, "bkselect", ab, &al, 0)
) {
- if(errno == ENO
ATTR
) {
+ if(
(al = getxattr(path, "user.bkselect", ab, sizeof(ab))) < 0
) {
+ if(errno == ENO
DATA
) {
} else if(errno == EPERM) {
/* Ignore for now because of weird effects... */
} else if(errno == E2BIG) {
} else if(errno == EPERM) {
/* Ignore for now because of weird effects... */
} else if(errno == E2BIG) {
@@
-70,9
+69,11
@@
int bkselect(char *path, int s)
if(bkselect(pb, s))
r = 1;
} else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
if(bkselect(pb, s))
r = 1;
} else if(S_ISREG(sb.st_mode) || S_ISLNK(sb.st_mode)) {
- if(s && printnames)
- printf("%s\n", pb);
- tsize += sb.st_size;
+ if(s) {
+ if(printnames)
+ printf("%s\n", pb);
+ tsize += sb.st_size;
+ }
}
}
}
}
@@
-82,14
+83,15
@@
int bkselect(char *path, int s)
void usage(void)
{
void usage(void)
{
- fprintf(stderr, "usage: bkselect [-hsq
] path...
\n");
+ fprintf(stderr, "usage: bkselect [-hsq
o] [path...]
\n");
}
int main(int argc, char **argv)
{
}
int main(int argc, char **argv)
{
- int c, i, r;
+ int c, i, r
, s
;
- while((c = getopt(argc, argv, "hsq")) >= 0) {
+ s = 1;
+ while((c = getopt(argc, argv, "hsqo")) >= 0) {
switch(c) {
case 's':
printsize = 1;
switch(c) {
case 's':
printsize = 1;
@@
-97,6
+99,9
@@
int main(int argc, char **argv)
case 'q':
printnames = 0;
break;
case 'q':
printnames = 0;
break;
+ case 'o':
+ s = 0;
+ break;
case 'h':
default:
usage();
case 'h':
default:
usage();
@@
-104,13
+109,13
@@
int main(int argc, char **argv)
}
}
if(argc - optind < 1) {
}
}
if(argc - optind < 1) {
-
usage(
);
- exit(1);
- }
- r = 0;
- for(i = optind; i < argc; i++) {
- if(bkselect(argv[i], 0))
- r = 1;
+
r = bkselect(".", s
);
+ } else {
+ r = 0;
+ for(i = optind; i < argc; i++) {
+ if(bkselect(argv[i], s))
+ r = 1;
+ }
}
if(printsize)
printf("%lli\n", tsize);
}
if(printsize)
printf("%lli\n", tsize);