summaryrefslogtreecommitdiffstats
path: root/bin/getfacl/getfacl.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-03-13 11:45:29 +0000
committerrwatson <rwatson@FreeBSD.org>2006-03-13 11:45:29 +0000
commit201a1558c6c27bf7ff35ddb2bdfa3537b0b122d1 (patch)
treeab56dacff00208c610173a142d8fd405934391d9 /bin/getfacl/getfacl.c
parentdf0e90beed955c2fe2128b911d58ae2e1bcb3e8c (diff)
downloadFreeBSD-src-201a1558c6c27bf7ff35ddb2bdfa3537b0b122d1.zip
FreeBSD-src-201a1558c6c27bf7ff35ddb2bdfa3537b0b122d1.tar.gz
Add "-q" argument to getfacl(1), which suppresses the per-file header
comment listing the file name, owner, and group. MFC after: 1 week Submitted by: Jan Srzednicki <w at expro dot pl>
Diffstat (limited to 'bin/getfacl/getfacl.c')
-rw-r--r--bin/getfacl/getfacl.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/bin/getfacl/getfacl.c b/bin/getfacl/getfacl.c
index 297b412..b023cb4 100644
--- a/bin/getfacl/getfacl.c
+++ b/bin/getfacl/getfacl.c
@@ -52,7 +52,7 @@ static void
usage(void)
{
- fprintf(stderr, "getfacl [-dh] [file ...]\n");
+ fprintf(stderr, "getfacl [-dhq] [file ...]\n");
}
/*
@@ -147,7 +147,7 @@ acl_from_stat(struct stat sb)
}
static int
-print_acl(char *path, acl_type_t type, int hflag)
+print_acl(char *path, acl_type_t type, int hflag, int qflag)
{
struct stat sb;
acl_t acl;
@@ -168,7 +168,9 @@ print_acl(char *path, acl_type_t type, int hflag)
else
more_than_one++;
- printf("#file:%s\n#owner:%d\n#group:%d\n", path, sb.st_uid, sb.st_gid);
+ if (!qflag)
+ printf("#file:%s\n#owner:%d\n#group:%d\n", path, sb.st_uid,
+ sb.st_gid);
if (hflag)
acl = acl_get_link_np(path, type);
@@ -204,7 +206,7 @@ print_acl(char *path, acl_type_t type, int hflag)
}
static int
-print_acl_from_stdin(acl_type_t type, int hflag)
+print_acl_from_stdin(acl_type_t type, int hflag, int qflag)
{
char *p, pathname[PATH_MAX];
int carried_error = 0;
@@ -212,7 +214,7 @@ print_acl_from_stdin(acl_type_t type, int hflag)
while (fgets(pathname, (int)sizeof(pathname), stdin)) {
if ((p = strchr(pathname, '\n')) != NULL)
*p = '\0';
- if (print_acl(pathname, type, hflag) == -1) {
+ if (print_acl(pathname, type, hflag, qflag) == -1) {
carried_error = -1;
}
}
@@ -226,10 +228,11 @@ main(int argc, char *argv[])
acl_type_t type = ACL_TYPE_ACCESS;
int carried_error = 0;
int ch, error, i;
- int hflag;
+ int hflag, qflag;
hflag = 0;
- while ((ch = getopt(argc, argv, "dh")) != -1)
+ qflag = 0;
+ while ((ch = getopt(argc, argv, "dhq")) != -1)
switch(ch) {
case 'd':
type = ACL_TYPE_DEFAULT;
@@ -237,6 +240,9 @@ main(int argc, char *argv[])
case 'h':
hflag = 1;
break;
+ case 'q':
+ qflag = 1;
+ break;
default:
usage();
return(-1);
@@ -245,17 +251,17 @@ main(int argc, char *argv[])
argv += optind;
if (argc == 0) {
- error = print_acl_from_stdin(type, hflag);
+ error = print_acl_from_stdin(type, hflag, qflag);
return(error ? 1 : 0);
}
for (i = 0; i < argc; i++) {
if (!strcmp(argv[i], "-")) {
- error = print_acl_from_stdin(type, hflag);
+ error = print_acl_from_stdin(type, hflag, qflag);
if (error == -1)
carried_error = -1;
} else {
- error = print_acl(argv[i], type, hflag);
+ error = print_acl(argv[i], type, hflag, qflag);
if (error == -1)
carried_error = -1;
}
OpenPOWER on IntegriCloud