diff mbox series

nfs4_setfacl: Add file name to error output.

Message ID 20200601192754.5413-1-kdsouza@redhat.com (mailing list archive)
State New, archived
Headers show
Series nfs4_setfacl: Add file name to error output. | expand

Commit Message

Kenneth Dsouza June 1, 2020, 7:27 p.m. UTC
Currently when a user tries to set acl's recursively and if
the operation fails the user is not aware on which file the error
occured. This patch adds file name to error output.

Example:
nfs4_setfacl -R -s A:dfg:6:RWX /nfsmount
Failed setxattr operation: /nfsmount/test: Operation not permitted
An error occurred during recursive file tree walk.

Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
---
 libnfs4acl/nfs4_set_acl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

J. Bruce Fields June 2, 2020, 8:11 p.m. UTC | #1
Thanks, applied.--b.

On Tue, Jun 02, 2020 at 12:57:54AM +0530, Kenneth D'souza wrote:
> Currently when a user tries to set acl's recursively and if
> the operation fails the user is not aware on which file the error
> occured. This patch adds file name to error output.
> 
> Example:
> nfs4_setfacl -R -s A:dfg:6:RWX /nfsmount
> Failed setxattr operation: /nfsmount/test: Operation not permitted
> An error occurred during recursive file tree walk.
> 
> Signed-off-by: Kenneth D'souza <kdsouza@redhat.com>
> ---
>  libnfs4acl/nfs4_set_acl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libnfs4acl/nfs4_set_acl.c b/libnfs4acl/nfs4_set_acl.c
> index 8a53f05..45e42fa 100644
> --- a/libnfs4acl/nfs4_set_acl.c
> +++ b/libnfs4acl/nfs4_set_acl.c
> @@ -61,13 +61,13 @@ int nfs4_set_acl(struct nfs4_acl *acl, const char *path)
>  		goto out_free;
>  	} else if (res < 0) {
>  		if (errno == EOPNOTSUPP)
> -			fprintf(stderr,"Operation to set ACL not supported.\n");
> +			fprintf(stderr,"Operation to set ACL not supported: %s\n", path);
>  		else if (errno == ENODATA)
> -			fprintf(stderr,"ACL Attribute not found on file.\n");
> +			fprintf(stderr,"ACL Attribute not found on file: %s\n", path);
>  		else if (errno == EREMOTEIO)
>  			fprintf(stderr,"An NFS server error occurred.\n");
>  		else
> -			perror("Failed setxattr operation");
> +			printf("Failed setxattr operation: %s: %s\n", path, strerror(errno));
>  	}
>  
>  out_free:
> -- 
> 2.21.1
diff mbox series

Patch

diff --git a/libnfs4acl/nfs4_set_acl.c b/libnfs4acl/nfs4_set_acl.c
index 8a53f05..45e42fa 100644
--- a/libnfs4acl/nfs4_set_acl.c
+++ b/libnfs4acl/nfs4_set_acl.c
@@ -61,13 +61,13 @@  int nfs4_set_acl(struct nfs4_acl *acl, const char *path)
 		goto out_free;
 	} else if (res < 0) {
 		if (errno == EOPNOTSUPP)
-			fprintf(stderr,"Operation to set ACL not supported.\n");
+			fprintf(stderr,"Operation to set ACL not supported: %s\n", path);
 		else if (errno == ENODATA)
-			fprintf(stderr,"ACL Attribute not found on file.\n");
+			fprintf(stderr,"ACL Attribute not found on file: %s\n", path);
 		else if (errno == EREMOTEIO)
 			fprintf(stderr,"An NFS server error occurred.\n");
 		else
-			perror("Failed setxattr operation");
+			printf("Failed setxattr operation: %s: %s\n", path, strerror(errno));
 	}
 
 out_free: