From nobody Mon Jun 23 13:03:30 2025 X-Original-To: dev-commits-src-main@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 4bQpDL4KQLz60Kj8; Mon, 23 Jun 2025 13:03:30 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bQpDL1mntz41pN; Mon, 23 Jun 2025 13:03:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750683810; 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=YePokqWg3N8O9SRbx1Y9Ob5KCo3wjbloaostekWwUDc=; b=iZG72+7OpnKEbzrQEEgWXDX25C+AxAk9IaSEEVgKEtfgb6xFRFKp1GLeGsO5YUjoLGrrvg Mq/6hyPwFhaeqBLs4iAsZiP1P/U9QT1sFY+Z6Aw/uQYCVyJ2ydd2Et19JkjMj3OjqSdx/2 Nx77wFsozhNPFRImgz5Ne4cs3moCrOeEPpDH0Hf68rVaXOavKSSJYnpKykHHn4Dy5+xSvx BhuHaIRRWuCqxwX1B1s3a+C6wFZvY8kP7dB4XGwIdn7SoQQFE2IyYmFgEZeYBd2A8jzbuA NSSO/+q2qbCLJfh2QQ9D7rQAAz5blSQttNe2PR3lCIYkE8VVjpVQyks6W92mWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750683810; 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=YePokqWg3N8O9SRbx1Y9Ob5KCo3wjbloaostekWwUDc=; b=XOkZ61ZP45P/OHNSwkb1qz06laJ8gXF7cuepJyIAEREwtfopYGN8HfA/qRHdvtW+r3QLJm e0EcEw5A+bZevrrE0cf75fH1KOt7BRoUb7/3UWlfkiCrVlhQdCHc4C1qCnDUCDPRSob1D1 nBxtsiTiITgQ91OZQsHa64naJBtDK4v0/ZoMgPAwcpWhCxP7kf3zWjEtFREkECga9uI3Ru FcbI9mJVfnGJJAvUmNIfsSX3gTPemL91EX1MxHa7kYEMQJ9MFb6c6o2XIe3bREXhix/eCT +dXjoUdkB0kuqO7W/HuNHbxWn5iHTG2gJGEuEZG1GmTKuA7lG+CiXsuMRYjfGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750683810; a=rsa-sha256; cv=none; b=SYujP/v5Yj1u+8ZVoUE6mh9u+9C4AbWYqzEDhvCmFfogWN5vhseESSjiae4aQNCG98U5Uz 4IXzUDV4EXrX4Mp8du1X8OSfQ5cCJZ2/9qGIUoRlyvy6v763lBHcnUoT/zhw22SZcGh9GP wQ7C8ZcTwXF0wZhK8w9MmDN0Oh1D0AUK2GiWgqYPgbwCPqztILkM6yKcO3ocofdFXDv5t3 5MIGk28Ddse0yGc0hudREWuSRip38zaaG2XB6Ii9K1Pt+q+/GwKAnqLBwvBb1mzrMh191m GiktYYnh5lELJYKaXT+3P8U7t5s7Y5EipgqcaroJ7c93iyk3/C6SP5clb2GR7w== 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 4bQpDL18LLz13VL; Mon, 23 Jun 2025 13:03:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55ND3Uat070759; Mon, 23 Jun 2025 13:03:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55ND3Uqr070756; Mon, 23 Jun 2025 13:03:30 GMT (envelope-from git) Date: Mon, 23 Jun 2025 13:03:30 GMT Message-Id: <202506231303.55ND3Uqr070756@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 0a5b763d98b9 - main - libc: Rename fscandir{,_b}() to fdscandir{,_b}(). List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0a5b763d98b921f921243525ff25a70bbe00cfaa Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=0a5b763d98b921f921243525ff25a70bbe00cfaa commit 0a5b763d98b921f921243525ff25a70bbe00cfaa Author: Dag-Erling Smørgrav AuthorDate: 2025-06-23 13:02:53 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2025-06-23 13:03:10 +0000 libc: Rename fscandir{,_b}() to fdscandir{,_b}(). This seems to fit the pattern better (e.g. fdopendir()). I've added weak references to ease the transition, but since it's only been a few days, we can remove them (and the ObsoleteFiles entries for the manual pages) before we branch stable/15. Fixes: deeebfdecab5 Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D50980 --- ObsoleteFiles.inc | 4 ++++ include/dirent.h | 4 ++-- lib/libc/gen/Makefile.inc | 4 ++-- lib/libc/gen/Symbol.map | 2 ++ lib/libc/gen/scandir.3 | 28 ++++++++++++++-------------- lib/libc/gen/scandir.c | 14 ++++++++++---- lib/libc/tests/gen/scandir_blocks_test.c | 12 ++++++------ lib/libc/tests/gen/scandir_test.c | 12 ++++++------ usr.bin/diff/diffdir.c | 2 +- 9 files changed, 47 insertions(+), 35 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 3dc879fe5b0b..cab8949b635b 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -51,6 +51,10 @@ # xargs -n1 | sort | uniq -d; # done +# 20250623: fscandir() renamed to fdscandir() +OLD_FILES+=usr/share/man/man3/fscandir.3.gz +OLD_FILES+=usr/share/man/man3/fscandir_b.3.gz + # 20250615: don't install man page for absent function OLD_FILES+=usr/share/man/man9/vm_map_simplify_entry.9.gz diff --git a/include/dirent.h b/include/dirent.h index 00319c0a8bd0..dff0e8675722 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -130,11 +130,11 @@ int scandir_b(const char *, struct dirent ***, #endif #endif #if __BSD_VISIBLE -int fscandir(int, struct dirent ***, +int fdscandir(int, struct dirent ***, int (*)(const struct dirent *), int (*)(const struct dirent **, const struct dirent **)); #ifdef __BLOCKS__ -int fscandir_b(int, struct dirent ***, +int fdscandir_b(int, struct dirent ***, int (^)(const struct dirent *), int (^)(const struct dirent **, const struct dirent **)); #endif diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc index f2f5afbb24d8..ad13aaa65621 100644 --- a/lib/libc/gen/Makefile.inc +++ b/lib/libc/gen/Makefile.inc @@ -499,8 +499,8 @@ MLINKS+=rand48.3 _rand48.3 \ MLINKS+=rtld_get_var.3 \ rtld_set_var.3 MLINKS+=scandir.3 alphasort.3 \ - scandir.3 fscandir.3 \ - scandir.3 fscandir_b.3 \ + scandir.3 fdscandir.3 \ + scandir.3 fdscandir_b.3 \ scandir.3 scandir_b.3 \ scandir.3 scandirat.3 \ scandir.3 scandirat_b.3 \ diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map index e7483d3e6ec2..8faecf4b3048 100644 --- a/lib/libc/gen/Symbol.map +++ b/lib/libc/gen/Symbol.map @@ -460,6 +460,8 @@ FBSD_1.8 { execvpe; fscandir; fscandir_b; + fdscandir; + fdscandir_b; fts_open_b; glob_b; psiginfo; diff --git a/lib/libc/gen/scandir.3 b/lib/libc/gen/scandir.3 index 21df9316d511..9ced9fa4ef9d 100644 --- a/lib/libc/gen/scandir.3 +++ b/lib/libc/gen/scandir.3 @@ -30,11 +30,11 @@ .Os .Sh NAME .Nm scandir , -.Nm fscandir , +.Nm fdscandir , .Nm scandirat , .Nm scandir_b , -.Nm fscandir_b , -.Nm fscandirat_b , +.Nm fdscandir_b , +.Nm fdscandirat_b , .Nm alphasort , .Nm versionsort .Nd scan a directory @@ -50,7 +50,7 @@ .Fa "int \*(lp*compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp" .Fc .Ft int -.Fo fscandir +.Fo fdscandir .Fa "int dirfd" .Fa "struct dirent ***namelist" .Fa "int \*(lp*select\*(rp\*(lpconst struct dirent *\*(rp" @@ -72,7 +72,7 @@ .Fa "int \*(lp^compar\*(rp\*(lpconst struct dirent **, const struct dirent **\*(rp" .Fc .Ft int -.Fo fscandir_b +.Fo fdscandir_b .Fa "int dirfd" .Fa "struct dirent ***namelist" .Fa "int \*(lp^select\*(rp\*(lpconst struct dirent *\*(rp" @@ -144,7 +144,7 @@ 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 fscandir +.Fn fdscandir function is similar to .Fn scandir , but takes a file descriptor referencing a directory instead of a path. @@ -185,12 +185,12 @@ for additional details. .Pp The .Fn scandir_b , -.Fn fscandir_b , +.Fn fdscandir_b , and .Fn scandirat_b functions behave in the same way as .Fn scandir , -.Fn fscandir , +.Fn fdscandir , and .Fn scandirat , respectively, @@ -201,10 +201,10 @@ rather than .Sh DIAGNOSTICS The .Fn scandir , -.Fn fscandir , +.Fn fdscandir , .Fn scandirat , .Fn scandir_b , -.Fn fscandir_b , +.Fn fdscandir_b , and .Fn scandirat_b functions return the number of directory entries found on succes. @@ -236,9 +236,9 @@ and .Fn versionsort functions are GNU extensions and conform to no standard. The -.Fn fscandir , +.Fn fdscandir , .Fn scandir_b , -.Fn fscandir_b , +.Fn fdscandir_b , and .Fn scandirat_b functions are @@ -262,8 +262,8 @@ and functions were added in .Fx 13.2 . The -.Fn fscandir , -.Fn fscandir_b , +.Fn fdscandir , +.Fn fdscandir_b , and .Fn scandirat_b functions were added in diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c index d8033a985862..134c88713d39 100644 --- a/lib/libc/gen/scandir.c +++ b/lib/libc/gen/scandir.c @@ -159,10 +159,10 @@ scandir(const char *dirname, struct dirent ***namelist, int #ifdef I_AM_SCANDIR_B -fscandir_b(int dirfd, struct dirent ***namelist, select_block select, +fdscandir_b(int dirfd, struct dirent ***namelist, select_block select, dcomp_block dcomp) #else -fscandir(int dirfd, struct dirent ***namelist, +fdscandir(int dirfd, struct dirent ***namelist, int (*select)(const struct dirent *), int (*dcomp)(const struct dirent **, const struct dirent **)) #endif @@ -203,9 +203,9 @@ scandirat(int dirfd, const char *dirname, struct dirent ***namelist, return (-1); ret = #ifdef I_AM_SCANDIR_B - fscandir_b + fdscandir_b #else - fscandir + fdscandir #endif (fd, namelist, select, dcomp); serrno = errno; @@ -242,3 +242,9 @@ scandir_thunk_cmp(const void *p1, const void *p2, void *thunk) return (dc((const struct dirent **)p1, (const struct dirent **)p2)); } #endif + +#ifdef I_AM_SCANDIR_B +__weak_reference(fdscandir_b, fscandir_b); +#else +__weak_reference(fdscandir, fscandir); +#endif diff --git a/lib/libc/tests/gen/scandir_blocks_test.c b/lib/libc/tests/gen/scandir_blocks_test.c index 28aeef4e7d4c..b94270bc410e 100644 --- a/lib/libc/tests/gen/scandir_blocks_test.c +++ b/lib/libc/tests/gen/scandir_blocks_test.c @@ -57,19 +57,19 @@ ATF_TC_BODY(scandir_b_test, tc) free(namelist); } -ATF_TC(fscandir_b_test); -ATF_TC_HEAD(fscandir_b_test, tc) +ATF_TC(fdscandir_b_test); +ATF_TC_HEAD(fdscandir_b_test, tc) { - atf_tc_set_md_var(tc, "descr", "Test fscandir_b()"); + atf_tc_set_md_var(tc, "descr", "Test fdscandir_b()"); } -ATF_TC_BODY(fscandir_b_test, tc) +ATF_TC_BODY(fdscandir_b_test, tc) { struct dirent **namelist = NULL; int fd, i, ret; scandir_blocks_prepare(tc); ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0); - ret = fscandir_b(fd, &namelist, + ret = fdscandir_b(fd, &namelist, ^(const struct dirent *ent) { return (strcmp(ent->d_name, "skip") != 0); }, @@ -112,7 +112,7 @@ ATF_TC_BODY(scandirat_b_test, tc) ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, scandir_b_test); - ATF_TP_ADD_TC(tp, fscandir_b_test); + ATF_TP_ADD_TC(tp, fdscandir_b_test); ATF_TP_ADD_TC(tp, scandirat_b_test); return (atf_no_error()); } diff --git a/lib/libc/tests/gen/scandir_test.c b/lib/libc/tests/gen/scandir_test.c index dcd73fe94df5..9a9940aca881 100644 --- a/lib/libc/tests/gen/scandir_test.c +++ b/lib/libc/tests/gen/scandir_test.c @@ -63,19 +63,19 @@ ATF_TC_BODY(scandir_test, tc) free(namelist); } -ATF_TC(fscandir_test); -ATF_TC_HEAD(fscandir_test, tc) +ATF_TC(fdscandir_test); +ATF_TC_HEAD(fdscandir_test, tc) { - atf_tc_set_md_var(tc, "descr", "Test fscandir()"); + atf_tc_set_md_var(tc, "descr", "Test fdscandir()"); } -ATF_TC_BODY(fscandir_test, tc) +ATF_TC_BODY(fdscandir_test, tc) { struct dirent **namelist = NULL; int fd, i, ret; scandir_prepare(tc); ATF_REQUIRE((fd = open("dir", O_DIRECTORY | O_RDONLY)) >= 0); - ret = fscandir(fd, &namelist, scandir_select, scandir_compare); + ret = fdscandir(fd, &namelist, scandir_select, scandir_compare); scandir_verify(tc, ret, namelist); for (i = 0; i < ret; i++) free(namelist[i]); @@ -127,7 +127,7 @@ ATF_TC_BODY(scandir_none, tc) ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, scandir_test); - ATF_TP_ADD_TC(tp, fscandir_test); + ATF_TP_ADD_TC(tp, fdscandir_test); ATF_TP_ADD_TC(tp, scandirat_test); ATF_TP_ADD_TC(tp, scandir_none); return (atf_no_error()); diff --git a/usr.bin/diff/diffdir.c b/usr.bin/diff/diffdir.c index fb76a5768e1a..a55a2bec70ee 100644 --- a/usr.bin/diff/diffdir.c +++ b/usr.bin/diff/diffdir.c @@ -83,7 +83,7 @@ vscandir(struct inodetree *tree, const char *path, struct dirent ***dirp, *dirp = NULL; return (0); } - if ((ret = fscandir(fd, dirp, selectf, comparf)) < 0) + if ((ret = fdscandir(fd, dirp, selectf, comparf)) < 0) goto fail; RB_INSERT(inodetree, tree, ino); close(fd);