]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xdrgen: Implement pass-through lines in specifications
authorChuck Lever <chuck.lever@oracle.com>
Fri, 9 Jan 2026 16:21:30 +0000 (11:21 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Thu, 29 Jan 2026 14:48:33 +0000 (09:48 -0500)
commit6bc85baba4b08c787a8c9ba1bb0252a83e5c5603
treed0f676c8dd3dfb2355f6b2b7933ed18b313bedb9
parent3daab3112f039cf849f96764019b096bb0a39d04
xdrgen: Implement pass-through lines in specifications

XDR specification files can contain lines prefixed with '%' that
pass through unchanged to generated output. Traditional rpcgen
removes the '%' and emits the remainder verbatim, allowing direct
insertion of C includes, pragma directives, or other language-
specific content into the generated code.

Until now, xdrgen silently discarded these lines during parsing.
This prevented specifications from including necessary headers or
preprocessor directives that might be required for the generated
code to compile correctly.

The grammar now captures pass-through lines instead of ignoring
them. A new AST node type represents pass-through content, and
the AST transformer strips the leading '%' character. Definition
and source generators emit pass-through content in document order,
preserving the original placement within the specification.

This brings xdrgen closer to feature parity with traditional
rpcgen while maintaining the existing document-order processing
model.

Existing generated xdrgen source code has been regenerated.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
12 files changed:
fs/nfsd/nfs4xdr_gen.c
fs/nfsd/nfs4xdr_gen.h
include/linux/sunrpc/xdrgen/nfs4_1.h
tools/net/sunrpc/xdrgen/README
tools/net/sunrpc/xdrgen/generators/passthru.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/grammars/xdr.lark
tools/net/sunrpc/xdrgen/subcmds/declarations.py
tools/net/sunrpc/xdrgen/subcmds/definitions.py
tools/net/sunrpc/xdrgen/subcmds/source.py
tools/net/sunrpc/xdrgen/templates/C/passthru/definition.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/passthru/source.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/xdr_ast.py