diff options
author | Andreas Gruenbacher <andreas.gruenbacher@gmail.com> | 2015-02-20 22:48:26 +0100 |
---|---|---|
committer | Andreas Gruenbacher <andreas.gruenbacher@gmail.com> | 2015-02-20 22:52:04 +0100 |
commit | c252ef434219891f616d891b46aad6b06efdd185 (patch) | |
tree | 17931b5c4710c42d12e355a1de23530d1be5c007 /tools/setfattr.c | |
parent | 0550d2bc989d390eb25f7004ee0fae2dbc693a0d (diff) | |
download | attr-c252ef434219891f616d891b46aad6b06efdd185.tar.gz |
Add setfattr --raw option
With this option, attribute values are taken as they are, without traing to
decode them. This can be thought of as the counterpart to "getfattr
--only-values".
Diffstat (limited to 'tools/setfattr.c')
-rw-r--r-- | tools/setfattr.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/setfattr.c b/tools/setfattr.c index 33a4282..e209b0d 100644 --- a/tools/setfattr.c +++ b/tools/setfattr.c @@ -42,6 +42,7 @@ struct option long_options[] = { { "value", 1, 0, 'v' }, { "no-dereference", 0, 0, 'h' }, { "restore", 1, 0, 'B' }, + { "raw", 0, 0, CHAR_MAX + 1 }, { "version", 0, 0, 'V' }, { "help", 0, 0, 'H' }, { NULL, 0, 0, 0 } @@ -53,6 +54,7 @@ int opt_set; /* set an attribute */ int opt_remove; /* remove an attribute */ int opt_restore; /* restore has been run */ int opt_deref = 1; /* dereference symbolic links */ +int opt_raw; /* attribute value is not encoded */ int had_errors; const char *progname; @@ -182,6 +184,7 @@ void help(void) " -v, --value=value use value as the attribute value\n" " -h, --no-dereference do not dereference symbolic links\n" " --restore=file restore extended attributes\n" +" --raw attribute value is not encoded\n" " --version print version and exit\n" " --help this help text\n")); } @@ -217,6 +220,10 @@ int main(int argc, char *argv[]) opt_value = optarg; break; + case CHAR_MAX + 1: + opt_raw = 1; + break; + case 'x': /* remove attribute */ if (opt_name || opt_set) goto synopsis; @@ -266,7 +273,8 @@ int do_set(const char *path, const char *name, const char *value) if (value) { size = strlen(value); - value = decode(value, &size); + if (!opt_raw) + value = decode(value, &size); if (!value) return 1; } |