From: frezidok1@gmail.com
To: yocto-patches@lists.yoctoproject.org
Cc: Dmitry Sakhonchik <frezidok1@gmail.com>
Subject: [pseudo] [PATCH v2 1/4] ports/linux/guts: Add open_tree wrapper
Date: Fri, 4 Sep 2026 16:06:24 +0300 [thread overview]
Message-ID: <20260904130627.453678-2-frezidok1@gmail.com> (raw)
In-Reply-To: <20260904130627.453678-1-frezidok1@gmail.com>
From: Dmitry Sakhonchik <frezidok1@gmail.com>
[YOCTO #16379]
OPEN_TREE_CLONE is not handled since it requires CAP_SYS_ADMIN and is outside the common pseudo use case.
Signed-off-by: Dmitry Sakhonchik <frezidok1@gmail.com>
---
ports/linux/guts/open_tree.c | 46 ++++++++++++++++++++++++++++++++++++
ports/linux/portdefs.h | 9 +++++++
ports/linux/wrapfuncs.in | 1 +
3 files changed, 56 insertions(+)
create mode 100644 ports/linux/guts/open_tree.c
diff --git a/ports/linux/guts/open_tree.c b/ports/linux/guts/open_tree.c
new file mode 100644
index 0000000..6c2aad9
--- /dev/null
+++ b/ports/linux/guts/open_tree.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2026 Yocto Project
+ * guts/COPYRIGHT for information.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * int open_tree(int dirfd, const char *path, unsigned int flags)
+ * int rc = -1;
+ */
+
+ struct stat64 buf;
+ int save_errno;
+ char *pseudo_path;
+
+ if (real_open_tree) {
+ pseudo_debug(PDBGF_SYSCALL, "open_tree, calling open_tree.\n");
+ rc = real_open_tree(dirfd, path, flags);
+ } else {
+ pseudo_debug(PDBGF_SYSCALL, "open_tree, calling syscall.\n");
+ rc = real_syscall(SYS_open_tree, dirfd, path, flags);
+ }
+
+ pseudo_path = pseudo_root_path(__func__, __LINE__, dirfd, path, 0);
+
+ if (rc != -1) {
+ save_errno = errno;
+ int stat_rc;
+
+ stat_rc = real___fxstatat64(_STAT_VER, dirfd, pseudo_path, &buf, (flags & AT_SYMLINK_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
+
+ pseudo_debug(PDBGF_FILE, "open_tree(path %s), flags %o, stat rc %d, stat mode %o\n",
+ pseudo_path, flags, stat_rc, buf.st_mode);
+
+ if (stat_rc != -1) {
+ pseudo_client_op(OP_OPEN, 0, rc, dirfd, pseudo_path, &buf);
+ } else {
+ pseudo_debug(PDBGF_FILE, "open_tree(fd %d, path %d/%s, flags %d) succeeded, but stat failed (%s).\n",
+ rc, dirfd, pseudo_path, flags, strerror(errno));
+ pseudo_client_op(OP_OPEN, 0, rc, dirfd, pseudo_path, 0);
+ }
+ errno = save_errno;
+ }
+
+/* return rc;
+ * }
+ */
diff --git a/ports/linux/portdefs.h b/ports/linux/portdefs.h
index 1f1a41a..565fed9 100644
--- a/ports/linux/portdefs.h
+++ b/ports/linux/portdefs.h
@@ -82,3 +82,12 @@ extern int unshare(int flags);
#define SYS_openat2 __NR_openat2
#endif
+
+#ifndef SYS_open_tree
+
+#ifndef __NR_open_tree
+#define __NR_open_tree 428
+#endif
+
+#define SYS_open_tree __NR_open_tree
+#endif
diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in
index 3cea20a..a51e9a0 100644
--- a/ports/linux/wrapfuncs.in
+++ b/ports/linux/wrapfuncs.in
@@ -10,6 +10,7 @@ int lchown(const char *path, uid_t owner, gid_t group); /* flags=AT_SYMLINK_NOFO
int __fxstatat(int ver, int dirfd, const char *path, struct stat *buf, int flags);
int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=((flags&O_NOFOLLOW)||((flags&(O_CREAT|O_EXCL))==(O_CREAT|O_EXCL))), noignore_path=1 */
int __openat_2(int dirfd, const char *path, int flags); /* flags=((flags&O_NOFOLLOW)||((flags&(O_CREAT|O_EXCL))==(O_CREAT|O_EXCL))), noignore_path=1 */
+int open_tree(int dirfd, const char *path, unsigned int flags); /* noignore_path=1 */
int mknod(const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknod */
int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknodat */
int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev); /* flags=AT_SYMLINK_NOFOLLOW */
next prev parent reply other threads:[~2026-09-04 13:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 13:06 [pseudo] [PATCH v2 0/4] Add open_tree() wrapper frezidok1
2026-09-04 13:06 ` frezidok1 [this message]
2026-09-04 13:06 ` [pseudo] [PATCH v2 2/4] test: Add open_tree test frezidok1
2026-09-04 13:06 ` [pseudo] [PATCH v2 3/4] ports/linux/pseudo_wrappers.c: Add syscall support for open_tree() wrapper frezidok1
2026-09-04 13:06 ` [pseudo] [PATCH v2 4/4] test: Add open_tree syscall test frezidok1
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=20260904130627.453678-2-frezidok1@gmail.com \
--to=frezidok1@gmail.com \
--cc=yocto-patches@lists.yoctoproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.