From nobody Wed Aug 31 01:32:25 2022 X-Original-To: dev-commits-src-all@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 4MHRVx6VBRz4bqTr; Wed, 31 Aug 2022 01:32:25 +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 4MHRVx5yVHz3DTb; Wed, 31 Aug 2022 01:32:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661909545; 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=ktyzSjk82nMb9235FJYX5z0FfDW2aDg1esHo8+uTMOk=; b=Ur8Rl+JLbPckq6nZB/inCow61QPVSAZvsQU2bJ2taPu7WUBb1HfLSOlvpoygY7i3LCmCuZ giK/wckKycxJ8D8RPAW28OfBU1igHFLrjh5cKiD9QfGHHjHU7qaetXeum28Fe5L7bHxlgw UYX3VbaWYYE6T2g5BuoFR69nlnfBGEvI6odVgFtQfO7gTaKOZqGlTCbzHpZiqNRoIZB+F0 ZjI+ITq9bN/s1M4hChchyu41l/XUnCvy+XUIHG1ESstWV8FjUeR5iotreCHNS9paOJ0e4+ Ej9ML0UPiFDCS/nJjWSeCouzcoFrPwCTO0y6W8WP1Ca7NZOSkn3nojeIGWtB+w== 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 4MHRVx4mx0zyBd; Wed, 31 Aug 2022 01:32:25 +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 27V1WPR7034015; Wed, 31 Aug 2022 01:32:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27V1WPMZ034014; Wed, 31 Aug 2022 01:32:25 GMT (envelope-from git) Date: Wed, 31 Aug 2022 01:32:25 GMT Message-Id: <202208310132.27V1WPMZ034014@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: a7593bf87d54 - stable/13 - Document scandirat(3) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: a7593bf87d54bb7d6c7224264bf507b1b41efcc7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661909545; 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=ktyzSjk82nMb9235FJYX5z0FfDW2aDg1esHo8+uTMOk=; b=JvQGw89iFsHYPdyZ6nVu946ZIi9V2iQ3f0R1Dzb37jVdrF64MqxCx670DtSuaLLfeL2dN3 RO9ugz6pkZTA7hlcQVfO3AwhwlE9yhdq9PqkN1qWSrsli7ku+5JI7j4+2Rnyno3LaFnLMf QkOw5WxPbHDYdbVhjsVI3rX/yFAPn1FOhZB0O2Sdra4U8JUohb5K1ZRBVhwCZrKD+i2N8S N8r+wH195J/POwszxtY1A2OJaTmVaVUEtn92x6tn0lvae9T+EDzkYssRqOMR5ORVdoRvgx lBx8VNtj53B3PpKsPsML7ScA/lvcS50EtEYBc1bVFpzeseqP7LpNpaoufJ+Q2g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661909545; a=rsa-sha256; cv=none; b=xIArEjyj0aJsnc7XoB8tnBrMLNjhPGRXDWR2VboJ7+tn7r9zkNmOI+llYUPPmgbeE9YQnq QBmX6Y7QIlML8XpZhNqYovZ6VD0emiHv+t9qk1dPBlvZigTeMCqnlzPuMLqqWXdWnSGJ7n QTk2OTqzTv3xN+j9qEt3yv/B9lruj/smm4z0nnxJ16lZr0RqKxjAOvXx3PwVNpck/LAT3k yl1CWvmRb9+0uvBy5TY2Wia/PunFcM6xUdDMBmCjwKvilQXJ7WRnoLwWogMTdh5BFyDuWw x/rHFXYi/knIGsQWttzxqLfNMF4AcJXTE/9lQwntwBSPIN7DH/BSc1uqOVFCPA== 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=a7593bf87d54bb7d6c7224264bf507b1b41efcc7 commit a7593bf87d54bb7d6c7224264bf507b1b41efcc7 Author: Konstantin Belousov AuthorDate: 2022-08-23 03:40:06 +0000 Commit: Konstantin Belousov CommitDate: 2022-08-31 01:20:28 +0000 Document scandirat(3) (cherry picked from commit a294e679738bb4d2254c0ff416d40f6d6329754a) --- lib/libc/gen/Makefile.inc | 1 + lib/libc/gen/scandir.3 | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index 616390ea8559..a8037564a095 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -494,6 +494,7 @@ MLINKS+=rand48.3 _rand48.3 \ rand48.3 srand48.3 MLINKS+=recv.2 recvmmsg.2 MLINKS+=scandir.3 alphasort.3 \ + scandir.3 scandirat.3 \ scandir.3 scandir_b.3 MLINKS+=sem_open.3 sem_close.3 \ sem_open.3 sem_unlink.3 diff --git a/lib/libc/gen/scandir.3 b/lib/libc/gen/scandir.3 index 47057fc647fc..b533b33ce7a7 100644 --- a/lib/libc/gen/scandir.3 +++ b/lib/libc/gen/scandir.3 @@ -28,11 +28,12 @@ .\" @(#)scandir.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd January 3, 2010 +.Dd August 23, 2022 .Dt SCANDIR 3 .Os .Sh NAME .Nm scandir , +.Nm scandirat , .Nm scandir_b , .Nm alphasort .Nd scan a directory @@ -47,6 +48,14 @@ .Fa "int \*(lp*select\*(rp\*(lpconst struct dirent *\*(rp" .Fa "int \*(lp*compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp" .Fc +.Ft +.Fo scandirat +.Fa int dirfd +.Fa "const char *dirname" +.Fa "struct dirent ***namelist" +.Fa "int \*(lp*select\*(rp\*(lpconst struct dirent *\*(rp" +.Fa "int \*(lp*compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp" +.Fc .Ft int .Fo scandir_b .Fa "const char *dirname" @@ -102,6 +111,39 @@ The memory allocated for the array can be deallocated with by freeing each pointer in the array and then the array itself. .Pp The +.Fn scandirat +function is similar to +.Fn scandir , +but takes an additional +.Fa dirfd +argument. +If the supplied +.Fa dirname +is absolute, the function's behavior is identical to that of +.Fn scandir , +the +.Fa dirfd +argument is unused. +If +.Fa dirname +is relative, +.Fa dirfd +must be a valid file descriptor referencing a directory, in +which case the +.Fa dirname +lookup is performed relative to the directory referenced by +.Fa dirfd . +If +.Fa dirfd +has the special value +.Va AT_FDCWD , +then the current process directory is used as the base for +relative lookups. +See +.Xr openat 2 +for additional details. +.Pp +The .Fn scandir_b function behaves in the same way as .Fn scandir , @@ -114,6 +156,7 @@ Returns \-1 if the directory cannot be opened for reading or if .Xr malloc 3 cannot allocate enough memory to hold all the data structures. .Sh SEE ALSO +.Xr openat 2 , .Xr directory 3 , .Xr malloc 3 , .Xr qsort 3 , @@ -126,3 +169,7 @@ and .Fn alphasort functions appeared in .Bx 4.2 . +The +.Fn scandirat +function was added in +.Fx 14.0 .