mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "Gaël PORTAY" <gael.portay@rtone.fr>
To: musl@lists.openwall.com
Cc: "Gaël PORTAY" <gael.portay@rtone.fr>
Subject: [musl] [PATCH v2 8/8] use new SYS_fchmodat2 syscall to implement fchmodat with flags
Date: Sun, 18 Feb 2024 03:26:50 +0100	[thread overview]
Message-ID: <20240218022650.1097269-9-gael.portay@rtone.fr> (raw)
In-Reply-To: <20240218022650.1097269-1-gael.portay@rtone.fr>

commit 0dc4824479e357a3e23a02d35527e23fca920343 worked around for lack
of flags argument in syscall for fchmodat.

linux 6.6 introduced a new syscall, SYS_fchmodat2, fixing this
deficiency. use it if any flags are passed, and fallback to the old
strategy on ENOSYS. continue using the old syscall when there are no
flags. this is the exact same strategy used when SYS_faccessat2 was used
to implement faccessat with flags.
---
 src/stat/fchmodat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c
index 41db0c46..a3f407e3 100644
--- a/src/stat/fchmodat.c
+++ b/src/stat/fchmodat.c
@@ -5,6 +5,11 @@
 
 int fchmodat(int fd, const char *path, mode_t mode, int flag)
 {
+	if (flag) {
+		int ret = __syscall(SYS_fchmodat2, fd, path, mode, flag);
+		if (ret != -ENOSYS) return __syscall_ret(ret);
+	}
+
 	if (!flag) return syscall(SYS_fchmodat, fd, path, mode);
 
 	if (flag != AT_SYMLINK_NOFOLLOW)
-- 
2.43.2


  parent reply	other threads:[~2024-02-18  2:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18  2:26 [musl] [PATCH v2 0/8] " Gaël PORTAY
2024-02-18  2:26 ` [musl] [PATCH v2 1/8] bits/syscall.h: add process_madvise from linux v5.14 Gaël PORTAY
2024-02-23  0:32   ` Rich Felker
2024-02-18  2:26 ` [musl] [PATCH v2 2/8] bits/syscall.h: add process_mrelease from linux v5.15 Gaël PORTAY
2024-02-18  2:26 ` [musl] [PATCH v2 3/8] bits/syscall.h: add futex_waitv from linux v5.16 Gaël PORTAY
2024-02-18  2:26 ` [musl] [PATCH v2 4/8] bits/syscall.h: add set_mempolicy_home_node from linux v5.17 Gaël PORTAY
2024-02-18  2:26 ` [musl] [PATCH v2 5/8] bits/syscall.h: add cachestat from linux v6.4 Gaël PORTAY
2024-02-18  2:26 ` [musl] [PATCH v2 6/8] remove flag argument from fchmodat syscall Gaël PORTAY
2024-02-18  2:26 ` [musl] [PATCH v2 7/8] bits/syscall.h: add __NR_fchmodat2 from linux v6.6 Gaël PORTAY
2024-02-18  2:26 ` Gaël PORTAY [this message]
2024-02-23  0:36   ` [musl] [PATCH v2 8/8] use new SYS_fchmodat2 syscall to implement fchmodat with flags Rich Felker

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=20240218022650.1097269-9-gael.portay@rtone.fr \
    --to=gael.portay@rtone.fr \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).