From patchwork Mon Sep 7 11:18:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97504 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96399C79F9E for ; Mon, 7 Sep 2026 11:19:50 +0000 (UTC) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.32733.1788779981592517144 for ; Mon, 07 Sep 2026 04:19:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=jckNaXpg; spf=pass (domain: gmail.com, ip: 209.85.208.47, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-6a5e329c0f2so3784107a12.3 for ; Mon, 07 Sep 2026 04:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788779980; x=1789384780; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Va4C0dTnKTWVpknauT3dH3SDglebvYppVpjNA76wBww=; b=jckNaXpg/H7IHW8XCAaulfYUXKY+qduZ9K+jKeZZ09RgQDD6NyMd3r9QlmolkCQ3nl 5aPbuRKzSTT0BiPdMc5PSzbdP4YfoQCpdS0xDyrRu8IRmjL8Zdv35/NYZk6MJ9R1LNkI ybPnsF6xDOzO1pzYqkze8HhX4zMyHII8yia0SGWsQ4ioectmg+GeY7dvYVAG/Jbje7Gy 1snL113S86QGmeCJ/TYk+gOfwPe+jyv52SwrLhctFIsQJUjHiuEJFT3EcjIlc127quXg qoUnq3kS0SwcSGNvDYtUiaZ2LrLNs0oBqzNwQvA/oHiVLIFIYn6+QAy9xcipdZ2sdfA0 hicA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788779980; x=1789384780; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Va4C0dTnKTWVpknauT3dH3SDglebvYppVpjNA76wBww=; b=AmH+jUdSiVVTB0KgL7CAe5NnpAtCONa/lz+teWH9tzMrZKO1CTZ8oKpIsp+lmp3yNq UEpsnwb/dal+DRkOHhCYywHN8LdIUKhXdhf0kEL3M7XGRSjBY33ckSSbg3tjPwZifYUS hwXMO678aQTqThD+Mrrmd2Z4JJvhqyfs7N5qK+5PTYFjMSiPSZb7N7HJG7d36R7Hg4ei J/5bA4btq0NMsI/8hr3vOmQ82k2wb52b2bH5WUX/uOsaxTWjsUPfbW7gwQSCCyQnAbhe T1HGyoBwd6DPmm95npyN/kVgmKd4IsW0Fayc+Y4zuL6cpGXhxFpAzJmuToMYaD4hONkX ZpGg== X-Gm-Message-State: AFuF++mbduRTp5PeJFkAEyiFd/bitoluTnQ8emFl1KZkHH5uhuVma3MC KSArhsQUij5MfHZ0szyXdFrbXdQZ8sRbL2fVKwXvzKP8UnolrCduGuF+FJXvTTeS X-Gm-Gg: AYBFou2FZJNj9MDFHUQnLJyG8MZrLrKG4NZr0kRby/zSD+F1squm++ysO3DfU57SOIS Su93r04S3lvdqrqFyBlIhX2e6ATFOUFDfFQrM5zTIDhRvk2IX4BTwEFrDBET9JkV3KsmmT7plWV i5U7obQmGqYd8ijzSf8D2MTcIeWLdpSLUrLjswFjcq4UJuHXqSYcBUCI7JsNsJYFgmsxhDoD8Ql Oe6hw7SJ+vyIE6KAVmgt6iGwYhxnRWNeqlz5i/QRD+ceRD4x5YwqTzeTnlBgs680CB+UV5uat1Q RdzXqGgekSi34ZWiLMueju4tvYaxnZg1MwUVriYPlMINLXOO36vWG6qDOfEUqC0IjF8607M6yCG gqfqiiScRfuMr9IMRIM6QEHJfNSS12b9/daXQrrYIGulBWX/7JsfjzOsivQThDqn5uKKfOCDLxk +K8PyhQWVpZGAMxtbDpi52Mo8myG+p+TZZ0erINu+5qkAcD0xdmoaQvMHv X-Received: by 2002:a05:6402:43c8:b0:6a3:8652:a373 with SMTP id 4fb4d7f45d1cf-6a7e8d4b44bmr7280680a12.3.1788779979375; Mon, 07 Sep 2026 04:19:39 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e6c20a41sm4200117a12.31.2026.09.07.04.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 04:19:38 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v3 1/6] ports/linux/guts: Add open_tree wrapper Date: Mon, 7 Sep 2026 14:18:38 +0300 Message-ID: <20260907111843.26746-2-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907111843.26746-1-frezidok1@gmail.com> References: <20260907111843.26746-1-frezidok1@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 07 Sep 2026 11:19:50 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4742 From: Dmitry Sakhonchik [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 --- 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 */ From patchwork Mon Sep 7 11:18:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97505 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FD97C79F89 for ; Mon, 7 Sep 2026 11:19:50 +0000 (UTC) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.32734.1788779988072933783 for ; Mon, 07 Sep 2026 04:19:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=eaR5PdZs; spf=pass (domain: gmail.com, ip: 209.85.208.49, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-6a82c103580so419215a12.0 for ; Mon, 07 Sep 2026 04:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788779986; x=1789384786; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bUI0zKjnqjI+sec4GtFQHNNYI3Dnad07oz3NpR89usg=; b=eaR5PdZs/w5oTbYyQ0abS8sIymhasvq2Sdk2JDhAhMl7cWuZ5l8DYpJuR8G9FBrSpX cRdZ/j1Of0oVWMGwjClLOUxdypoUScTCLTUeSWhND/ZTNZJBm/b6BF79fUq2migsEweT aodZqZ5eEAX/dvXsLzFGmEkADIqXE9MqVaBaQxGRa7eF4Z92g9wOSlLkP17V3xYyWTS3 9tVd6y+J9pSutacirYTSzYyAnkLZ3NPGXQjG4LfagpPYPSMOf1fYrEA3Qk9FSRWPAPjB qfh8SRvwehcD4kMCHq7qkUzEVuUBhQrMJ4ZLgrXtO1z1V4VMzrl9QWI2hGu/nRPgSu3L dhpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788779986; x=1789384786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bUI0zKjnqjI+sec4GtFQHNNYI3Dnad07oz3NpR89usg=; b=Ow562+gAwsqP8v9YEklyV/8mQbUV27rNqAzp93IKYMK3QIVzgMEhqICLXTjFpZ06V+ MxrFHRz4gcgXXMLYEQCIfczHZEnqgpK3nApdq7W44PbDWceoGzbml2pKiq+WlnrNRC3d KAyWApREFAMNMy1f1cvFKMomYVhwqbwKXbgoSCXKppbvLw3K8Fxl4L/duwupdG78Q+Pq HW3wwTe0CmNsiSZiKTqTB1YLc2ZwFjEZteYC1VjPsevT8pAeaE+B45thoj4jv2GtSfHD RZMS8AMibivIacHiMjz6tKs/HUT/cxkiKzP/BLKITjNp+e5EAJEc1mBM8e7FjtXbWEDR YoeQ== X-Gm-Message-State: AFuF++mnz3v3s/wREFjX26rLZDze9enqia2kiEgJ/g4i+lGnxJ1TlpMv tWxnKTAgchduR/x4fkaX4k6j3H/D69KUV7vg+8GhGRFBpXTRPOzqPHmcP9RGBDPy X-Gm-Gg: AYBFou3G8eEWmZxY/WcL/NHVBXeAhGRGDYVk4RpBoQFMfTva2VlXyIzPNBiFAmA8zRm DIIxn8imAszZZEDD7YtuO2t83Iiq670Rn9/CHjw0bPC/kqh/cGx8LsB22uajiw1bLDY0gfhOoIj kszCi+Jwfmh6bsp8J4ANzY5QAPGyWtqxGYclzjJufVETh9rhoiPli8y7/Th4mKvlYpt1LmebbWx z2yDVu1/Tanrazi2bFCVKSC2lqiblIMXva1dOT/dbCrCTCRVKjRIHUAIawiqdoFbNxF6w9/9xxO JXjvyur62rX20f3JZXtOnif8kD8cTECdIminpmJG4vjr3/jcwdofcR6/uJ5ci4uMOgIXXZpyss4 rXXQRETECrfDBHDiUywkU1OePQ/SMLV4es4CxQs3ZY8o4H92bOMy2fzI2veyEcPbNfqhThSzTLY xsYHep9jiLV1J63q5xzvnsONVerrzg2DSC1TWSKPGZ8ApaQCn8lmfcm9fLTg== X-Received: by 2002:a05:6402:42c6:b0:6a6:32fa:1e99 with SMTP id 4fb4d7f45d1cf-6a7e90b8f43mr8031778a12.17.1788779986006; Mon, 07 Sep 2026 04:19:46 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e6c20a41sm4200117a12.31.2026.09.07.04.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 04:19:45 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v3 2/6] test: Add open_tree test Date: Mon, 7 Sep 2026 14:18:39 +0300 Message-ID: <20260907111843.26746-3-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907111843.26746-1-frezidok1@gmail.com> References: <20260907111843.26746-1-frezidok1@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 07 Sep 2026 11:19:50 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4743 From: Dmitry Sakhonchik [YOCTO #16379] Covers basic open_tree wrapper functionality and the AT_EMPTY_PATH case. Signed-off-by: Dmitry Sakhonchik --- test/test-open_tree.c | 139 +++++++++++++++++++++++++++++++++++++++++ test/test-open_tree.sh | 5 ++ 2 files changed, 144 insertions(+) create mode 100644 test/test-open_tree.c create mode 100755 test/test-open_tree.sh diff --git a/test/test-open_tree.c b/test/test-open_tree.c new file mode 100644 index 0000000..0fc02f4 --- /dev/null +++ b/test/test-open_tree.c @@ -0,0 +1,139 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include + +#define TEST_DIR "test-open-tree-dir" +#define TEST_FILE "test-open-tree-file" + +static int test_no_flags(void) { + int treefd = -1; + int fd = -1; + int rc = 1; + + treefd = open_tree(AT_FDCWD, TEST_DIR, 0); + if (treefd == -1) { + perror("open_tree"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static int test_relative_dirfd(void) { + int basefd = -1; + int treefd = -1; + int fd = -1; + int rc = 1; + + basefd = open(".", O_PATH | O_DIRECTORY); + if (basefd < 0) { + perror("open"); + goto out; + } + + treefd = open_tree(basefd, TEST_DIR, 0); + if (treefd < 0) { + perror("open_tree"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (basefd != -1) { + close(basefd); + } + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static int test_at_empty_path(void) { + int treefd = -1; + int dirfd = -1; + int fd = -1; + int rc = 1; + + dirfd = open(TEST_DIR, O_PATH | O_DIRECTORY); + if (dirfd < 0) { + perror("open"); + goto out; + } + + treefd = open_tree(dirfd, "", AT_EMPTY_PATH); + if (treefd == -1) { + perror("open_tree"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (dirfd != -1) { + close(dirfd); + } + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static void cleanup(void) { + if (unlink(TEST_DIR "/" TEST_FILE) == -1 && errno != ENOENT) { + perror("unlink"); + } + if (rmdir(TEST_DIR) == -1 && errno != ENOENT) { + perror("rmdir"); + } +} + +int main(void) { + cleanup(); + + if (mkdir(TEST_DIR, 0777) == -1) { + perror("mkdir"); + return 1; + } + + int rc = test_no_flags() || test_at_empty_path() || test_relative_dirfd(); + + cleanup(); + + return rc; +} diff --git a/test/test-open_tree.sh b/test/test-open_tree.sh new file mode 100755 index 0000000..1654a0b --- /dev/null +++ b/test/test-open_tree.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test/test-open_tree + +PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree \ No newline at end of file From patchwork Mon Sep 7 11:18:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81576C79F99 for ; Mon, 7 Sep 2026 11:20:00 +0000 (UTC) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.32737.1788779996524586690 for ; Mon, 07 Sep 2026 04:19:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=kMZSZxjl; spf=pass (domain: gmail.com, ip: 209.85.208.49, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-69fab5a852cso4608163a12.0 for ; Mon, 07 Sep 2026 04:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788779995; x=1789384795; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TG29WNSeqf1QKp/iqetr53Xl7iDfOEoORGiiYI4rGaA=; b=kMZSZxjldXPESSQT2qUh4CI42LVm8YYCz96xoy0r2NS6/FytPn7hMLPxrLTpSFJqz1 P+NWQEYCE65Xyir7k6RwmdNgU81LkWCLAD4cH4sr02JU9bY5tY/jyUifXNo44mM8sd4R PkJSVb5TO9eAK41bSYH7RhJRd7lcf66KZn0iQGVE5c7OPoVJ3PYcDM6t7fU4/3dhgCvG 4P/YQ0Hl4qq9P8V4kYRVpYXZERna/yHSmSo/1RwxfWOhd9uitawd+fXartqNytuBQ+yz gfRWah5rsi38GQA0pqDjZAQr3L9boBdHX9BKzBviLz6DDBjBayktURz5qobwgEnpgjtt k0ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788779995; x=1789384795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TG29WNSeqf1QKp/iqetr53Xl7iDfOEoORGiiYI4rGaA=; b=ATYGVak2bvVYDKbp6yLHFpE0qSnlakRirI/mkVsApieUbLv4JE4aoCdCdxGsfWg3aN 0QWIK3wNwB/MfNa3/TpqYZTdRyxSltV7pe1CIrawnRbEyy3kDCIlWJ+jcgWLlAxb+ZvN uWbqGCxsGiyz6LZrIAtLwO8F906YpDmRKqrLUM5xws8/oANIn4nqtLoryi6lP4M31FmS dN2Sj7sRietyEEEozNvIZPnUtGF0/ocjAYZS3a51v4e6ejZ/yljnJZ7sLMaS9YoUIdyM WtuP/cSpvqv34NRiFG6CzaJbtx53Wmwt7UuUgyuJEE/UD8fPu3eaUJpiXdDV7waBZ76/ x23w== X-Gm-Message-State: AFuF++ndwFXG3Mgu6a5DwLFGQ40909XxX1rqkAiDSQnlsPysVi+OGtfB 9k/YwmnLbxAQjMtXHic/pejiACdaFajDlLcDgBrlPTQ5cLXuPpCNNJDLAsXfkeLP X-Gm-Gg: AYBFou1fs75YTw0DQ4otXCu6fhtakncfRVXHGv0IhnAMvvTy1VDQ2skBhVd8nu4VNgJ /pMBYaWbDXWQOX9XQm5yoAW71hbg79idE4olOeyLGWH0TOcElMI0oAQkl/4ijAf0Cy1FnZEOFJa mz/Aujxlx4ZqRlm9hHmY8m/jtmXjj7ecr2h4g6Bq3FPf/vuvTrmd/OJBxlNG4oJJfTBWqYa9kFz 9TK762ZFG8M4emXl+Qw6mpmmhOI08RYUhUpILYfB8hoGBGNdNCUYhHTxOfsa5EaaPMWHH+Cq0A0 6lMUoSg+slOzP2EenBiDzyykenwawXNOpvtJtyFydTv1K/H8Z1hgTKWzAeLEAtPd5a34eTRY8G8 KNOh/Zgffb64QVv3hycdNI4glcc141BsqgoMHbrkGMMrslZTgcPHQVrTz431asEopTTCUz/CScp nMtAh83KCFIckTKQ3ovzKOV6CGpCCoTDc80ikn2PITOBXA22MR6Z690MhF X-Received: by 2002:a05:6402:2b88:b0:6a6:306c:cceb with SMTP id 4fb4d7f45d1cf-6a7e8d8df90mr7634812a12.12.1788779994546; Mon, 07 Sep 2026 04:19:54 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e6c20a41sm4200117a12.31.2026.09.07.04.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 04:19:53 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v3 3/6] ports/linux/pseudo_wrappers.c: Add syscall support for open_tree() wrapper Date: Mon, 7 Sep 2026 14:18:40 +0300 Message-ID: <20260907111843.26746-4-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907111843.26746-1-frezidok1@gmail.com> References: <20260907111843.26746-1-frezidok1@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 07 Sep 2026 11:20:00 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4744 From: Dmitry Sakhonchik [YOCTO #16379] Signed-off-by: Dmitry Sakhonchik --- ports/linux/pseudo_wrappers.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ports/linux/pseudo_wrappers.c b/ports/linux/pseudo_wrappers.c index b920cb2..33cba2d 100644 --- a/ports/linux/pseudo_wrappers.c +++ b/ports/linux/pseudo_wrappers.c @@ -102,6 +102,20 @@ syscall(long number, ...) { #error SYS_openat2 not defined #endif +#ifdef SYS_open_tree + if (number == SYS_open_tree) { + pseudo_debug(PDBGF_SYSCALL, "syscall, faking open_tree.\n"); + va_start(ap, number); + int dirfd = va_arg(ap, int); + const char *path = va_arg(ap, const char*); + unsigned int flags = va_arg(ap, unsigned int); + + return wrap_open_tree(dirfd, path, flags); + } +#else +#error SYS_open_tree not defined +#endif + #ifdef SYS_renameat2 /* Call out wrapper, expanding the variable arguments first */ if (number == SYS_renameat2) { From patchwork Mon Sep 7 11:18:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85C89C79F89 for ; Mon, 7 Sep 2026 11:20:10 +0000 (UTC) Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.32744.1788780007427823607 for ; Mon, 07 Sep 2026 04:20:07 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=aANSS6wx; spf=pass (domain: gmail.com, ip: 209.85.208.53, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-69fab5a852cso4608395a12.0 for ; Mon, 07 Sep 2026 04:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788780006; x=1789384806; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=U51Km27bUin8I6yWA7uWIhFWDB6EZm7iysxiw2UI+Mg=; b=aANSS6wxRVfWLT3KUD9ja02EQuC6YVe9zvOVKLTgUG2J7pwBSjZuCuvSHtNOXex9OW FYvs6yloTabffG9TcgmNp5V9iKb0DDcZbRzu5YWQO4BxvJAH5f+jz56dA2fThpKu2iEH 1BFzuBta+Y7bXCpyktAK4Bh5Ax/RUNiwxfIgtOLFrl93wlNU1tmZWa6chg0IFrSc5Jv4 hOEveMVnO/AEEtdn8DhPI075uV3Fbp581q3PCSkLCVHOxzSmyD7s1EV4cAaGXBErIF6x inwIdzQBenhuu/UqXcdTXSPiIUKey/02Qhv2D2sf5Vz/7LMyZwZyoeTacdIcmy8XUzWd mqcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788780006; x=1789384806; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=U51Km27bUin8I6yWA7uWIhFWDB6EZm7iysxiw2UI+Mg=; b=Ogu0voX+5kNbaSK6jGP5w4DDMNcRtuCJUt0Ri2JA2w3iKoidZRZve9kwbZYsRhtcTX fyP81wE9CK+esserWzqNpFIKetDbB2rhK+KLCnueVXnF6Kre2sX+3ho9LVIR+ZJQ15a1 5XEhZ5Mk3gpSESRkIWVQSZDca4fbb+X3kk/BrD15r7swTduWbexs/qwIXVEnm2Ifyehh ZwtCyYNf+TdWEnnDfM2aBRYweq+y0o6qoNomQvEGa0PrCVQoWUTIEcq8yVNMTQXN9GTS z0FGQUiuQO1ObYCa4jeTAGnmfklOOGcZW6qNVDWKG+YrJsSq3q9gz5VHbbPW1W4kijC+ WHmA== X-Gm-Message-State: AFuF++mBhFwS57iAKKq00TSm/vEootRr5YVYcNrXJDrTRpeUIGd7dNd5 FLs/NcJjhh6bSHYV8b+K7FOlp+kOutWPF2lax98OoDzBww4tiMhT/6yOARq2A9Qd X-Gm-Gg: AYBFou3uxgAMiNQ6WURuT/Lbeh+rwslXNeSTPuK7YzHg81/k5pMac35yHzSkXH2760a Rc5fY37zqIyWzKdyqwY8u/77n8kAvQHQT6xCslEclHGBwkRKXsqarSi6ZEolHZH9vUXjGUAukbj xzZshkAYqrNwPYbpIap42hGeGTQ6E4j2LbiTa3uPFRfF84GJedFSbSeNhga2qlVCaMJt+3ycNft /cBUPfS4ylfw5m540IXIgAsM4X6DUyd7PGjcC5kwGkIwq4s0a6KMXKXsOzXi0ivOOibdhkQBRNS 60GEGf8qgpdw49UoLnjdZ/qicjl9UkesqvEMUx8qzv20WutsE53UTe/UfuZbSlF2T8KbuReV/jK hgZRcU1e9LHrmtnySgZw7vQ05igM2xktix2L2N6WhYspBJ6DeQtSnqKjwfDHmMdHk5nzJICBEol l4NGcpcIMICpi9IZJQsuWhUAk8b5fAK5TeULgQAmEjBX/DwmHe9A9OTFJZ X-Received: by 2002:a05:6402:4348:b0:6a7:e5e3:35a7 with SMTP id 4fb4d7f45d1cf-6a7e8e92bffmr7061317a12.18.1788780005404; Mon, 07 Sep 2026 04:20:05 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e6c20a41sm4200117a12.31.2026.09.07.04.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 04:20:04 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v3 4/6] test: Add open_tree syscall test Date: Mon, 7 Sep 2026 14:18:41 +0300 Message-ID: <20260907111843.26746-5-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907111843.26746-1-frezidok1@gmail.com> References: <20260907111843.26746-1-frezidok1@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 07 Sep 2026 11:20:10 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4745 From: Dmitry Sakhonchik [YOCTO #16379] Covers basic wrapper functionality when using syscall(SYS_open_tree, ...), also tests AT_EMPTY_PATH flag and related paths using dirfd != AT_FDCWD. Signed-off-by: Dmitry Sakhonchik --- test/test-open_tree-syscall.c | 152 +++++++++++++++++++++++++++++++++ test/test-open_tree-syscall.sh | 5 ++ 2 files changed, 157 insertions(+) create mode 100644 test/test-open_tree-syscall.c create mode 100755 test/test-open_tree-syscall.sh diff --git a/test/test-open_tree-syscall.c b/test/test-open_tree-syscall.c new file mode 100644 index 0000000..03f5618 --- /dev/null +++ b/test/test-open_tree-syscall.c @@ -0,0 +1,152 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include + +#define TEST_DIR "test-open-tree-dir" +#define TEST_FILE "test-open-tree-file" + +static int do_open_tree_syscall(int dirfd, const char *path, + unsigned int flags) +{ +#ifdef SYS_open_tree + return syscall(SYS_open_tree, dirfd, path, flags); +#elif defined(__NR_open_tree) + return syscall(__NR_open_tree, dirfd, path, flags); +#else + errno = ENOSYS; + return -1; +#endif +} + +static int test_no_flags(void) { + int treefd = -1; + int fd = -1; + int rc = 1; + + treefd = do_open_tree_syscall(AT_FDCWD, TEST_DIR, 0); + if (treefd == -1) { + perror("open_tree"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static int test_relative_dirfd(void) { + int basefd = -1; + int treefd = -1; + int fd = -1; + int rc = 1; + + basefd = open(".", O_PATH | O_DIRECTORY); + if (basefd < 0) { + perror("open"); + goto out; + } + + treefd = do_open_tree_syscall(basefd, TEST_DIR, 0); + if (treefd < 0) { + perror("open_tree"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; + out: + if (basefd != -1) { + close(basefd); + } + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static int test_at_empty_path(void) { + int treefd = -1; + int dirfd = -1; + int fd = -1; + int rc = 1; + + dirfd = open(TEST_DIR, O_PATH | O_DIRECTORY); + if (dirfd < 0) { + perror("open"); + goto out; + } + + treefd = do_open_tree_syscall(dirfd, "", AT_EMPTY_PATH); + if (treefd == -1) { + perror("open_tree"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (dirfd != -1) { + close(dirfd); + } + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static void cleanup(void) { + if (unlink(TEST_DIR "/" TEST_FILE) == -1 && errno != ENOENT) { + perror("unlink"); + } + if (rmdir(TEST_DIR) == -1 && errno != ENOENT) { + perror("rmdir"); + } +} + +int main(void) { + cleanup(); + + if (mkdir(TEST_DIR, 0777) == -1) { + perror("mkdir"); + return 1; + } + + int rc = test_no_flags() || test_at_empty_path() || test_relative_dirfd(); + + cleanup(); + + return rc; +} diff --git a/test/test-open_tree-syscall.sh b/test/test-open_tree-syscall.sh new file mode 100755 index 0000000..3cb4d96 --- /dev/null +++ b/test/test-open_tree-syscall.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test/test-open_tree-syscall + +PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree-syscall \ No newline at end of file From patchwork Mon Sep 7 11:18:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82C78C79F99 for ; Mon, 7 Sep 2026 11:20:20 +0000 (UTC) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.32750.1788780011662969205 for ; Mon, 07 Sep 2026 04:20:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=rB2tFva9; spf=pass (domain: gmail.com, ip: 209.85.208.52, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-6a5e329c0f2so3784735a12.3 for ; Mon, 07 Sep 2026 04:20:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788780010; x=1789384810; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JEnnJkz2WMy/oXHPCNRiSqRYRh/TZttmJDfojt2QGZ8=; b=rB2tFva9tjEFGeW0jUJ3Bs/nFd6nlWlNhOgehKYOug9yl4Su1JmQ3qbSGoYAb7i/zJ V9xiAAF6MOAHyzJ9JYEceP50RgIG+yG1Disdu7uiQj8j4+5aaKVGT72rQOYX619DClQP 3LYyAOky1fNpwBuQ999LaE3Hmd2oc8u4BizfR0w8hQTVtnActBrcoDdQMnxY3xpbaKdq 1UhocYA7jjY6xV6cwmf5zyoNXpASOs8x5vFXJLi2nQ6S50cQn6wLXLpWlmDsmYdJovRM CF+zPNrEH1/CdG80TF/5L/iyzP0tOpkHgN3cKvpZfYrlcenguygD0EDUCrWx5vPU+5qo a17g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788780010; x=1789384810; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JEnnJkz2WMy/oXHPCNRiSqRYRh/TZttmJDfojt2QGZ8=; b=FJdlCsV04E4VkxHsEbVNuFIVUvzGqaXoz/R/IUYnR2vGedKIbi8R/9TlxRaVSKFnpW fzoXbdcmpjIsZqr5uB9LerCKPZ2WATHwh5q7ZBfLg7q+HSijechEYBbUvtK5gb5YgOKc XUv+NneIjDPo0SW0Xwxjc/5h3o4YQHM8S+jN6Vt1Jdkqs3+U5GgK8JSFgKIZTXscvMxe 4e3ruk5ZN/VEx/xExYM3DQMY2TYBYGr9clE3+YtuSfBHW5LtyA+4qHU+PT4h2MKaza4B AgVIS2/ecJPq73Ca1b9eqadv+ENqZvUED+pg2w1lJs4NdUnYx0oZBtET6UBKqG5vzCX3 plMg== X-Gm-Message-State: AFuF++m7xsUTr47LG6/8Egz/sNObhyYC53IZnp2yeTThVz0o94TE63Ic T+S7xoTKDi8AdNlnN8tYTEvUn//CkprdopSt7svhUGqTsaTSv2nM4ecHj6wsnWkt X-Gm-Gg: AYBFou1H0OeJCmmlPIQyY1tjWbcAsECMrPjx0dH8HSc3i/f5P2I9O/avMhZ7fpIZ8hl kbvm3+eD9OfKAtvUzzAHByv8/2BYXVlr+eOaIUahGaWOVwx1Xf9xJ0XIzpKkiZAx7WMYR6TKuTM u9mpEC73xn2I4+KjuOaII2hirrhXT7o6RXsTaohUIy+BC2Ex972gt3V7n/+gvb8Hzo87c5e46UM bmduOi1iyfkE0gAX0j9UqCcZ2vqVQTqAbG2RqU7kWOvtMRvktMF3ZqRSkXxoYr1BwvZufb6b80q atF1vD6b8+XPxJHVaotgxPwMTNbMGR80uZJAqkzU1lAVhBxvvBjeZ/0dN8Clki6+lYU/sLUcE07 CoyUwEiYJS+7r/K/xZBRFaLDYhWGL2RWGm304eXSXswIvSgrm6k4q64WlcJUyCfiRZY6NU/8aNO l9vepy3fqik+GYS0TD0xny8WT9qau4YJdNnW0dE8ykcz5QVBmCVdTzzErs X-Received: by 2002:a05:6402:2110:b0:6a7:ea53:f61e with SMTP id 4fb4d7f45d1cf-6a812fbf245mr2702259a12.29.1788780009629; Mon, 07 Sep 2026 04:20:09 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e6c20a41sm4200117a12.31.2026.09.07.04.20.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 04:20:09 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v3 5/6] test: Add open_tree_attr syscall test Date: Mon, 7 Sep 2026 14:18:42 +0300 Message-ID: <20260907111843.26746-6-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907111843.26746-1-frezidok1@gmail.com> References: <20260907111843.26746-1-frezidok1@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 07 Sep 2026 11:20:20 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4746 From: Dmitry Sakhonchik [YOCTO #16379] Covers basic wrapper functionality when using syscall(SYS_open_tree_attr, ...), also tests AT_EMPTY_PATH flag and related paths using dirfd != AT_FDCWD. The test uses attr == NULL, because using mount_attr in this call starts mount-specific privilege checks which end up with EPERM. Signed-off-by: Dmitry Sakhonchik --- test/test-open_tree_attr-syscall.c | 165 ++++++++++++++++++++++++++++ test/test-open_tree_attr-syscall.sh | 5 + 2 files changed, 170 insertions(+) create mode 100644 test/test-open_tree_attr-syscall.c create mode 100755 test/test-open_tree_attr-syscall.sh diff --git a/test/test-open_tree_attr-syscall.c b/test/test-open_tree_attr-syscall.c new file mode 100644 index 0000000..4b656cb --- /dev/null +++ b/test/test-open_tree_attr-syscall.c @@ -0,0 +1,165 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +#ifndef SYS_open_tree_attr + +#ifndef __NR_open_tree_attr +#define __NR_open_tree_attr 467 +#endif + +#define SYS_open_tree_attr __NR_open_tree_attr +#endif + +#define TEST_DIR "test-open-tree-dir" +#define TEST_FILE "test-open-tree-file" + +static int do_open_tree_attr_syscall(int dirfd, const char *path, + unsigned int flags) +{ + /* Using mount_attr in this call starts mount-specific privilege checks + * which end up with EPERM. + * The functionality when using attr == NULL is equivalent to open_tree() */ +#ifdef SYS_open_tree_attr + return syscall(SYS_open_tree_attr, dirfd, path, flags, NULL, 0); +#elif defined(__NR_open_tree_attr) + return syscall(__NR_open_tree_attr, dirfd, path, flags, NULL, 0); +#else + errno = ENOSYS; + return -1; +#endif +} + +static int test_no_flags(void) { + int treefd = -1; + int fd = -1; + int rc = 1; + + treefd = do_open_tree_attr_syscall(AT_FDCWD, TEST_DIR, 0); + if (treefd == -1) { + perror("open_tree_attr"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static int test_relative_dirfd(void) { + int basefd = -1; + int treefd = -1; + int fd = -1; + int rc = 1; + + basefd = open(".", O_PATH | O_DIRECTORY); + if (basefd < 0) { + perror("open"); + goto out; + } + + treefd = do_open_tree_attr_syscall(basefd, TEST_DIR, 0); + if (treefd < 0) { + perror("open_tree_attr"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; + out: + if (basefd != -1) { + close(basefd); + } + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static int test_at_empty_path(void) { + int treefd = -1; + int dirfd = -1; + int fd = -1; + int rc = 1; + + dirfd = open(TEST_DIR, O_PATH | O_DIRECTORY); + if (dirfd < 0) { + perror("open"); + goto out; + } + + treefd = do_open_tree_attr_syscall(dirfd, "", AT_EMPTY_PATH); + if (treefd == -1) { + perror("open_tree_attr"); + goto out; + } + + fd = openat(treefd, TEST_FILE, O_CREAT | O_RDWR, 0666); + if (fd < 0) { + perror("openat"); + goto out; + } + + rc = 0; +out: + if (dirfd != -1) { + close(dirfd); + } + if (treefd != -1) { + close(treefd); + } + if (fd != -1) { + close(fd); + } + return rc; +} + +static void cleanup(void) { + if (unlink(TEST_DIR "/" TEST_FILE) == -1 && errno != ENOENT) { + perror("unlink"); + } + if (rmdir(TEST_DIR) == -1 && errno != ENOENT) { + perror("rmdir"); + } +} + +int main(void) { + cleanup(); + + if (mkdir(TEST_DIR, 0777) == -1) { + perror("mkdir"); + return 1; + } + + int rc = test_no_flags() || test_at_empty_path() || test_relative_dirfd(); + + cleanup(); + + return rc; +} diff --git a/test/test-open_tree_attr-syscall.sh b/test/test-open_tree_attr-syscall.sh new file mode 100755 index 0000000..3e50ebe --- /dev/null +++ b/test/test-open_tree_attr-syscall.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +./test/test-open_tree_attr-syscall + +PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree_attr-syscall From patchwork Mon Sep 7 11:18:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97509 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8442EC79F99 for ; Mon, 7 Sep 2026 11:20:30 +0000 (UTC) Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.32494.1788780024825040739 for ; Mon, 07 Sep 2026 04:20:25 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=ZLTSKRS2; spf=pass (domain: gmail.com, ip: 209.85.208.50, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-6a5ebf75d62so4935214a12.1 for ; Mon, 07 Sep 2026 04:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788780023; x=1789384823; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TpAn+ev0mjriQBZovNit/5c7iNwzyPq7sx+AX/5IpUs=; b=ZLTSKRS2faP6p9X0p7Tg3xj0FnRjLC2EDAoCjE5SJLyY1fAyXkCVLhCPvj9vueXpfG ACKVDlNwtJD7CSH5ijQ4Kq6BK8PcDNulH7KxTixc1H/tTLHAfn8pCKdSp7rhk/zWwKca bLeaPYDIbW8SMVrlCIT9D8AjoHJnGl/nAVgJ8kQTcWo6KAmVINTYfFpBwWeSlpk88jan THowNQm+Q/9bGfBdNPLlo+6we5YLKG65EUqP7RMrpBsGjGbBMQriLHXRNJbnh/X5g8lf uT7LqvJU2HiPM6jpkAnWnLsH7G3LRtHr9nxVlezq8Ar9MTLal1qxQBipGEVPtT+TCeEt 4QBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788780023; x=1789384823; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TpAn+ev0mjriQBZovNit/5c7iNwzyPq7sx+AX/5IpUs=; b=CSetjcayNNYcHlfGHMzrcz7tC1vLTk0eQCLJjiTu5ebNmhJknwxFz6SBgeGTR8Usg6 M1WBIvC8RvuTfmHiVanSsiPH1N4psWdOUVqsx8E3WdD66+aOhbNy1jpT094JaPwsIFPp jzXgnlrLSsBF/pRRyr8cgyfJZPZXzbALjDDcK3Z3z7GEmaT3Uorbm6d1SiC3p8PNPcCd RG6WrUd2cmzCHLCMdxWwL8f9dpJ7M2Cid2jyXD1fiT+F0T/db5H6vKBP9Pm4BDzazR6C N+pWV0G3KQkuIhJsnZxolJW4mvw4dX8q8BFi+M/5fXSY1QWl4A70Z3yoXAm03B4RA6M5 MIGw== X-Gm-Message-State: AFuF++n8rWh+brtX2L3mg+o0vircwtLhxuf5skbaHAKAk6+NGaG0LuO8 w97iO/gW2qxBVzbxEGWHW3KoLigZSiD3VEWKXg2P4BEx7+upAyheKPXWAapuTp9Y X-Gm-Gg: AYBFou3XSuuHEUFZSNVRzuu4sg95M/NqI+JgKYnTF0tV933qxMCNmoggbix4ffQBR57 1n8p3GwGRrJHoepX4r/1umJfJSYUnHE/j4Y6z3NxOv+diOlyIWlCAbFbkM19cDzFB5PLSJHEsSm BeCX1J6xHyGmSAcJz2DtDeXLgpQ0QrlZ82QNF1K0dNc7aCjNaxwiecTpsDalR3eeFYG4YGwKIPu SnyXrxrwfmLIDOZZgsufN6XhwdvvqbF0kbkZ6Cs/jUYqXSb92wZXUQlUi8LlrHslIOe+VZLfZSq LBtQxIh0PRzpxEeWQXO2Du4rmraP0OTM+OXNwRJu0MomVn0csmO6ULPr10Rii6TimahCEt43N7I UKp/R3PU5QLEk9NBnxLz6ZRoeSE+h5JOycAKxd0Sa4wVfik46BPnATR52sZ/OYoY0dQN6k47SsU MZ3Q1OxPbUKz9oavQgB9QtVLrO2YLdei4as9kNeZ0/VL5oLDpeS95aV6DerzfoJSLbwy0= X-Received: by 2002:aa7:c75a:0:b0:6a6:75b7:4ff6 with SMTP id 4fb4d7f45d1cf-6a696a84013mr7036587a12.8.1788780022749; Mon, 07 Sep 2026 04:20:22 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e6c20a41sm4200117a12.31.2026.09.07.04.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2026 04:20:22 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v3 6/6] ports/linux/guts: Add open_tree_attr wrapper Date: Mon, 7 Sep 2026 14:18:43 +0300 Message-ID: <20260907111843.26746-7-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260907111843.26746-1-frezidok1@gmail.com> References: <20260907111843.26746-1-frezidok1@gmail.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Mon, 07 Sep 2026 11:20:30 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4747 From: Dmitry Sakhonchik [YOCTO #16379] It mostly mirrors open_tree, with the additional mount attribute arguments passed to the underlying syscall. Signed-off-by: Dmitry Sakhonchik --- ports/linux/guts/open_tree_attr.c | 48 +++++++++++++++++++++++++++++++ ports/linux/portdefs.h | 9 ++++++ ports/linux/pseudo_wrappers.c | 16 +++++++++++ ports/linux/wrapfuncs.in | 1 + pseudo_wrappers.c | 1 + 5 files changed, 75 insertions(+) create mode 100644 ports/linux/guts/open_tree_attr.c diff --git a/ports/linux/guts/open_tree_attr.c b/ports/linux/guts/open_tree_attr.c new file mode 100644 index 0000000..da0315c --- /dev/null +++ b/ports/linux/guts/open_tree_attr.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2026 Yocto Project + * guts/COPYRIGHT for information. + * + * SPDX-License-Identifier: LGPL-2.1-only + * + * int open_tree_attr(int dirfd, const char *path, unsigned int flags, struct mount_attr *attr, size_t size) + * int rc = -1; + */ + + /* Mostly based on open_tree wrapper */ + + struct stat64 buf; + int save_errno; + char *pseudo_path; + + if (real_open_tree_attr) { + pseudo_debug(PDBGF_SYSCALL, "open_tree_attr, calling open_tree_attr.\n"); + rc = real_open_tree_attr(dirfd, path, flags, attr, size); + } else { + pseudo_debug(PDBGF_SYSCALL, "open_tree_attr, calling syscall.\n"); + rc = real_syscall(SYS_open_tree_attr, dirfd, path, flags, attr, size); + } + + 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_attr(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_attr(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 565fed9..af8b8e8 100644 --- a/ports/linux/portdefs.h +++ b/ports/linux/portdefs.h @@ -91,3 +91,12 @@ extern int unshare(int flags); #define SYS_open_tree __NR_open_tree #endif + +#ifndef SYS_open_tree_attr + +#ifndef __NR_open_tree_attr +#define __NR_open_tree_attr 467 +#endif + +#define SYS_open_tree_attr __NR_open_tree_attr +#endif diff --git a/ports/linux/pseudo_wrappers.c b/ports/linux/pseudo_wrappers.c index 33cba2d..4141556 100644 --- a/ports/linux/pseudo_wrappers.c +++ b/ports/linux/pseudo_wrappers.c @@ -116,6 +116,22 @@ syscall(long number, ...) { #error SYS_open_tree not defined #endif +#ifdef SYS_open_tree_attr + if (number == SYS_open_tree_attr) { + pseudo_debug(PDBGF_SYSCALL, "syscall, faking open_tree_attr.\n"); + va_start(ap, number); + int dirfd = va_arg(ap, int); + const char *path = va_arg(ap, const char*); + unsigned int flags = va_arg(ap, unsigned int); + struct mount_attr *attr = va_arg(ap, struct mount_attr*); + size_t size = va_arg(ap, size_t); + + return wrap_open_tree_attr(dirfd, path, flags, attr, size); + } +#else +#error SYS_open_tree_attr not defined +#endif + #ifdef SYS_renameat2 /* Call out wrapper, expanding the variable arguments first */ if (number == SYS_renameat2) { diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in index a51e9a0..639d9a5 100644 --- a/ports/linux/wrapfuncs.in +++ b/ports/linux/wrapfuncs.in @@ -11,6 +11,7 @@ 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 open_tree_attr(int dirfd, const char *path, unsigned int flags, struct mount_attr *attr, size_t size); /* 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 */ diff --git a/pseudo_wrappers.c b/pseudo_wrappers.c index 112239b..78cdecf 100644 --- a/pseudo_wrappers.c +++ b/pseudo_wrappers.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef PSEUDO_PORT_LINUX_STATVFS #include #endif