From 12a0b40d09546839f67c8c216d0f20a6609716b2 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 27 Dec 2017 11:23:43 -0600 Subject: Promote setfattr --- toys/other/setfattr.c | 41 +++++++++++++++++++++++++++++++++++++++++ toys/pending/setfattr.c | 41 ----------------------------------------- 2 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 toys/other/setfattr.c delete mode 100644 toys/pending/setfattr.c diff --git a/toys/other/setfattr.c b/toys/other/setfattr.c new file mode 100644 index 00000000..48817aa2 --- /dev/null +++ b/toys/other/setfattr.c @@ -0,0 +1,41 @@ +/* setfattr.c - Write POSIX extended attributes. + * + * Copyright 2016 Android Open Source Project. + * + * No standard + +USE_SETFATTR(NEWTOY(setfattr, "hn:|v:x:|[!xv]", TOYFLAG_USR|TOYFLAG_BIN)) + +config SETFATTR + bool "setfattr" + default y + help + usage: setfattr [-h] [-x|-n NAME] [-v VALUE] FILE... + + Write POSIX extended attributes. + + -h Do not dereference symlink + -n Set given attribute + -x Remove given attribute + -v Set value for attribute -n (default is empty) +*/ + +#define FOR_setfattr +#include "toys.h" + +GLOBALS( + char *x, *v, *n; +) + +void setfattr_main(void) +{ + int h = toys.optflags & FLAG_h, rc; + char **s; + + for (s=toys.optargs; *s; s++) { + if (TT.x) rc = (h?lremovexattr:removexattr)(*s, TT.x); + else rc = (h?lsetxattr:setxattr)(*s, TT.n, TT.v, TT.v?strlen(TT.v):0, 0); + + if (rc) perror_msg("%s", *s); + } +} diff --git a/toys/pending/setfattr.c b/toys/pending/setfattr.c deleted file mode 100644 index efec9a53..00000000 --- a/toys/pending/setfattr.c +++ /dev/null @@ -1,41 +0,0 @@ -/* setfattr.c - Write POSIX extended attributes. - * - * Copyright 2016 Android Open Source Project. - * - * No standard - -USE_SETFATTR(NEWTOY(setfattr, "hn:|v:x:|[!xv]", TOYFLAG_USR|TOYFLAG_BIN)) - -config SETFATTR - bool "setfattr" - default n - help - usage: setfattr [-h] [-x|-n NAME] [-v VALUE] FILE... - - Write POSIX extended attributes. - - -h Do not dereference symlink - -n Set given attribute - -x Remove given attribute - -v Set value for attribute -n (default is empty) -*/ - -#define FOR_setfattr -#include "toys.h" - -GLOBALS( - char *x, *v, *n; -) - -void setfattr_main(void) -{ - int h = toys.optflags & FLAG_h, rc; - char **s; - - for (s=toys.optargs; *s; s++) { - if (TT.x) rc = (h?lremovexattr:removexattr)(*s, TT.x); - else rc = (h?lsetxattr:setxattr)(*s, TT.n, TT.v, TT.v?strlen(TT.v):0, 0); - - if (rc) perror_msg("%s", *s); - } -} -- cgit v1.2.3