From cdd6bb09f31033e3b1f3a0d628de2bc346b3f8eb Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 5 Oct 2025 20:38:30 +0200 Subject: [PATCH] Define _CS_PATH on the BSDs According to https://man.netbsd.org/confstr.3 _CS_PATH is obsoleted by sysctl (which has a USER_CS_PATH equivalent), but Linux doesn't have that. So the simplest thing for applications is to use _CS_PATH which is part of POSIX. Define, matching the header. We could maybe share this definition in src/unix/bsd/netbsdlike/mod.rs, but I saw that existing definitions are not shared either, so I'm not sure. $ grep src/unix/bsd/netbsdlike -e _PC_LINK_MAX src/unix/bsd/netbsdlike/netbsd/mod.rs:1599:11:pub const _PC_LINK_MAX: c_int = 1; src/unix/bsd/netbsdlike/openbsd/mod.rs:1193:11:pub const _PC_LINK_MAX: c_int = 1; Originally reported in https://github.com/fish-shell/fish-shell/issues/11892 --- libc-test/semver/dragonfly.txt | 1 + libc-test/semver/freebsd.txt | 1 + libc-test/semver/netbsd.txt | 1 + libc-test/semver/openbsd.txt | 1 + src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 ++ src/unix/bsd/freebsdlike/mod.rs | 2 ++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 ++ src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 ++ 8 files changed, 12 insertions(+) diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 31c40372f195c..6c2a3a0d2e4e0 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1128,6 +1128,7 @@ WTRAPPED XUCRED_VERSION YESEXPR YESSTR +_CS_PATH _IOFBF _IOLBF _IONBF diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index be24fc9fe9efe..b2d06b1166a94 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1715,6 +1715,7 @@ XUCRED_VERSION XU_NGROUPS YESEXPR YESSTR +_CS_PATH _IOFBF _IOLBF _IONBF diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 4280ec02de730..5821466cc8ddf 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1127,6 +1127,7 @@ XATTR_CREATE XATTR_REPLACE YESEXPR YESSTR +_CS_PATH _IO _IOC _IOFBF diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 6e452dadea797..97ad85dfc3286 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -917,6 +917,7 @@ WSTOPPED WTRAPPED YESEXPR YESSTR +_CS_PATH _IO _IOC _IOFBF diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index fb6b0fca02aeb..4ade5e7378660 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1361,6 +1361,8 @@ pub const VCHECKPT: usize = 19; pub const _PC_2_SYMLINKS: c_int = 22; pub const _PC_TIMESTAMP_RESOLUTION: c_int = 23; +pub const _CS_PATH: c_int = 1; + pub const _SC_V7_ILP32_OFF32: c_int = 122; pub const _SC_V7_ILP32_OFFBIG: c_int = 123; pub const _SC_V7_LP64_OFF64: c_int = 124; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 5dabe047633f0..9a04316808b01 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1197,6 +1197,8 @@ pub const _SC_RAW_SOCKETS: c_int = 119; pub const _SC_SYMLOOP_MAX: c_int = 120; pub const _SC_PHYS_PAGES: c_int = 121; +pub const _CS_PATH: c_int = 1; + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 07532c84dfbaf..19c162d0f6cc6 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1612,6 +1612,8 @@ pub const _PC_2_SYMLINKS: c_int = 13; pub const _PC_ACL_EXTENDED: c_int = 14; pub const _PC_MIN_HOLE_SIZE: c_int = 15; +pub const _CS_PATH: c_int = 1; + pub const _SC_SYNCHRONIZED_IO: c_int = 31; pub const _SC_IOV_MAX: c_int = 32; pub const _SC_MAPPED_FILES: c_int = 33; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index df4eb22337810..402917d551fa6 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1212,6 +1212,8 @@ pub const _PC_SYMLINK_MAX: c_int = 19; pub const _PC_SYNC_IO: c_int = 20; pub const _PC_TIMESTAMP_RESOLUTION: c_int = 21; +pub const _CS_PATH: c_int = 1; + pub const _SC_CLK_TCK: c_int = 3; pub const _SC_SEM_NSEMS_MAX: c_int = 31; pub const _SC_SEM_VALUE_MAX: c_int = 32;