1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include <sys/xattr.h>
- #include "libbb.h"
- int setfattr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
- int setfattr_main(int argc UNUSED_PARAM, char **argv)
- {
- const char *name;
- const char *value = "";
- int status;
- int opt;
- enum {
- OPT_h = (1 << 0),
- OPT_x = (1 << 1),
- };
- opt = getopt32(argv, "^"
- "hx:n:v:"
-
- "\0" "-1:x:n:n--x:x--nv:v--x"
- , &name, &name, &value
- );
- argv += optind;
- status = EXIT_SUCCESS;
- do {
- int r;
- if (opt & OPT_x)
- r = ((opt & OPT_h) ? lremovexattr : removexattr)(*argv, name);
- else {
- r = ((opt & OPT_h) ? lsetxattr : setxattr)(
- *argv, name,
- value, strlen(value), 0
- );
- }
- if (r) {
- bb_simple_perror_msg(*argv);
- status = EXIT_FAILURE;
- }
- } while (*++argv);
- return status;
- }
|