From nobody Wed Aug 31 01:32:24 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHRVw6wXKz4bq5L; Wed, 31 Aug 2022 01:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHRVw4gvBz3DRH; Wed, 31 Aug 2022 01:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661909544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LPmTf+cMdDZy9DkkBVrC5xqqGeGB5jljVWYbh3IeUjo=; b=BhBuaGXXQE/eu0csFsApWZyTkH+6rfdTBCzIS78NCyTSQoh7Qp5uozcWodreLlwcRauJmy SR3tipAcnNLn+/kaAqBapVyS5K50y1N5cMxKRLsm4+SXcHN/9L6vqzK6Wo37j/0qNuRlMh JaWiqtOIXgc92yXjBUl7+S+hbBIqAaQI84NENoCNcjnmO+TEMpn8wJkAA7u0D4SNYhp02n 7v4hlXviF4kLuSpd81pmDr/vuHdUP7ISeva9iQ9DIe/HlvgkgChxDQyHHjKA4X4neWRpQ2 1facAc5Yav8MU3nYeoKh6wllEhbUbKshufPnrZRCUs1EGnlllPL+bzFmFk9XdA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MHRVw3m4nzy8J; Wed, 31 Aug 2022 01:32:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27V1WOh2033991; Wed, 31 Aug 2022 01:32:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27V1WOa4033990; Wed, 31 Aug 2022 01:32:24 GMT (envelope-from git) Date: Wed, 31 Aug 2022 01:32:24 GMT Message-Id: <202208310132.27V1WOa4033990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f8a926bebe81 - stable/13 - libc: add scandirat(3) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f8a926bebe819c09e04261fb212cacbf3b1adca0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661909544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LPmTf+cMdDZy9DkkBVrC5xqqGeGB5jljVWYbh3IeUjo=; b=ceg8qRUoSCZy2DtvQ2mEqqFxg9Hbve0ao5lxigN6xlpibJc+GhpoueDMOP6I2pKT4Y+S0b bHQQoHU0UcSTqsFd3bPB2rZnSaWtYlKrpFZhvCNas5MVnqdqJJM8aG+GSXOAPNZBsa9w6q ckEFVyMT87r8HPieEeTtOUjd4L+9McUKPuolZISkNs0QL9249sOczUCjk3/5ZM/Mox2wMs XsXjl9saHq04BijOokJ0w463Jq+8OCOeOOhaDZdG1Zi4/mQwRZkYJ9IX0ecV2YS6Nr7+mZ Zj+a3QbG9vyaAQnOmmHy/O6B7tzIH+SbENc4y1UC58TgCHmgX8jVQrOgrTmfgQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661909544; a=rsa-sha256; cv=none; b=vEN3JKa6+1hzfBtL3/4MznlEVEZhbK5SmdQSa/z0Tcl6TNOTRrTg3tZmKO4otJqjXd/Aac HxuBl/cOxDCGPDllSlLCjiAFSfTccda6GZyKqqzWebxISuJhB9d/wpeuowXNGxApjHpppA uYIHOWF6r7LY/y8yJwdauW9VehgaRKC3dv5kGkfC4ulr43gkDCa4Xc342tdCbVeo7+hYGc +NOtdrcX+0V1ClQvc2WZoRXxXwEpAmDJ3M3IRQLI/PlHJ0L9JWyQR8qqxQlzx6tiy5+YOp JdB7JzNxR1VNjRbdHyzViQjbdNdZsapFpJLZ66lUafKxK/+MSTRT1FaELcUVAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f8a926bebe819c09e04261fb212cacbf3b1adca0 commit f8a926bebe819c09e04261fb212cacbf3b1adca0 Author: Konstantin Belousov AuthorDate: 2022-08-23 03:30:06 +0000 Commit: Konstantin Belousov CommitDate: 2022-08-31 01:20:28 +0000 libc: add scandirat(3) (cherry picked from commit 9fb8e8eede5b48eda7dc39f61d815595c14e5752) --- include/dirent.h | 5 +++++ lib/libc/gen/Symbol.map | 1 + lib/libc/gen/scandir.c | 21 +++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/include/dirent.h b/include/dirent.h index 702153e28fc0..047206258471 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -131,6 +131,11 @@ int scandir_b(const char *, struct dirent ***, int (^)(const struct dirent **, const struct dirent **)); #endif #endif +#if __BSD_VISIBLE +int scandirat(int, const char *, struct dirent ***, + int (*)(const struct dirent *), int (*)(const struct dirent **, + const struct dirent **)); +#endif #if __XSI_VISIBLE void seekdir(DIR *, long); long telldir(DIR *); diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index 012c9ff11f04..74676ffe2270 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -439,6 +439,7 @@ FBSD_1.7 { posix_spawn_file_actions_addchdir_np; posix_spawn_file_actions_addclosefrom_np; posix_spawn_file_actions_addfchdir_np; + scandirat; sched_getaffinity; sched_setaffinity; sched_getcpu; diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c index 4cfc823e4f94..3a891b0ad3f2 100644 --- a/lib/libc/gen/scandir.c +++ b/lib/libc/gen/scandir.c @@ -42,8 +42,10 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include +#include #include #include +#include #include "un-namespace.h" #ifdef I_AM_SCANDIR_B @@ -159,6 +161,25 @@ scandir(const char *dirname, struct dirent ***namelist, } #ifndef I_AM_SCANDIR_B +int +scandirat(int dirfd, const char *dirname, struct dirent ***namelist, + int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **, + const struct dirent **)) +{ + DIR *dirp; + int fd; + + fd = _openat(dirfd, dirname, O_RDONLY | O_DIRECTORY | O_CLOEXEC); + if (fd == -1) + return (-1); + dirp = fdopendir(fd); + if (dirp == NULL) { + _close(fd); + return (-1); + } + return (scandir_dirp(dirp, namelist, select, dcomp)); +} + /* * Alphabetic order comparison routine for those who want it. * POSIX 2008 requires that alphasort() uses strcoll().