From patchwork Fri Sep 4 13:06:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97304 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 42846C624D3 for ; Fri, 4 Sep 2026 13:07:27 +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.msgproc01-g2.13452.1788527245801799087 for ; Fri, 04 Sep 2026 06:07:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=BTjE+rd+; 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-6a173ad7cf4so1517119a12.3 for ; Fri, 04 Sep 2026 06:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788527244; x=1789132044; 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=BTjE+rd+lbW0+IDDUylO5vJgtWHPCziBcG5QN5vxaInWbCTOJeKIS4R86xObOLsIBb r7hPk+w10IlgqpFoAhcQ1g/4vhxIWZU4BZYZYW2bFczhdRCX9bw3hReIiubX+ONmQFCc JxWMenMQwR1CsVVsAWaM7/YrfROnvst0YPHIC5ADYtKQbCdXdE5TWT6HF2S6a97HOsKQ pxor2y2qo2TO08sSQ9FeHaB6YNOO8bdem9DkIvwRan/8GuEfvJTYqFP6EsHu2Hhjv6Pk c8+mTCOC5mItnXadTXMeWGEBdRHfdaEEHodjy7b050bwVjCISWUoOLjZJCF/KWPOBiFe bGTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788527244; x=1789132044; 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=F076wirhWbAPKaXYyPt+HmOj/REefU6eNF+yu0xHHdULTxugFIrcXzNFZUYAMgYL2G yu3J91jiBEFdRcWTDmfKRtnVCtx5pMg0ObBb4nL+GuZwUA0sPApvGezU0OxZ8bahMTO2 a4KESO9kEZfs+HQTyq71+fBaw+LblXAFq8stVxX61AwNfhtEKBJsiJcvI5opAxH3pK0+ hj9s46ovOGBT++qyacBkNUj82QaA56r5OumnRCUqn7ndHra7m9ncoAcalAvUTNoCCyqw SUWF8JKXHFuO1bj456FS5Vk1yPdrGV90EDSmj8fnCG19GSgO3kwfkRvt9qPyPMcY3hW7 /PMg== X-Gm-Message-State: AFuF++lULSj732xFTwnu5YXVqqoIqi1jneWw9FIcs3kxQpkpFhmYdPic rDm4HeyUFUgJNWTeorA3GnDot3WGN+0Ih0IgI4BuHMtXOMJitaiwS9paeu5x692G X-Gm-Gg: AYBFou1LIAf9N0jkkqV4tbGbELooYdPZYMLE3TPgW+x1wr+Ubo5Q/mEX2rVbr5sTpl0 lwSJm8bOKxUkBHFQ3UPbHWrynqb3T9cNXHI3SZIJmJtBmn16e7enUvA/tgqNfzO27HVJPlIdzfA 38Kl+9o3dVeU6hLp2hsSWG3EKb50UK+dfdRB1uSGsAJVxxhpzYLVizGkSDJ2M4bKCsRF6hD8FUu /DhqtN2lS7m5HG4PZxNPBHTt+eFghiUXosWyFPQ5n7TQQDNAMCilIOxGpiNQB16UYH8xiR6BQss qxvwRdaBRV93l+3fci3i1Deu4KCm8mRuNiELjjwjMPUcQrqKioB6Ul9jE9j6/tSrKy0m2rtAkVO aBRNLsLut79syOVcIO3u2lmaeKtk6Tmkb5/M90H8+BhrTslY0gqfQW/is9LGzpTPKTYri4YmIQF 8oSA8TlJPzeFSidBgZZ0pVW+D6ScAD+t6uaCg4aMjAKKr2z10NA53uU9Q= X-Received: by 2002:a05:6402:46cc:b0:6a6:1026:b0d6 with SMTP id 4fb4d7f45d1cf-6a7e8d54234mr1856593a12.4.1788527243696; Fri, 04 Sep 2026 06:07:23 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e68c3d88sm1173158a12.15.2026.09.04.06.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 06:07:22 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v2 1/4] ports/linux/guts: Add open_tree wrapper Date: Fri, 4 Sep 2026 16:06:24 +0300 Message-ID: <20260904130627.453678-2-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904130627.453678-1-frezidok1@gmail.com> References: <20260904130627.453678-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 ; Fri, 04 Sep 2026 13:07:27 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4729 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 Fri Sep 4 13:06:25 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97305 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 465FBC624D3 for ; Fri, 4 Sep 2026 13:07:37 +0000 (UTC) Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.13455.1788527253864695927 for ; Fri, 04 Sep 2026 06:07:34 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=CANSv0DF; spf=pass (domain: gmail.com, ip: 209.85.208.41, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-6a7f27637d6so434594a12.3 for ; Fri, 04 Sep 2026 06:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788527252; x=1789132052; 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=CANSv0DF1AnYkzGWaFyycx0aii/b8H8kOW6q90CozxTkOFe0+GzH8WlRNEDxRdBjl+ S+xr5QLFkiiSLUBGghiib/SCKBychVFt4C1MkGNrherjaySpLbKJXKjsLsB8Jjhy8Lzb P59cLTPZHaCxHv4hrPUFK4cpEtM2TCK+hq4XdNl7q/ViPuGxvzM1f9AXUATzMmrWpF/V G9z/gH88Wcck6SoJOqvqYm8xIzfal+tLlGQZUSG3vwquXMG7g2WdXfofbwWwzE6WlHqN coUWPDJDT6VBui1CI9WMR6NTZjf72gdDlgwHul0e2pNSPcUeljhL4x6GWLvElLkCjeuU v0bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788527252; x=1789132052; 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=dLXKRL1jx1YCJ2onvqj0D0hHa14ECGMuLn1ICAGVxv0Kl/5rHkZJt+63mIrKDdnuYW SPJ4zrP/Wg3TbnCFo01M9KYWU0qe242AwKGgV15kKyRPvdmywZHYksxtfMWPaouN5DMq osw4S4XgJaIY0pU+EFuNskhO+/rMmEh0TfLo+yIcR6MWT12e8HMkRzV8rHVBwbtHmT3F WoIPEgVC1myZPI2WKrTVcNscEeiKTmvK4NVmtYF9+WuPb1fTFaj8NYGNZENtzH2WCxmr yyvmXfXVBsnzbLDs0L4RHXA6/NNDW5U1R+UO0hfpG4FCMUeYEX3VIMouPcV1SlMys2T5 jxrg== X-Gm-Message-State: AFuF++n6ECQ6nC5jRN2ojBFbHSlj8W8N0hzTQEfQQZhQBcLJON8GN/Bq ZOY9UtLTem4kr4kXTqKibZNqhYuvLqpWdaE0BSdHgEwEmn/LSHEwW8JOMQcdmW/B X-Gm-Gg: AYBFou3POqV+Gg1txRXIOg0CjJ40dFwlQt3IhohhdAGsIDJbVuuKapIlSBGXg/qDI/2 M16h7UfNwwGItLSF56HjOlU2jdNezikTlfcM3RKlH/aPtGDnVwqJnDJHyFQ7Um/SGEVnKOszH19 bkTIOrSSJezQoByCSuyieyOu00kThARbkr10NPA1YO1UMdwPF5nUvaFo/+xjyfvLjQeFC3RWFeh u11C8Mxl2mg4f5BfVT5xkfDVxp/DyM4O2/9CixrGWakV13cNhqxbwGfECDhLmva4JqQY6XvZq47 TaiG5FeDTDMLV2t/nHAMGU+fYPYp3V/CMgpcb1fvC54fHXAk1Mg4YwrboICUS3r9jsoQqs2bJQ4 wbuisc6hr/f17kw9UnjiB/0hMVd+9Jv5J9tXFfDsO++i2qIKHf4YsKOdg2O6cgzG+pzlJ4/vR+B NOEXZoWKX3XV+9q8TKiU+BTMfzLOo9KD30clTDsknZcrX2RtGTmfY3LEw= X-Received: by 2002:a05:6402:3553:b0:6a6:32f5:90b3 with SMTP id 4fb4d7f45d1cf-6a7e8f9d860mr2878223a12.21.1788527251873; Fri, 04 Sep 2026 06:07:31 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e68c3d88sm1173158a12.15.2026.09.04.06.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 06:07:30 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v2 2/4] test: Add open_tree test Date: Fri, 4 Sep 2026 16:06:25 +0300 Message-ID: <20260904130627.453678-3-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904130627.453678-1-frezidok1@gmail.com> References: <20260904130627.453678-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 ; Fri, 04 Sep 2026 13:07:37 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4730 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 Fri Sep 4 13:06:26 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97306 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 429E9C61DD6 for ; Fri, 4 Sep 2026 13:07:47 +0000 (UTC) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.13458.1788527261214421021 for ; Fri, 04 Sep 2026 06:07:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=KLkLkk/J; spf=pass (domain: gmail.com, ip: 209.85.208.43, mailfrom: frezidok1@gmail.com) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-6a668ce86abso1499469a12.2 for ; Fri, 04 Sep 2026 06:07:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788527259; x=1789132059; 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=KLkLkk/JQAaRw3Q3y5bV9NteeiFlZNpYeGd50TN11WKmEvLpOQL29NNzbmhQz2QuUr Ho27PuBLRin9us1zNmASLnmfJ5fQ0WyoTHjDvHm8HvxVSQ4ycTAtPiOi8mS9851wzgEC uQNITkKiTmRWQyb9lCXNSizg7dP2p/0lVuCyOFtHevrtYlUisqYoHJzEqlb1gC3NOGTu Z97Loqmd1+R6dUtz8c29A1SRks3aNJVwnsaVh4UBPQDI1sRLj7Zc4jFYpjLMIoM0eMri L0nmVHK8roBjfYpdl8lL/QV2m5jihU8hjfrBUyododtLfvrCvKoTmS1994eFXYHkRHqw FHSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788527259; x=1789132059; 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=qCKO9WGpwBE/EmxOGpcE1BbYaNyh2GVhSy9PUeEZ9+tph2Janl3NTChPbCVSW3NkEn frCbeKGBCZu6Q4C6SbBsYf7uo73qs57eDFrU4wWbWgmxJLcWF15k+l21IvZEQ1lO6MwH uX5GYsRhPNxy7xQkJJPS+r6Vnp64Xr7SLiA3JUtzGxO6KdiiVlChiQaDYhCtj2MMWBSF ai6+gbKRVRTwgQV4jUqwMr1DlK6HeRuiQrNeW2uKA+/Dm8GhDjIHuSCBhuaSCAKGgwSX T7df4ZBn5xiHI2MqgNsbRFP6IB1enrZSucUlUPpvytYRWTLYgQGfThDxQA0L4Kex4yHv qtHQ== X-Gm-Message-State: AFuF++mZITlZXKlpY7Vm0g/KVm9a1kz8rhXotfdsJMMuDKKK2tOZYSU9 TZWCYrZb0BSzkkPM0N5oSMe1T9bOB+yFLZmYpa91m2DK2GI8AjSf9pf+WT7SyNMu X-Gm-Gg: AYBFou0Hod/3OXNPvq/Fb+UnEe9KX+A2LjEOklBNh3Uh65ruKeHsza+QPTv1QojSH1c Pw5CIDSo0kKrKsqp6hmHUNJ9lWU4VTWHstt2vBqeXVpiDsnmcb/QwdoSCzznsEefZQxMMmyjn1z elaeevcGwg5xTNqf70icfLZCkso+MBCtwRHx/PCY90fyY/z9wojPyqYz8uU9NBapeU6YF8PE+JJ R8FpGyS3/fegChysmDyU6VNu2AlNGol10b5Ola3JyFRgRMekUxRI8Kp/PPOBlc583o5Woofy2yG XzFg5SzRtYvmk5hRrrkE/Y/s7P2NAdBfycvCooiy3AY4UGhS8sCetPxzSGhJMp/wXH9yS4f2Sri AGEI3xfskjyqVC95tLV1mNrMU0eh4fTF5UM6SNd3MSP0vbzCfKbOwagiKyqhprjfxFmlNX8DiaN v2jdXRBiCHP7/0henxZkYN+M4GxLnE/jpMKJouCmqjXagxvKZ60MH4EHM= X-Received: by 2002:a05:6402:210c:b0:6a0:9776:cb5b with SMTP id 4fb4d7f45d1cf-6a7e8d987ebmr3075607a12.13.1788527259243; Fri, 04 Sep 2026 06:07:39 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e68c3d88sm1173158a12.15.2026.09.04.06.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 06:07:37 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v2 3/4] ports/linux/pseudo_wrappers.c: Add syscall support for open_tree() wrapper Date: Fri, 4 Sep 2026 16:06:26 +0300 Message-ID: <20260904130627.453678-4-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904130627.453678-1-frezidok1@gmail.com> References: <20260904130627.453678-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 ; Fri, 04 Sep 2026 13:07:47 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4731 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 Fri Sep 4 13:06:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 97307 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 47B3AC61DD6 for ; Fri, 4 Sep 2026 13:07:57 +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.msgproc01-g2.13468.1788527271255379954 for ; Fri, 04 Sep 2026 06:07:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=U2dZgNPO; 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-6a0c8283146so1432417a12.0 for ; Fri, 04 Sep 2026 06:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788527269; x=1789132069; 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=U2dZgNPO84jF+BOme0Ftr7GwhfRRSqN+Xg/gxd2kUB6CnNvIrfkBqdMtMUghAJhH7n pS7QhcY5q59ZjNXopVGrOjcF3w56A+L1lDGrENPWtRzu+gyvtUiSX3x1NukKOSgBZBuJ kRtjpMvLZ6gw6muNIF/9N8mD7lX/QVRfryt8/t5AdYKFwkmYGPKi5ozRkUz+lnuWbske swjkROP9ztsXbzeRs3T/4jQn6WvN7EHMo6p7LNMEnybtxO9Jfk/5bG5w5nXutWfTACRl tO4WbiZG63+2MM3WKNJdZ3uuEHpSv/kkWyXW3hiqqhocwoTzquNPJo0PneE3LVKvZH8m F0cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788527269; x=1789132069; 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=OBNW6/vfD8Y298tU+f3hMzaIVQrzntj2KbZdFl8rCsllQmEJp72l6eeTUixqaKh+dn 7tRrR+sMjDI2/oXrt+TTT4MT9H/JFKau5l+VyU49j+t6moWyITb1YVw5/s5bAO/zfieC na7MNDQcvzDRig61ciYX+Srb7ag7BvE2cLfdZg2v/gZPyVjOqLdX38dTIVE+FfwOLO3N sEoHWNFfHCVbrp5AkacUKLRUJgZG7mZ4ufSvj9qYYx44zAcN/J42Sa2b2sGx7HHLYxAq NiGDMbAK1pCJcl7aHOLP3W/hjctN8yG49RDIzL/Q5fXDOwsihnXUpDek3q5Jzqu1HMUF TvIA== X-Gm-Message-State: AFuF++lKO0GOtrIa//iNg+nBarDwSjYw33IBneVMkfgDBBwjPMbrZInN NBHbsT1MCFk9bjKe8PUrCpWbmVJmpXxugDQSa/ZXjYh55zkfSqha9sfBQGb3C1LO X-Gm-Gg: AYBFou0i5TBxBM6cFoZjHcVjpEeImMZkWTTtlspXIbF0/7nmN35riPsL9KeyBfkjedF eie5AYDyuTxZBwsP8OZHlzyOIbwIJ/ELb6ea/QuU9ntrpxZfFf0oCscKzQR+fpB7UVtrNH/bp74 OoEHdcXiev4gZyNlHsiBL43XNAmiPYiASCXHev3ZokI38/88nqZ7zixvxm8cRz/BO1vLW/IIxI2 zpNEhHy6jTVrq0thCjjQkHS68D10o+3eju8MKpGJfDu/7QzX69bkSZbzXWkRhFOiMcRJbqtYchs EKDBzI5NXT4WF9m5A8kiYnpLB9SLccCaWXSYOsT8bKPViRiGxeQPjn1u2BJchKKvQkT7Q96UAtH gP/KrvZl3e9qLJCTuV3OP7H1KEXXR/jZZ4TPYLqK1h2SF2G/Jm8mQHfIGHeHsoe11s8fuWhDuYT GmUKqKGTaHM/SJ1WnNcIUkXWmppyGSnTF50Lyt7TILhba2DV5CTxhgFjI= X-Received: by 2002:a05:6402:a0ca:b0:6a7:f25b:d281 with SMTP id 4fb4d7f45d1cf-6a7f25bd43dmr505305a12.13.1788527269096; Fri, 04 Sep 2026 06:07:49 -0700 (PDT) Received: from ubuntu1.. ([194.87.83.187]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a7e68c3d88sm1173158a12.15.2026.09.04.06.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2026 06:07:48 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v2 4/4] test: Add open_tree syscall test Date: Fri, 4 Sep 2026 16:06:27 +0300 Message-ID: <20260904130627.453678-5-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260904130627.453678-1-frezidok1@gmail.com> References: <20260904130627.453678-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 ; Fri, 04 Sep 2026 13:07:57 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4732 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