From nobody Thu May 07 05:02:55 2026 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 4gB0W43m78z6dSvY for ; Thu, 07 May 2026 05:02:56 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gB0W35Chgz3vlT for ; Thu, 07 May 2026 05:02:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778130175; 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=32RCz/jlZOMPsR+cpxuzQo3PcH5s9RQ6Elt+Kq6yEvc=; b=L227mHiTs2Ac2lhpK83fTJD83+AA8IO0ogg8rzJZYXJ9uNDy7HI2kjvUbSIi0HSs+wMYrY asPORxHyUIn2IlHPzXIblgKbNXa2GnleNG0FGy/uClt8+0kKV5y1/1aR3nvd5k4EdNVWva SXIzS/AXAfEigV6kr3jzTEI6r6vLd9C7Zadu5uW7Wk+J6JTusq0lTlT5fmiqZhN6VJSOI0 jUrsF7O1hmP4p7XWbT4i9HnxSIeTYy/YS4baRgzGQyoghM4GDJtIwzIiCnwJJtl5lAM26Q 03OPmCYzQ/vWPwhqAtUWSebQIxCexdifwxRCi1oZIjEmENvQSwAGSRluROdkbA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1778130175; a=rsa-sha256; cv=none; b=NxVgp3Cpo7H/tTUtYWlguOAr22nqvKv5GC/lEFVeLf6RaG5F/z98ykpHmKWqdWJwSiVf3H prrFPDyZCd6zibCeWnm32GzAeS19Rc/vlVZ/xyCdjvao9CX4XyoONfSSoy5P+hb1/NJ25u 7fDDG8i/yPrDYfFuyT+x7DUdsm+8mzbzBPCbteE6vR8PWdpjV5SHD+slLjxf1Uwwx1LVvd nviqu9jt8AV5ARgo435YAfB0uK/STNcTysUf7CY1KI6lxzIZIi2bIrRBc0xjF07QygN1Cz PqDqJPom9jYZjivjNJDpOWs4+venSERA1hkGu1Utp9yiQKZHtCwd+AXnZAkWBw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1778130175; 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=32RCz/jlZOMPsR+cpxuzQo3PcH5s9RQ6Elt+Kq6yEvc=; b=cpxoBPQsHCaF2qC4OLUoUjiJRET4ZSkDLjcNHsySCSZJVclf/ZtWC7OSnnrw/miyO7sO31 PlepZSCr0IK5bq7fov0eeBp4YsZKgq8JHmxxWJmpDTEU4DVy4tWLZwWZk0vUI0ivQNSmQ7 q8aWdpRCWiMVQH8vVyGub+nOSDNt4CDG7sogbwLEeBNywNc8o0lKaDFd+HKb0PBP+0eLpb HTTRb1jaS5wV01IbaMWF7zKCLV8DbSZhK4NMeT9/qzeki91KKDJoeiSXn5PEg8Y4SscHfa Z47bmFr7SHgXNskAPhRNwn+ihwTEzqqRYLH5rD/uCBl2fKcme29ztU1Xt5FheQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gB0W33zFJz1B8j for ; Thu, 07 May 2026 05:02:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 348c0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 07 May 2026 05:02:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alex Richardson Subject: git: 96b2f4a91241 - main - p9fs: implement basic pathconf support 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: arichardson X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 96b2f4a9124158f27c4c27c32f6fa1a6018250fb Auto-Submitted: auto-generated Date: Thu, 07 May 2026 05:02:55 +0000 Message-Id: <69fc1cff.348c0.5473ab52@gitrepo.freebsd.org> The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=96b2f4a9124158f27c4c27c32f6fa1a6018250fb commit 96b2f4a9124158f27c4c27c32f6fa1a6018250fb Author: Alex Richardson AuthorDate: 2026-05-07 04:22:23 +0000 Commit: Alex Richardson CommitDate: 2026-05-07 04:23:04 +0000 p9fs: implement basic pathconf support This is needed for various pjdfstest tests which fail with syntax errors if pathconf _PC_NAME_MAX/_PC_PATH_MAX return -1. For NAME_MAX we can use the 9P2000.L Tstatfs call to get namelen from the host. While this could theoretically be different for nested filesystems in the shared mount it is a much better guess than just returning 255. There does not seem to be a way to get the host PATH_MAX, so we just return the conservative kernel default. Found while fixing https://github.com/CTSRD-CHERI/cheribsd/issues/2617. Reviewed by: markj, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56493 --- sys/fs/p9fs/p9fs.h | 1 + sys/fs/p9fs/p9fs_vnops.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/sys/fs/p9fs/p9fs.h b/sys/fs/p9fs/p9fs.h index 2470734fef4d..b469495ef69e 100644 --- a/sys/fs/p9fs/p9fs.h +++ b/sys/fs/p9fs/p9fs.h @@ -154,6 +154,7 @@ struct p9fs_session { struct mtx p9fs_mtx; /* mutex used for guarding the chain.*/ STAILQ_HEAD( ,p9fs_node) virt_node_list; /* list of p9fs nodes in this session*/ struct p9_fid *mnt_fid; /* to save nobody 's fid for unmounting as root user */ + unsigned int name_max; /* cached max filename length */ }; struct p9fs_mount { diff --git a/sys/fs/p9fs/p9fs_vnops.c b/sys/fs/p9fs/p9fs_vnops.c index 7141e9700602..ad739a219acb 100644 --- a/sys/fs/p9fs/p9fs_vnops.c +++ b/sys/fs/p9fs/p9fs_vnops.c @@ -37,10 +37,12 @@ #include #include #include -#include -#include #include +#include +#include +#include #include +#include #include #include @@ -2248,6 +2250,72 @@ p9fs_delayed_setsize(struct vop_delayed_setsize_args *ap) return (0); } +static unsigned int +p9fs_get_name_max(struct p9fs_node *np) +{ + struct p9fs_session *vses = np->p9fs_ses; + struct p9_statfs statfs; + struct p9_fid *vfid; + unsigned int name_max; + int error = 0; + + name_max = atomic_load_int(&vses->name_max); + if (name_max != 0) + return (name_max); + + P9_DEBUG(VOPS, "%s: querying _PC_NAME_MAX\n", __func__); + vfid = p9fs_get_fid(vses->clnt, np, NULL, VFID, -1, &error); + if (vfid != NULL) { + error = p9_client_statfs(vfid, &statfs); + if (error == 0) { + /* + * Note that this is not strictly correct if you have + * nested mounts on the host (e.g. when using qemu with + * multidevs=remap), but is a better estimate than just + * returning 255. + */ + name_max = statfs.namelen; + } + } + P9_DEBUG(VOPS, "%s: max_name=%u error=%d\n", __func__, name_max, error); + if (error != 0 || name_max == 0) { + printf("p9fs: warning: failed to query name_max (error %d), " + "using fallback %d\n", error, NAME_MAX); + name_max = NAME_MAX; /* fallback and prevent retrying */ + } + atomic_store_int(&vses->name_max, name_max); + return (name_max); +} + +/* + * Return POSIX pathconf information applicable to p9fs filesystems. + */ +static int +p9fs_pathconf(struct vop_pathconf_args *ap) +{ + int error = 0; + struct vnode *vp = ap->a_vp; + struct p9fs_node *np = P9FS_VTON(vp); + + switch (ap->a_name) { + case _PC_NAME_MAX: + *ap->a_retval = p9fs_get_name_max(np); + break; + case _PC_SYMLINK_MAX: + case _PC_PATH_MAX: + /* + * These are conservative estimates, the real value depends on + * the host file system. + */ + *ap->a_retval = MAXPATHLEN; + break; + default: + error = vop_stdpathconf(ap); + break; + } + return (error); +} + struct vop_vector p9fs_vnops = { .vop_default = &default_vnodeops, .vop_lookup = p9fs_lookup, @@ -2257,6 +2325,7 @@ struct vop_vector p9fs_vnops = { .vop_delayed_setsize = p9fs_delayed_setsize, .vop_getattr = p9fs_getattr_dotl, .vop_setattr = p9fs_setattr_dotl, + .vop_pathconf = p9fs_pathconf, .vop_reclaim = p9fs_reclaim, .vop_inactive = p9fs_inactive, .vop_readdir = p9fs_readdir,