diff options
author | green <green@FreeBSD.org> | 2002-10-10 17:16:00 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 2002-10-10 17:16:00 +0000 |
commit | 22299c98475bd852c8dca621d95e815cd48a4668 (patch) | |
tree | 87ac113a38ab0bc334e07e9bd047f3a06e349f09 /usr.sbin | |
parent | 8d1b432ebca11727add6494b7b74e57979cf4a44 (diff) | |
download | FreeBSD-src-22299c98475bd852c8dca621d95e815cd48a4668.zip FreeBSD-src-22299c98475bd852c8dca621d95e815cd48a4668.tar.gz |
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
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/extattr/rmextattr.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.sbin/extattr/rmextattr.c b/usr.sbin/extattr/rmextattr.c index 13bebc6..a86eb62 100644 --- a/usr.sbin/extattr/rmextattr.c +++ b/usr.sbin/extattr/rmextattr.c @@ -62,7 +62,7 @@ usage(void) fprintf(stderr, " attrname filename ...\n"); exit(-1); case EASET: - fprintf(stderr, "usage: setextattr [-fhq] attrnamespace"); + fprintf(stderr, "usage: setextattr [-fhnq] attrnamespace"); fprintf(stderr, " attrname attrvalue filename ...\n"); exit(-1); case EARM: @@ -107,6 +107,7 @@ main(int argc, char *argv[]) int flag_force = 0; int flag_nofollow = 0; + int flag_null = 0; int flag_quiet = 0; int flag_string = 0; int flag_hex = 0; @@ -123,7 +124,7 @@ main(int argc, char *argv[]) minargc = 3; } else if (!strcmp(p, "setextattr")) { what = EASET; - options = "fhq"; + options = "fhnq"; minargc = 4; } else if (!strcmp(p, "rmextattr")) { what = EARM; @@ -145,6 +146,9 @@ main(int argc, char *argv[]) case 'h': flag_nofollow = 1; break; + case 'n': + flag_null = 1; + break; case 'q': flag_quiet = 1; break; @@ -199,10 +203,12 @@ main(int argc, char *argv[]) case EASET: if (flag_nofollow) error = extattr_set_link(argv[arg_counter], - attrnamespace, attrname, buf, strlen(buf)); + attrnamespace, attrname, buf, + strlen(buf) + flag_null); else error = extattr_set_file(argv[arg_counter], - attrnamespace, attrname, buf, strlen(buf)); + attrnamespace, attrname, buf, + strlen(buf) + flag_null); if (error >= 0) continue; break; |