Add an -n option to write the trailing nul byte to the extattr when
using setextattr(8) to write a string. Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
This commit is contained in:
parent
878382facb
commit
cb0187a0da
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=104803
@ -62,7 +62,7 @@ usage(void)
|
|||||||
fprintf(stderr, " attrname filename ...\n");
|
fprintf(stderr, " attrname filename ...\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
case EASET:
|
case EASET:
|
||||||
fprintf(stderr, "usage: setextattr [-fhq] attrnamespace");
|
fprintf(stderr, "usage: setextattr [-fhnq] attrnamespace");
|
||||||
fprintf(stderr, " attrname attrvalue filename ...\n");
|
fprintf(stderr, " attrname attrvalue filename ...\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
case EARM:
|
case EARM:
|
||||||
@ -107,6 +107,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
int flag_force = 0;
|
int flag_force = 0;
|
||||||
int flag_nofollow = 0;
|
int flag_nofollow = 0;
|
||||||
|
int flag_null = 0;
|
||||||
int flag_quiet = 0;
|
int flag_quiet = 0;
|
||||||
int flag_string = 0;
|
int flag_string = 0;
|
||||||
int flag_hex = 0;
|
int flag_hex = 0;
|
||||||
@ -123,7 +124,7 @@ main(int argc, char *argv[])
|
|||||||
minargc = 3;
|
minargc = 3;
|
||||||
} else if (!strcmp(p, "setextattr")) {
|
} else if (!strcmp(p, "setextattr")) {
|
||||||
what = EASET;
|
what = EASET;
|
||||||
options = "fhq";
|
options = "fhnq";
|
||||||
minargc = 4;
|
minargc = 4;
|
||||||
} else if (!strcmp(p, "rmextattr")) {
|
} else if (!strcmp(p, "rmextattr")) {
|
||||||
what = EARM;
|
what = EARM;
|
||||||
@ -145,6 +146,9 @@ main(int argc, char *argv[])
|
|||||||
case 'h':
|
case 'h':
|
||||||
flag_nofollow = 1;
|
flag_nofollow = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
flag_null = 1;
|
||||||
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
flag_quiet = 1;
|
flag_quiet = 1;
|
||||||
break;
|
break;
|
||||||
@ -199,10 +203,12 @@ main(int argc, char *argv[])
|
|||||||
case EASET:
|
case EASET:
|
||||||
if (flag_nofollow)
|
if (flag_nofollow)
|
||||||
error = extattr_set_link(argv[arg_counter],
|
error = extattr_set_link(argv[arg_counter],
|
||||||
attrnamespace, attrname, buf, strlen(buf));
|
attrnamespace, attrname, buf,
|
||||||
|
strlen(buf) + flag_null);
|
||||||
else
|
else
|
||||||
error = extattr_set_file(argv[arg_counter],
|
error = extattr_set_file(argv[arg_counter],
|
||||||
attrnamespace, attrname, buf, strlen(buf));
|
attrnamespace, attrname, buf,
|
||||||
|
strlen(buf) + flag_null);
|
||||||
if (error >= 0)
|
if (error >= 0)
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user