From: Kenneth Dsouza <kdsouza@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Subject: Re: [PATCH] Add support for -L(logical) and -P(physical) option in nfs4_getfacl.
Date: Mon, 28 Jan 2019 08:33:47 +0530 [thread overview]
Message-ID: <CAA_-hQKJ7jTq44_qc3wHApthV-k28Sn4Fudgh71Adwj-iYb=-g@mail.gmail.com> (raw)
In-Reply-To: <20181205021051.8700-1-kdsouza@redhat.com>
Ping ?
On Wed, Dec 5, 2018 at 7:41 AM Kenneth D'souza <kdsouza@redhat.com> wrote:
>
> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
> ---
> man/man1/nfs4_getfacl.1 | 18 +++++++++++++-
> nfs4_getfacl/nfs4_getfacl.c | 47 +++++++++++++++++++++++++++++++++----
> 2 files changed, 59 insertions(+), 6 deletions(-)
>
> diff --git a/man/man1/nfs4_getfacl.1 b/man/man1/nfs4_getfacl.1
> index 83067c9..940a2b5 100644
> --- a/man/man1/nfs4_getfacl.1
> +++ b/man/man1/nfs4_getfacl.1
> @@ -8,7 +8,7 @@
> .SH NAME
> nfs4_getfacl \- get NFSv4 file/directory access control lists
> .SH SYNOPSIS
> -.B nfs4_getfacl [-HR]
> +.B nfs4_getfacl [-HRLP]
> file ...
> .SH DESCRIPTION
> .B nfs4_getfacl
> @@ -28,6 +28,22 @@ flag is specified,
> .B nfs4_getfacl
> will list the NFSv4 ACLs of all files and directories recursively.
>
> +If the
> +.BR -L / --logical
> +flag is specified,
> +.B nfs4_getfacl
> +will follow symbolic links to directories. The default behavior is to follow
> +symbolic link arguments, and skip symbolic links encountered in subdirectories.
> +Only effective in combination with -R.
> +
> +If the
> +.BR -P / --physical
> +flag is specified,
> +.B nfs4_getfacl
> +will not follow symbolic links to directories. This also skips symbolic link
> +arguments.
> +Only effective in combination with -R.
> +
> The output format for an NFSv4 file ACL, e.g., is:
> .RS
> .nf
> diff --git a/nfs4_getfacl/nfs4_getfacl.c b/nfs4_getfacl/nfs4_getfacl.c
> index 5a9c911..dd5c1b9 100644
> --- a/nfs4_getfacl/nfs4_getfacl.c
> +++ b/nfs4_getfacl/nfs4_getfacl.c
> @@ -46,9 +46,19 @@ static void usage(int);
> static void more_help();
> static char *execname;
> static void print_acl_from_path();
> +static int walk_type = 0;
> +static void logical();
>
> static int recursive(const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
> {
> + if ((tflag == FTW_SL) && (walk_type == 2))
> + return 0;
> +
> + if ((tflag == FTW_SL) && (walk_type == 1)) {
> + logical(fpath);
> + return 0;
> + }
> +
> print_acl_from_path(fpath);
> return 0;
> }
> @@ -56,14 +66,16 @@ static int recursive(const char *fpath, const struct stat *sb, int tflag, struct
> static struct option long_options[] = {
> {"more-help", 0, 0, 'H' },
> {"help", 0, 0, 'h' },
> - {"recursive", 0, 0, 'R' },
> + {"recursive", 0, 0, 'R' },
> + {"logical", 0, 0, 'L' },
> + {"physical", 0, 0, 'P' },
> { NULL, 0, 0, 0, },
> };
>
> int main(int argc, char **argv)
> {
> int opt, res = 1;
> - int do_recursive = 0;
> + int flag, do_recursive = 0;
>
> execname = basename(argv[0]);
>
> @@ -73,7 +85,7 @@ int main(int argc, char **argv)
> goto out;
> }
>
> - while ((opt = getopt_long(argc, argv, "HR?h", long_options, NULL)) != -1) {
> + while ((opt = getopt_long(argc, argv, "HR?hLP", long_options, NULL)) != -1) {
> switch(opt) {
> case 'H':
> more_help();
> @@ -84,6 +96,22 @@ int main(int argc, char **argv)
> do_recursive = 1;
> break;
>
> + case 'L':
> + if (walk_type != 0) {
> + fprintf(stderr, "More than one walk type specified\n");
> + goto out;
> + }
> + walk_type = 1; /* Follow all symbolic links */
> + break;
> +
> + case 'P':
> + if (walk_type != 0) {
> + fprintf(stderr, "More than one walk type specified\n");
> + goto out;
> + }
> + walk_type = 2; /* Skip all symbolic links */
> + break;
> +
> default:
> usage(1);
> res = 0;
> @@ -99,7 +127,10 @@ int main(int argc, char **argv)
>
> for(; optind < argc; optind++) {
> if(do_recursive) {
> - if (nftw(argv[optind], recursive, 20, 0) == -1)
> + if (walk_type == 2 || walk_type == 1)
> + flag = FTW_PHYS;
> +
> + if (nftw(argv[optind], recursive, 20, flag) == -1)
> printf("Invalid filename: %s\n", argv[optind]);
> }
> else
> @@ -121,11 +152,17 @@ static void print_acl_from_path(const char *fpath)
> }
> }
>
> +static void logical(const char *fpath)
> +{
> + if (nftw(fpath, recursive, 20, 0) == -1)
> + printf("Invalid filename: %s\n", fpath);
> +}
> +
> static void usage(int label)
> {
> if (label)
> fprintf(stderr, "%s %s -- get NFSv4 file or directory access control lists.\n", execname, VERSION);
> - fprintf(stderr, "Usage: %s [-R] file ...\n -H, --more-help\tdisplay ACL format information\n -?, -h, --help\tdisplay this help text\n -R --recursive\trecurse into subdirectories\n", execname);
> + fprintf(stderr, "Usage: %s [-RPL] file ...\n -H, --more-help\tdisplay ACL format information\n -?, -h, --help\tdisplay this help text\n -R, --recursive\trecurse into subdirectories\n -L, --logical\t\tlogical walk, follow symbolic links\n -P, --physical\tphysical walk, do not follow symbolic links\n", execname);
> }
>
> static void more_help()
> --
> 2.17.2
>
prev parent reply other threads:[~2019-01-28 3:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-05 2:10 [PATCH] Add support for -L(logical) and -P(physical) option in nfs4_getfacl Kenneth D'souza
2019-01-28 3:03 ` Kenneth Dsouza [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA_-hQKJ7jTq44_qc3wHApthV-k28Sn4Fudgh71Adwj-iYb=-g@mail.gmail.com' \
--to=kdsouza@redhat.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).