diff mbox series

[v1] src/vfs/utils: Reset errno to zero when detect O_TMPFILE

Message ID 1671078101-15585-1-git-send-email-xuyang2018.jy@fujitsu.com (mailing list archive)
State New, archived
Headers show
Series [v1] src/vfs/utils: Reset errno to zero when detect O_TMPFILE | expand

Commit Message

Yang Xu (Fujitsu) Dec. 15, 2022, 4:21 a.m. UTC
For some filesystem that doesn't support O_TMPFILE, it will pass
ENOTSUP errno to upper layer. so it will report the following error:
QA output created by 696
vfstest.c: 1818: setgid_create_umask - Success - failure: is_setgid
vfstest.c: 2421: run_test - Operation not supported - failure...

To fix this, just reset errno before return.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 src/vfs/utils.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Zorro Lang Dec. 16, 2022, 7:13 p.m. UTC | #1
On Thu, Dec 15, 2022 at 12:21:41PM +0800, Yang Xu wrote:
> For some filesystem that doesn't support O_TMPFILE, it will pass
> ENOTSUP errno to upper layer. so it will report the following error:
> QA output created by 696
> vfstest.c: 1818: setgid_create_umask - Success - failure: is_setgid
> vfstest.c: 2421: run_test - Operation not supported - failure...
> 
> To fix this, just reset errno before return.
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---

I never hit this failure before, but this change make sense to me.

Reviewed-by: Zorro Lang <zlang@redhat.com>

>  src/vfs/utils.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/vfs/utils.c b/src/vfs/utils.c
> index 6db7a11d..8b000506 100644
> --- a/src/vfs/utils.c
> +++ b/src/vfs/utils.c
> @@ -921,10 +921,12 @@ bool openat_tmpfile_supported(int dirfd)
>  
>  	fd = openat(dirfd, ".", O_TMPFILE | O_RDWR, S_IXGRP | S_ISGID);
>  	if (fd == -1) {
> -		if (errno == ENOTSUP)
> +		if (errno == ENOTSUP) {
> +			errno = 0; /* Don't report misleading errno. */
>  			return false;
> -		else
> +		} else {
>  			return log_errno(false, "failure: create");
> +		}
>  	}
>  
>  	if (close(fd))
> -- 
> 2.27.0
>
diff mbox series

Patch

diff --git a/src/vfs/utils.c b/src/vfs/utils.c
index 6db7a11d..8b000506 100644
--- a/src/vfs/utils.c
+++ b/src/vfs/utils.c
@@ -921,10 +921,12 @@  bool openat_tmpfile_supported(int dirfd)
 
 	fd = openat(dirfd, ".", O_TMPFILE | O_RDWR, S_IXGRP | S_ISGID);
 	if (fd == -1) {
-		if (errno == ENOTSUP)
+		if (errno == ENOTSUP) {
+			errno = 0; /* Don't report misleading errno. */
 			return false;
-		else
+		} else {
 			return log_errno(false, "failure: create");
+		}
 	}
 
 	if (close(fd))