From patchwork Mon Oct 5 08:11:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 99978 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 CCA5DCA5FF0 for ; Mon, 5 Oct 2026 08:12:22 +0000 (UTC) Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.15217.1791187932236043844 for ; Mon, 05 Oct 2026 01:12:12 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=QnhCWgPb; spf=pass (domain: gmail.com, ip: 74.125.225.141, mailfrom: frezidok1@gmail.com) Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-4a0280d4f56so8603525e9.2 for ; Mon, 05 Oct 2026 01:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791187930; x=1791792730; 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=mBl7W4ZDCYNuvlFqDhc5gVZWtBj0/1h3GIJo4IXZB90=; b=QnhCWgPbuDQpRgSNvvcnCAFKgrBYnJ98NiNv0nxhWVY11pjrlTceWWfPohq7iQ2aZz fgTdlZ9yA4lyBhnSy48ryz0hCMFkj0ta3kMWCZXyJB9lisngY/dpTGR7gGd3KLoWEHZD yVTEmZ5Kul2CR+xYdPGqZF18lo3LORQWrcKsavs3hmuaesI34+486ggZKtRKiOJbwNOF KveV9IaAoq/TuYQzqAReRH1jSPwfNHCyVTTIQU5RaovW9omkYm7LiAIjPG88ruIfh8Wn lYGBnAZDXw4IY+OSkZVDeCMqf1fVguhjYTnJqDcxy3FfCEjvqgSi/Af7gIqD+b/ztFO1 zkVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791187930; x=1791792730; 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=mBl7W4ZDCYNuvlFqDhc5gVZWtBj0/1h3GIJo4IXZB90=; b=g4xqaAT93aPtwhoMqpTSQGe7E2+hjgRh38yeW4y5+3/Ptd2S1290hj7NIizH3cPuuW e8TCSj4Mmigv+BGn6p5701fTOH0GQ55HyMgNYeExfq3troBqZ0sff9tohEN1mRFECAkA Qyy/fWmA0cZRf0u78FKGJiQJ8p0sT203DJrE+Mau8Apv3ueXXs1CjCEi5f4LvE3cWhaa ZreyQ6UF7PMCWhSRmVgVvK2+ByOpIuVT8w+Pnqp+uBebqXniVzfNiAbSoArP4Pg17RDJ 7P0bwuFc+PXgDsi/8pGEYWPTwZh9bPFaTC9/yxD65pGpZXQJoi4Gxg4jH7EMlUwsk5e7 1oAQ== X-Gm-Message-State: AFuF++kVbHYYh5VQzw2ZFkOijS5VF0yIp+ZSubJgLFWv7ajVyfXGmaLm IR04C1/sTMZKtMLZcQZck0tmQDcW84m6CLhfRkZlAIm/kZHJKHoD3N0giAshiJxr X-Gm-Gg: AYBFou0fJ6BeXQ3QdSwM4+83tHDeWGhqMMc1joab43LWPa8kMZZatphCfkMY4F/JlVR GM6KtVOD5AA1ANRZVN1I/QQPfYWcK1oPFORhCCTjW1qkJD0hX9c6sSCoDNC7mM5gS9/UbX3GbDp w0vnyUaKAvMLPk8phGp079K0vUfRtXt4VKh6Ixfda8THidHCvQ+Sc+OobFijUCzZ1WJoKbYfBE0 jGvNcO+l0ckUQCzKaFjoCB+p4jLmyDdKQhVKdopNsKsZfZ0PNND8DdFdpnjog659+PMjMhc2mlX 304z9EvNCc1+4snT5kjPDE19hbYoYfkgKfLtcCEIZpcKKqreLCWihWSK6M7+2b51mrTksdsjFsE WgPJqqDmReZp/MW1kndJ/WEEnCRhmTtsKVxFCeOka0oH3qFLxRuE5Y82EPTkdMPjzKNwSyvug0o aG2XOs+TcYw+/WOguJb0ohsDEb9sJR4MmLieYDVgKvq/J9OjwAwvfkyiFEiQPv4RRDE6GyudJNW UgmbWEkNC8kQB+9mvHw2fRLagWA X-Received: by 2002:a05:600c:a306:b0:49f:f099:6f8c with SMTP id 5b1f17b1804b1-4a0275758cemr126977045e9.9.1791187929982; Mon, 05 Oct 2026 01:12:09 -0700 (PDT) Received: from ubuntu1.. (ppp91-79-47-228.pppoe.mtu-net.ru. [91.79.47.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0280d1e38sm268675535e9.13.2026.10.05.01.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 01:12:05 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v4 1/6] ports/linux/guts: Add open_tree wrapper Date: Mon, 5 Oct 2026 11:11:22 +0300 Message-ID: <20261005081127.107126-2-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005081127.107126-1-frezidok1@gmail.com> References: <20261005081127.107126-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, 05 Oct 2026 08:12:22 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4984 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 | 59 ++++++++++++++++++++++++++++++++++++ ports/linux/portdefs.h | 16 ++++++++++ ports/linux/wrapfuncs.in | 1 + 3 files changed, 76 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..ca299a1 --- /dev/null +++ b/ports/linux/guts/open_tree.c @@ -0,0 +1,59 @@ +/* + * 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 (flags & OPEN_TREE_CLONE) { + pseudo_diag("ERROR: OPEN_TREE_CLONE is not supported\n"); + } + + if (path && path[0] == '/') { + /* If the path is absolute, we should account for a potential chroot */ + path = pseudo_path; + } + + /* + * Older libc versions do not provide open_tree(), so call the syscall + * directly when the libc wrapper is not available. + */ + 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); + } + + if (rc != -1) { + save_errno = errno; + int stat_rc; + + pseudo_path = pseudo_root_path(__func__, __LINE__, dirfd, path, 0); + + 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..579dde7 100644 --- a/ports/linux/portdefs.h +++ b/ports/linux/portdefs.h @@ -82,3 +82,19 @@ 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 + +/* OPEN_TREE_CLONE may be missing from older host headers. + */ +#ifndef OPEN_TREE_CLONE +#define OPEN_TREE_CLONE (1U << 0) +#endif + diff --git a/ports/linux/wrapfuncs.in b/ports/linux/wrapfuncs.in index 3cea20a..bc6ca23 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); /* preserve_paths=1, 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 Oct 5 08:11:23 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Sakhonchik X-Patchwork-Id: 99977 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 B5057CA5FCE for ; Mon, 5 Oct 2026 08:12:22 +0000 (UTC) Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.15218.1791187936286870334 for ; Mon, 05 Oct 2026 01:12:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=nHjzJnrI; spf=pass (domain: gmail.com, ip: 74.125.225.141, mailfrom: frezidok1@gmail.com) Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-49d1fb0cf5eso12440475e9.3 for ; Mon, 05 Oct 2026 01:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791187934; x=1791792734; 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=PQ9OtYQz/ILSUSpuY3QKpve236/B7A1PMMq1AdJSML8=; b=nHjzJnrIlMUefP40Dp+5F+HGAL0ahu7cykhANkc8cDl4GfkrfGXPErlFej6u/2Y7S1 aTfwNYYMvIz79Yh9d/zRBxsI3fxVTSQAaI8X/kjvqIp97nEOtpR9sjL11t2p9Yo1hkTX RVvypDBfFIUNPngk6j9mrtl1CiGA29ibd1Nkkc1UaITBVDCkYffPWROC7DOyvkRDMrW7 miti8b32b4rL5U7HrGUI4ycj7+qW41Z3BKkzQG9KmPgxdmlbl2p23vszHRU+Aiauw4yD D7fJR/LKDQpcHpkqVNBjsQsvF7EU+vF77LPHw7NZZnffCoYnOeXFB5DRa1EO5uGiu9wZ mCoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791187934; x=1791792734; 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=PQ9OtYQz/ILSUSpuY3QKpve236/B7A1PMMq1AdJSML8=; b=NBU20ikmQHqLXyFoi4//pOq3jz6VK4RnZCu4WhMBADur8MSlf7hyG7Ku9KqGNTBpWD TCn7dGrLyYzIjqqYNZyRyIeRKcR8fylWsCircZBLlu0MVj426fihYhYqgTgYLtkg4ORo VoTSIA9FI6t/0R50jkltPnNhwG3aKbiw6cL59Sjab8AfrHp4TacwisxZ/5DPhFDuegI9 Fsp8UJqPrvtp4HSf1XSGJo9VpwER/21J/Y5UcPV7dke89Lq2UI+QiYyDFd9UXd15eyVm vWPGtXYRQGGsmtIm2PVl613MIDopzPJD5CppfP/9oLi80Hun000mJOQHe3nPG3nzdHPe jk5g== X-Gm-Message-State: AFuF++kMHa7eb+f6S6Up+gtEswDpvl6Z1qTZ3Dnby5oNpN+Nnw2AwxjE UBjZG0IHlJ7tg14uX9DRoU7s3HJBh93p6Mo5pztX+PZZrYXfv7XpnEGP3Jy8qQ0D X-Gm-Gg: AYBFou1orZUGwh2+xYFVuW7Dz1XnRabkf04+AEnU4ps0I5teWVkPh/7vlmTY+9dV/Ni dVO8P9GAILMql1L2+uZqP5UM8H/eYbT8X5QiPSVAk0Bgxmd4ukAtPPBYgEQwUUQXSwDCxzUNaiF gfi7Pa6/HyHNpRH5M/2YYUNyDuqRisyI5+PVlY8ovmfvUEL6Ho4EwWe+maxFjAA+k2GycgfIvlD J296xJvwi1HjOcLS7Jl0b2sRyQRSrdGtbdrxEhyeitsJgwbRwOcQd7mCCBfyTH+MBqI2UNn1XBo ivCVOPO5OgaFqHBJ/hfAph9dbjN0Nv7qeKnm7vyPRD/8S502RlFc7Dm44cT1FGUQ/nm7ncReWW0 E3huOcaDnC/vt2iIAMmjndaqnoaUq8qrbUxEyb2g6+BihDdD4uV/34i+afJ+63J/k7p+t9lWK1a uY/Bbo8xrWkCpV6FcMxgdW6WsLiPvSuqbxTZg4c/t2wQ4x+LL/TSKP5bF7yLcmuvSW4hNzDV5LS zoeEMazBLKY4Np8ILIJRyF/+xlj X-Received: by 2002:a05:600c:a011:b0:49d:17d4:aff2 with SMTP id 5b1f17b1804b1-4a0275107e2mr164615535e9.1.1791187934197; Mon, 05 Oct 2026 01:12:14 -0700 (PDT) Received: from ubuntu1.. (ppp91-79-47-228.pppoe.mtu-net.ru. [91.79.47.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0280d1e38sm268675535e9.13.2026.10.05.01.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 01:12:13 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v4 2/6] test: Add open_tree test Date: Mon, 5 Oct 2026 11:11:23 +0300 Message-ID: <20261005081127.107126-3-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005081127.107126-1-frezidok1@gmail.com> References: <20261005081127.107126-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, 05 Oct 2026 08:12:22 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4985 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 | 141 +++++++++++++++++++++++++++++++++++++++++ test/test-open_tree.sh | 9 +++ 2 files changed, 150 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..9570f11 --- /dev/null +++ b/test/test-open_tree.c @@ -0,0 +1,141 @@ +#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(); + rc |= test_at_empty_path(); + rc |= 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..427d550 --- /dev/null +++ b/test/test-open_tree.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +./test/test-open_tree +rc1=$? + +PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree +rc2=$? + +exit $((rc1 | rc2)) From patchwork Mon Oct 5 08:11: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: 99979 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 DD795CA5FFC for ; Mon, 5 Oct 2026 08:12:22 +0000 (UTC) Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.15219.1791187940441920138 for ; Mon, 05 Oct 2026 01:12:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=g/tiskKD; spf=pass (domain: gmail.com, ip: 209.85.221.47, mailfrom: frezidok1@gmail.com) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-48c4649b35bso1471640f8f.3 for ; Mon, 05 Oct 2026 01:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791187938; x=1791792738; 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=9+md5jNnfBEJeZWuNm4WQPGV7HdtWxtQMntjRBhtAlM=; b=g/tiskKD6Bqe76v5gnLQ5Wnk+FQ6cAvlvy8h7lv/Ck+toEaWUJdqbvl3m31Mw1zKKO zl/KpEbWoDYIt/F8UhBW0fc1M4c97uxtZjjNhNQx5npNwlULcXct3WfI4uGFlqXO7l+Z lEcAjnDci9Vcmo8dlzNYG9S6Ng9TXDbEJw3BQiO9mxlqZb9WpW41Lf36ycFVgV4eggii OE9H/wzb6ONSzJiuxbw6V+9iZjTMnXVRi7xwFwAweQEY+oQovEGHE8UELoRCZfemdk3v g3LsHiyBwQOpH/yhwKz0MY3L8A7oJqyKDRQdtbgiRAZ4JcSAUHMI7cu/82hIEsmgtnCI KxLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791187938; x=1791792738; 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=9+md5jNnfBEJeZWuNm4WQPGV7HdtWxtQMntjRBhtAlM=; b=LNVYct1vxIlQUW9AqZuzadSqy44n9wR8tLo6518kAQkgG/ALNguTDkZs4UM6kxQ85m 4/ODWmGTkMMeM+dZ+uXYSxnHyzaObJKay3Y46coPIhE31e9nQV8ADckxm7wjxI5Rs+XC EqhlYSPEgqS/D5PkbcV9kxumDZBCdEEvKti2AQo0SQ33uQ971ZJTTE4IlKrp0tgcIlXV V3ykxwT6aU/1gqdEkULXPSPWlI9HbDV7R2Tya3jUKZj89GaNHIVKJagaxKMpTH8WGSG+ GrAjmuezay9Mw39knuWXotzbLW1rxg0/BEmGNKFyeIn10VH7jdG35ngfLvTQszfYyKEy vMTg== X-Gm-Message-State: AFuF++lAlWKhfWauyp76gl2zfMDHUTBomjFdv0oTGbZVGJWZl7ugsSbf XQa6jy+09Z4ittX9He0Jzoi/zqdJRtgG81UxHEEwJRc+/YyfE0xZvJNUsbEcc5Fr X-Gm-Gg: AYBFou3D1gVbtdFQ/kEETPx/5gO14LQAeEF2kLCgcB+XCrb2l3RLrd4T3H51V5ghRxo PjMRvYCxlY9HgnbWMv9ZBq9hTQ/aSE+WT9tKy7nKnW0qXgLz5uytVwfuBCN3/hAZ0cojzSGmSSp qiLD+YKPzAsn/HWpaE37PWu3kDTYeDYlOKc6B8bz+sHT/chYFwQj6h75pnLstlztxSRR6ardGoi HSTdp1f6a9nQKBrb7zQ/R246kdwn84zy/jhpoFv+9mtO0DX/XX938o3ZV29UEt3jj9SboHv9UmH DM9zRCCYwB+CAATXPTNf4ojd8UYWCMMEw0kNzinEcifKjrzynj+FrdqEap/VyIZLQ8UE042zV0s d8487zbU2oHkaVQ2mENZKE+4fREiSCHpU+d5iK9lfnDSv3g1GIqwNDbmm8ILy08TDIVK22MuJdu qPEGY03NgG57DZ1/YyWJg+WewIV06vXQsiM1EN9emlXqVlC9dIGN4kWjHci+NNFiiILKzDlCU4r P5Ae6emHqk6/g2Z1UrUKpHOyzquUw== X-Received: by 2002:a05:600c:a49:b0:4a0:eae0:769a with SMTP id 5b1f17b1804b1-4a168100e0dmr95800045e9.28.1791187938208; Mon, 05 Oct 2026 01:12:18 -0700 (PDT) Received: from ubuntu1.. (ppp91-79-47-228.pppoe.mtu-net.ru. [91.79.47.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0280d1e38sm268675535e9.13.2026.10.05.01.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 01:12:17 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v4 3/6] ports/linux/pseudo_wrappers.c: Add syscall support for open_tree() wrapper Date: Mon, 5 Oct 2026 11:11:24 +0300 Message-ID: <20261005081127.107126-4-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005081127.107126-1-frezidok1@gmail.com> References: <20261005081127.107126-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, 05 Oct 2026 08:12:22 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4986 From: Dmitry Sakhonchik [YOCTO #16379] open_tree() was added in Linux 5.2, while the glibc wrapper was only introduced in glibc 2.36. Before that, applications using glibc had to invoke it through syscall. As a result, applications supporting older glibc versions may still invoke open_tree() via syscall() 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 Oct 5 08:11: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: 99980 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 D7D35CA5FFC for ; Mon, 5 Oct 2026 08:12:32 +0000 (UTC) Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.15161.1791187942846478977 for ; Mon, 05 Oct 2026 01:12:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=WZOR2sYt; spf=pass (domain: gmail.com, ip: 74.125.225.141, mailfrom: frezidok1@gmail.com) Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-49fe8bf173aso8376395e9.3 for ; Mon, 05 Oct 2026 01:12:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791187941; x=1791792741; 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=SYks8fJRt6Vd8Ce4kvrMwHiAqbSw8S/YxhOTZ/v6aoI=; b=WZOR2sYtE+J9/90mBYnTHIcMdIQbfK2L5c7xTAp/ejcftqxpuNqlx9syajA5sxhJpy vl0gM1JJKy3zZajIyJVwk7/2g5VCls6b+4dNd1EUQgk5bb2otE26KNwSkZatxt4ZSEPA UIFGLrsbhJNXcxiWT6V0Y8Ofy0IJGdZE78injeHS7tUQtg0jp8/LJsq7otjhmHvK2elr kcckpnBjKYdgWHiOWxb0qOt1TzwEUeNvs4QMErN0cBqpJAOLeS9/xlOoa7UbISI+ySBB X82OYObq/DVzFL3Q/3BIh9tV9XHddQZJZCd4aytO9EjgIPuIeDddgDc4sGhqqMaJsP4X KYxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791187941; x=1791792741; 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=SYks8fJRt6Vd8Ce4kvrMwHiAqbSw8S/YxhOTZ/v6aoI=; b=hlI+ZVG09twCAfiBvwmc9667+0F3vmTmJcmam9L0KxS0dmArxYSTlVIf/xwjJ2ll8X r6vqxc8JpugZ5E1blpW6SL+W5JnU66H9CKfb4ORyx6Lur048PVqsEgfYDBnavqyUeFXM CEPrnSyTLERD+kXkIsmqP1+c41YJmkeKPMyCLgqedM1isEpY6MpTS22kS8hp89ZihnNz NhSq68c+4gmTgKmCnS6FBboxiMxqdsjmYFIWJItFG9QeT+nm5Hws8xmyauW6NZSN/px5 QX56cMujbYtPC3XOxkXrxXq4lSetDnTrInX/LVgC2+6YzR7PXNfbsjkYga3JiW7VpNmy DqMw== X-Gm-Message-State: AFuF++kTgORKvR5/Q3gfLMzRtz5zUxCdwoREx18z5WXIXFtltNBmYAIg IzNK9Ff9iOEupYPxxUtAlcWLND9/a4T7duRmi1OWmCK0L2vE99au7HAf/DTZPzNB X-Gm-Gg: AYBFou26Zz0ElCRuUc6quMqwStI4qH53DAI9U5A77E3z0BKo+zvoCtiKQ9G06nSP4lj gbKojMEBO+Fuf3cr7FHOamMEPkqC29j83c2Ms4r01oTFpLa+gBDtAYLL4jfhTm/110pVEHZDqpJ RFbDTObVvBQIZMmRsRc0mGYFPjuBghC7ns8u8H3FE09Z5GaYl4EliTQVSXKSCl3NXlpJp7bPi7n qrKzOd2REOlTG54Wa6sHgAgs+hZt/ZzYHpRdXfFUR04I5fQ/UkiLXMetEf3QoZ1DX6WLiHcIJru U6IlQF+ihunxM2JX+91FWqaUJ1HBcZR2ql/3dwZ+z+Y6/kW9vEtOwp8IqziXm5INlp33dm6PLHt wuvqmsO+bZVCkVNjwRPZqPvmFylQ2y2y9WX44pvbp54MoKgVPzmycfgGR2PeCdWpLNkHhwQ3W/X Kqdk5Ek0/TyZqHqALkTt66Z4NP6jK6DofiJcxsVFsf1MifAA1yMAwMknLclHhReIrB8lEYvs3G0 3ieLtkhO67ay0MG8lk2f0oqp+EY X-Received: by 2002:a05:600c:8b33:b0:49f:fd2d:23d1 with SMTP id 5b1f17b1804b1-4a027598c41mr164691295e9.27.1791187940866; Mon, 05 Oct 2026 01:12:20 -0700 (PDT) Received: from ubuntu1.. (ppp91-79-47-228.pppoe.mtu-net.ru. [91.79.47.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0280d1e38sm268675535e9.13.2026.10.05.01.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 01:12:20 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v4 4/6] test: Add open_tree syscall test Date: Mon, 5 Oct 2026 11:11:25 +0300 Message-ID: <20261005081127.107126-5-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005081127.107126-1-frezidok1@gmail.com> References: <20261005081127.107126-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, 05 Oct 2026 08:12:32 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4987 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 | 154 +++++++++++++++++++++++++++++++++ test/test-open_tree-syscall.sh | 9 ++ 2 files changed, 163 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..42eeb37 --- /dev/null +++ b/test/test-open_tree-syscall.c @@ -0,0 +1,154 @@ +#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(); + rc |= test_at_empty_path(); + rc |= 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..b3cd550 --- /dev/null +++ b/test/test-open_tree-syscall.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +./test/test-open_tree-syscall +rc1=$? + +PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree-syscall +rc2=$? + +exit $((rc1 | rc2)) From patchwork Mon Oct 5 08:11: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: 99981 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 CAD96CA5FF0 for ; Mon, 5 Oct 2026 08:12:32 +0000 (UTC) Received: from mail-wm2-f13.google.com (mail-wm2-f13.google.com [74.125.225.141]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.15162.1791187952218518612 for ; Mon, 05 Oct 2026 01:12:32 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=k1bMTR5d; spf=pass (domain: gmail.com, ip: 74.125.225.141, mailfrom: frezidok1@gmail.com) Received: by mail-wm2-f13.google.com with SMTP id 5b1f17b1804b1-4a022e9cbebso12118545e9.0 for ; Mon, 05 Oct 2026 01:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791187950; x=1791792750; 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=Ahr65LlqRZF7ziGb54e59+uE7PKTZRVpLFM3ck0sKhM=; b=k1bMTR5dN2k8f2wMGuBJ4jILJUuCsXby0amHdSoyCu8av6NSmO81Hj46yKYBph0XLH i2pyo9PaDBMkwNUgWD+pvV2ISlicbyb3lKVRTfV0O4Lc9tYOgwyXZLy28QiJSfTO3Shw 8yHC5wo51Fb0eqSxIr6D5j35Zxnc22U43exhlMz/reiDynvw3q565Oh4++gTvXa5pWu3 zlB3fTsq1vNeHroChqOVTgebRShizr2sgguNFYx1DiY8Ne26PyECdeWgUMP4fNd7AREN eHNDHQXT46fh2eavpl6JBIntqj1aJsLBJwllgwlok00J8HH0E79xVSL4Lk0JYfts//0/ g7ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791187950; x=1791792750; 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=Ahr65LlqRZF7ziGb54e59+uE7PKTZRVpLFM3ck0sKhM=; b=okixvyPTYeKwizhm6GihvoiJMRTwDTQWCbTFwnd/ck+VB+teU6xbP/gv6aZ3NmKfa0 Nj8PNS0E+lUFsUN8FflLoKWvn3bqS7hZD0rylkRiNJwEI/cNM388xzmyJj+lSsS0nGmt jVgIy9hVKASnnFuZpMblxeGmXBWhOLq8hyugodqXfk/X2W/l/UNJ5INwUuoU4BXLZRhk RUU46/fKCJkvLtAYKm4sVFyzCl2HaPf4+xDzOrUnZnMk78TcuUQ8EUeldn55TWul0dAk wdnmHNlr/EafV1/fwYZn9eTqSYA/icD/CHLkGp8TtBdZb1S9KDF494WoX7UpqiG9Jc6I j40w== X-Gm-Message-State: AFuF++nxkzq2RkxaAmX92tAqZh4PirlPTsV7f0686S90D++c9lMMo0pe P60H+M0wU6CQ9X3ceWYw16oUgxrZ/tiR1Njxds5Igt28AgcdU5xwRIRQRtf69Ix2 X-Gm-Gg: AYBFou0wPtnfsj+Q757TY7WqglXoIpeVy+r4yf8gqDtmxyK9in8VOrKfNAh5jzAcViB 6X9B/QyQenmR0wWVwe99DjJiEOywtzIBVQfjtaQbnA2NaDjZHDdQ8mKeVEANP/qsxXKt+PMY/p+ pRPHK7BS4IhF426wX169AMoMtG5x9SKe+/SNK2ar/L6aCssCeRDN7oJYGxoceZM+BeCfDIj0hC0 wBJNJ11yq69HdbsYnZaVlHb5b3mkM6I8SE7A/XRBcZNtYBbzrC+3o3emR7oelAcvtuASkDTXE7v EDFnPtsqrpd1Y53GEQB7Q/+PBfBTHFgGJS2/ieKWcP9Sf+wfI8BwVLOtIAhjJX0rHXgAOfYjdn3 X91ouaoknkDmsbRYiNUmilsqd+wcREiKQaHhSIhkugHB5VzXfrhNiKHuoIiPDRunA2p0lkwtlVp 5glDffVv0iftvDG6qkqTMWxOD2s0RmPxzoNh7VTdb402qcF4iCQu1oXtmuyQQBOmiEkUezgU3hD fON9UbWfUqDPeQYh8wPtxgk8yjG X-Received: by 2002:a05:600c:a306:b0:49e:719e:e215 with SMTP id 5b1f17b1804b1-4a027577b68mr121333965e9.26.1791187950278; Mon, 05 Oct 2026 01:12:30 -0700 (PDT) Received: from ubuntu1.. (ppp91-79-47-228.pppoe.mtu-net.ru. [91.79.47.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0280d1e38sm268675535e9.13.2026.10.05.01.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 01:12:28 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v4 5/6] test: Add open_tree_attr syscall test Date: Mon, 5 Oct 2026 11:11:26 +0300 Message-ID: <20261005081127.107126-6-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005081127.107126-1-frezidok1@gmail.com> References: <20261005081127.107126-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, 05 Oct 2026 08:12:32 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4988 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 | 167 ++++++++++++++++++++++++++++ test/test-open_tree_attr-syscall.sh | 9 ++ 2 files changed, 176 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..cc38c5f --- /dev/null +++ b/test/test-open_tree_attr-syscall.c @@ -0,0 +1,167 @@ +#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(); + rc |= test_at_empty_path(); + rc |= 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..f6e51f4 --- /dev/null +++ b/test/test-open_tree_attr-syscall.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +./test/test-open_tree_attr-syscall +rc1=$? + +PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree_attr-syscall +rc2=$? + +exit $((rc1 | rc2)) From patchwork Mon Oct 5 08:11: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: 99982 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 C8B71CA5FF0 for ; Mon, 5 Oct 2026 08:12:42 +0000 (UTC) Received: from mail-wr2-f34.google.com (mail-wr2-f34.google.com [74.125.225.98]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.15163.1791187956031679395 for ; Mon, 05 Oct 2026 01:12:36 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=W7aIwNzI; spf=pass (domain: gmail.com, ip: 74.125.225.98, mailfrom: frezidok1@gmail.com) Received: by mail-wr2-f34.google.com with SMTP id ffacd0b85a97d-48b01c41135so894926f8f.0 for ; Mon, 05 Oct 2026 01:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791187954; x=1791792754; 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=LQYIDNnXUCepz+96C4gqw8T6ZXsPjeS5T1dcjHPVZqc=; b=W7aIwNzI7ogQrUuNR07pK7NVWrwI3nOpdRL2qH5QIaCgA2IrQCp9oPLGshlYV/xVgz C1bOl5rSo6ZMHhLxDxqSqe9MNBYZnpnj6jRWOAXpCQXr1OSuC5TEkKMPfqn8SeTQeVij r+Gc6JoKhasrYEm7ZRguoqySKX234qR6LuP2cjQMNb+xUsW/0wXmLl333NRicq8hEzIp 0JK1jnRKGJQ3Gx5cRmlTAaG1U5ZQ4wmtk3798BrCZZnAsYgwaxr/iH1aXMtErGAzfeTK wLL+LJAMSTizVQKnA9Un6C8rAuLNPpgbhq5XW8cFh6TEarP++vz2Gp2/so5nDRqGBvgm 3Qug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791187954; x=1791792754; 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=LQYIDNnXUCepz+96C4gqw8T6ZXsPjeS5T1dcjHPVZqc=; b=dUcZl7HOF8+InsLo7EmfGG/8HRogjZ3QPtSbDB1g8dpejv3H/gQrk5V5dBGu5pDvEQ HhxKPlv/87VCDJkhW4crHoX89QI0XoGyewpqxuoesCRb5GK/eKZzsYx5OBbxY3EsuReH rEoF7TvpGw/DyG7Mnm9L4X++UGatBGPlQ6y+sehPsAGedEqhZLsuGSLEBiObfsJWBXN0 8+PEZ9hgURW9Bu3RtnQSVdBErY5LIVgBlVwWvLSoM+wfLro+s5wg6Mn9p6L1iyyhjpby TnsFi3yuWqVJ8H41I4YrqfitIaimPhbJn7iikq/XAGzpUVI7/MgVWF/EGeHw7TvgbhiP O+Iw== X-Gm-Message-State: AFuF++lUGoxayRvhswWIxKhZkVHkpD05qwaKrh9f6LsjCSOic8C0hSD5 COwoLmWKIjLr024cTC1Li8SR3QoVCLhIO9EbulgBASqdIsXYx7MWDUNAkBUnRg9I X-Gm-Gg: AYBFou1kJg7pIgvOvGtGzgvxUxeqFIiUPo3Snq7cH2I+YfSlk25UlVWr+IwWRKQns7T yF0UR9UhlHWy+bOyAQNOggJ1poR3FpJwX7iOpmU02YQbqnz5cuxB/1tSC2aQih/3zFTpbEGyrWP ZDc2pZ634pnJRtuUggdn7Q6M8n3WQ51Z4woUqqmVwIB/m56uB8CXtL875OALowfSQwtmk3QVG9q oO5YXgJcfTHZ+e8tYMppOqmgXNwUm04imQK7jaZEChJRR+Vf7O6gHfclP6W/bQSkledC4wucxUa KWY295plnk/7uNsHVT/I7okmH+hUbPfe/vcWcXU5MrO+YARfPMhn/HgN5qUpRI5CGyAQo5LfF6N h+weYuTQJdctBJfhRxh7D9845GhJcR5MJ88uTmuFTdikjRIvzREEIdcgHcXpf76oNbbrq1MkYS+ qOz2R0lDKXKuj/cZI0Gx/LvlRuKldDxoGb/WidzlpDJ0tTPm1ngPYzjXMPIgPqDuT/8ooPiuvvx a3b9Up2LMz7xuOyV849Lwxp7ZEYrk2N8wd4p24= X-Received: by 2002:a05:600c:3152:b0:49e:7c8c:361d with SMTP id 5b1f17b1804b1-4a027584bc4mr166737025e9.22.1791187954053; Mon, 05 Oct 2026 01:12:34 -0700 (PDT) Received: from ubuntu1.. (ppp91-79-47-228.pppoe.mtu-net.ru. [91.79.47.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4a0280d1e38sm268675535e9.13.2026.10.05.01.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 01:12:33 -0700 (PDT) From: frezidok1@gmail.com To: yocto-patches@lists.yoctoproject.org Cc: Dmitry Sakhonchik Subject: [pseudo] [PATCH v4 6/6] ports/linux/guts: Add open_tree_attr wrapper Date: Mon, 5 Oct 2026 11:11:27 +0300 Message-ID: <20261005081127.107126-7-frezidok1@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261005081127.107126-1-frezidok1@gmail.com> References: <20261005081127.107126-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, 05 Oct 2026 08:12:42 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/4989 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 | 57 +++++++++++++++++++++++++++++++ ports/linux/portdefs.h | 8 +++++ ports/linux/pseudo_wrappers.c | 16 +++++++++ ports/linux/wrapfuncs.in | 1 + pseudo_wrappers.c | 1 + 5 files changed, 83 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..3cf8fc7 --- /dev/null +++ b/ports/linux/guts/open_tree_attr.c @@ -0,0 +1,57 @@ +/* + * 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 (flags & OPEN_TREE_CLONE) { + pseudo_diag("ERROR: OPEN_TREE_CLONE is not supported\n"); + } + + if (path && path[0] == '/') { + /* If the path is absolute, we should account for a potential chroot */ + path = 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); + } + + if (rc != -1) { + save_errno = errno; + int stat_rc; + + pseudo_path = pseudo_root_path(__func__, __LINE__, dirfd, path, 0); + + 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 579dde7..6cece4e 100644 --- a/ports/linux/portdefs.h +++ b/ports/linux/portdefs.h @@ -98,3 +98,11 @@ extern int unshare(int flags); #define OPEN_TREE_CLONE (1U << 0) #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 bc6ca23..d417ed3 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); /* preserve_paths=1, noignore_path=1 */ +int open_tree_attr(int dirfd, const char *path, unsigned int flags, struct mount_attr *attr, size_t size); /* preserve_paths=1, 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