mailing list of musl libc
 help / color / Atom feed
* [musl] [PATCH] stat: Fix chmod
@ 2020-02-19  2:32 Zhang Tianci
  2020-02-19  3:50 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Tianci @ 2020-02-19  2:32 UTC (permalink / raw)
  To: musl; +Cc: zhangtianci1, yunlong.song

chmod misses `flag` argument when calling the syscall fchmodat.
Although Linux does not use `flag` in fchmodat, but in other system,
fchmodat will get a random value and it will cause flag check error.

Signed-off-by: Zhang Tianci <zhangtianci1@huawei.com>
---
 src/stat/chmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/stat/chmod.c b/src/stat/chmod.c
index d4f53c5..e99a146 100644
--- a/src/stat/chmod.c
+++ b/src/stat/chmod.c
@@ -7,6 +7,6 @@ int chmod(const char *path, mode_t mode)
 #ifdef SYS_chmod
 	return syscall(SYS_chmod, path, mode);
 #else
-	return syscall(SYS_fchmodat, AT_FDCWD, path, mode);
+	return syscall(SYS_fchmodat, AT_FDCWD, path, mode, 0);
 #endif
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] [PATCH] stat: Fix chmod
  2020-02-19  2:32 [musl] [PATCH] stat: Fix chmod Zhang Tianci
@ 2020-02-19  3:50 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-02-19  3:50 UTC (permalink / raw)
  To: musl

On Wed, Feb 19, 2020 at 10:32:22AM +0800, Zhang Tianci wrote:
> chmod misses `flag` argument when calling the syscall fchmodat.
> Although Linux does not use `flag` in fchmodat, but in other system,
> fchmodat will get a random value and it will cause flag check error.
> 
> Signed-off-by: Zhang Tianci <zhangtianci1@huawei.com>
> ---
>  src/stat/chmod.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/stat/chmod.c b/src/stat/chmod.c
> index d4f53c5..e99a146 100644
> --- a/src/stat/chmod.c
> +++ b/src/stat/chmod.c
> @@ -7,6 +7,6 @@ int chmod(const char *path, mode_t mode)
>  #ifdef SYS_chmod
>  	return syscall(SYS_chmod, path, mode);
>  #else
> -	return syscall(SYS_fchmodat, AT_FDCWD, path, mode);
> +	return syscall(SYS_fchmodat, AT_FDCWD, path, mode, 0);
>  #endif
>  }
> -- 
> 2.17.1

The Linux fchmodat syscall does not take a flags argument, which is
why src/stat/fchmodat.c has to go to such trouble to emulate one. It's
probably a mistake (but harmless) that we pass one (always zero) in
the first line:

        if (!flag) return syscall(SYS_fchmodat, fd, path, mode, flag);

It'd be nice if Linux would add new versions of this and faccessat
that take flags like they're supposed to.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19  2:32 [musl] [PATCH] stat: Fix chmod Zhang Tianci
2020-02-19  3:50 ` Rich Felker

mailing list of musl libc

Archives are clonable: git clone --mirror http://inbox.vuxu.org/musl

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git