xdrgen - machine-generated XDR functions
Subsystems (3)
[email protected]
maintainercover xdrgen - machine-generated XDR functions
From: Chuck Lever <[email protected]>
For a description of this work-in-progress, see the new README file. For unfinished work items, ditto.
The first patch adds the tool.
The second patch is an nfs4_1.x file that I created to confirm that the tool indeed works for Jeff's purposes. Actual generated header and source are in fs/nfsd/nfs4xdr_gen.? .
Feel free to ignore 2/2. It is included here only to demonstrate the tool's new "pragma" directives that I think can avoid the need to hand-edit generated source, as discussed in an earlier thread. Grep the new README or nfs4_1.x for "pragma".
These patches apply to v6.11-rc4, but can be rebased on nfsd-next if they are found merge-worthy. See also:
https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=lkxdrgen
For review, note that the numerous .j2 files are all tiny and can be skimmed in favor of the .py files, where the tool's logic is.
All Python-related advice and guidance is gratefully accepted.
--
Chuck Lever (2):
tools: Add xdrgen
NFSD: Create an initial nfs4_1.x file
fs/nfsd/nfs4_1.x | 164 +++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 +++++ include/linux/sunrpc/xdrgen-builtins.h | 253 ++++++++++ tools/net/sunrpc/xdrgen/.gitignore | 2 + tools/net/sunrpc/xdrgen/README | 231 +++++++++ tools/net/sunrpc/xdrgen/__init__.py | 0 tools/net/sunrpc/xdrgen/common.py | 21 + .../net/sunrpc/xdrgen/generators/__init__.py | 0 .../sunrpc/xdrgen/generators/boilerplate.py | 66 +++ .../net/sunrpc/xdrgen/generators/constant.py | 38 ++ tools/net/sunrpc/xdrgen/generators/enum.py | 67 +++ tools/net/sunrpc/xdrgen/generators/program.py | 96 ++++ tools/net/sunrpc/xdrgen/generators/struct.py | 435 +++++++++++++++++ tools/net/sunrpc/xdrgen/generators/typedef.py | 282 +++++++++++ tools/net/sunrpc/xdrgen/generators/union.py | 297 ++++++++++++ tools/net/sunrpc/xdrgen/subcmds/__init__.py | 0 tools/net/sunrpc/xdrgen/subcmds/header.py | 62 +++ tools/net/sunrpc/xdrgen/subcmds/lint.py | 28 ++ tools/net/sunrpc/xdrgen/subcmds/source.py | 82 ++++ .../templates/C/boilerplate/header_bottom.j2 | 3 + .../templates/C/boilerplate/header_top.j2 | 11 + .../templates/C/boilerplate/source_top.j2 | 5 + .../templates/C/constants/declaration.j2 | 5 + .../templates/C/enum/declaration/close.j2 | 7 + .../C/enum/declaration/enumerator.j2 | 2 + .../templates/C/enum/declaration/open.j2 | 3 + .../xdrgen/templates/C/enum/decoder/enum.j2 | 19 + .../xdrgen/templates/C/enum/encoder/enum.j2 | 14 + .../C/program/declaration/argument.j2 | 2 + .../templates/C/program/declaration/result.j2 | 2 + .../templates/C/program/decoder/argument.j2 | 21 + .../templates/C/program/encoder/result.j2 | 21 + .../templates/C/struct/declaration/basic.j2 | 5 + .../templates/C/struct/declaration/close.j2 | 7 + .../struct/declaration/fixed_length_array.j2 | 5 + .../struct/declaration/fixed_length_opaque.j2 | 5 + .../templates/C/struct/declaration/open.j2 | 6 + .../C/struct/declaration/optional_data.j2 | 5 + .../C/struct/declaration/pointer-open.j2 | 6 + .../declaration/variable_length_array.j2 | 8 + .../declaration/variable_length_opaque.j2 | 5 + .../declaration/variable_length_string.j2 | 5 + .../templates/C/struct/decoder/basic.j2 | 6 + .../templates/C/struct/decoder/close.j2 | 3 + .../C/struct/decoder/fixed_length_array.j2 | 8 + .../C/struct/decoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/decoder/open.j2 | 12 + .../C/struct/decoder/optional_data.j2 | 6 + .../C/struct/decoder/pointer-open.j2 | 22 + .../C/struct/decoder/variable_length_array.j2 | 13 + .../struct/decoder/variable_length_opaque.j2 | 6 + .../struct/decoder/variable_length_string.j2 | 6 + .../templates/C/struct/encoder/basic.j2 | 10 + .../templates/C/struct/encoder/close.j2 | 3 + .../C/struct/encoder/fixed_length_array.j2 | 12 + .../C/struct/encoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/encoder/open.j2 | 12 + .../C/struct/encoder/optional_data.j2 | 6 + .../C/struct/encoder/pointer-open.j2 | 20 + .../C/struct/encoder/variable_length_array.j2 | 15 + .../struct/encoder/variable_length_opaque.j2 | 8 + .../struct/encoder/variable_length_string.j2 | 8 + .../templates/C/typedef/declaration/basic.j2 | 11 + .../typedef/declaration/fixed_length_array.j2 | 11 + .../declaration/fixed_length_opaque.j2 | 11 + .../declaration/variable_length_array.j2 | 14 + .../declaration/variable_length_opaque.j2 | 11 + .../declaration/variable_length_string.j2 | 11 + .../templates/C/typedef/decoder/basic.j2 | 17 + .../C/typedef/decoder/fixed_length_array.j2 | 25 + .../C/typedef/decoder/fixed_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_array.j2 | 26 ++ .../typedef/decoder/variable_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_string.j2 | 17 + .../templates/C/typedef/encoder/basic.j2 | 21 + .../C/typedef/encoder/fixed_length_array.j2 | 25 + .../C/typedef/encoder/fixed_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_array.j2 | 30 ++ .../typedef/encoder/variable_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_string.j2 | 17 + .../C/union/declaration/case_spec.j2 | 2 + .../templates/C/union/declaration/close.j2 | 8 + .../C/union/declaration/default_spec.j2 | 2 + .../templates/C/union/declaration/open.j2 | 6 + .../C/union/declaration/switch_spec.j2 | 3 + .../xdrgen/templates/C/union/decoder/basic.j2 | 6 + .../xdrgen/templates/C/union/decoder/break.j2 | 2 + .../templates/C/union/decoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/close.j2 | 4 + .../templates/C/union/decoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/open.j2 | 12 + .../C/union/decoder/optional_data.j2 | 6 + .../templates/C/union/decoder/switch_spec.j2 | 7 + .../C/union/decoder/variable_length_array.j2 | 13 + .../C/union/decoder/variable_length_opaque.j2 | 6 + .../C/union/decoder/variable_length_string.j2 | 6 + .../xdrgen/templates/C/union/decoder/void.j2 | 3 + .../xdrgen/templates/C/union/encoder/basic.j2 | 10 + .../xdrgen/templates/C/union/encoder/break.j2 | 2 + .../templates/C/union/encoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/close.j2 | 4 + .../templates/C/union/encoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/open.j2 | 12 + .../templates/C/union/encoder/switch_spec.j2 | 7 + .../xdrgen/templates/C/union/encoder/void.j2 | 3 + tools/net/sunrpc/xdrgen/tests/test.x | 36 ++ tools/net/sunrpc/xdrgen/xdr | 1 + tools/net/sunrpc/xdrgen/xdr.ebnf | 117 +++++ tools/net/sunrpc/xdrgen/xdr_ast.py | 437 ++++++++++++++++++ tools/net/sunrpc/xdrgen/xdr_parse.py | 20 + tools/net/sunrpc/xdrgen/xdrgen | 95 ++++ 112 files changed, 3986 insertions(+) create mode 100644 fs/nfsd/nfs4_1.x create mode 100644 fs/nfsd/nfs4xdr_gen.c create mode 100644 fs/nfsd/nfs4xdr_gen.h create mode 100644 include/linux/sunrpc/xdrgen-builtins.h create mode 100644 tools/net/sunrpc/xdrgen/.gitignore create mode 100644 tools/net/sunrpc/xdrgen/README create mode 100644 tools/net/sunrpc/xdrgen/__init__.py create mode 100644 tools/net/sunrpc/xdrgen/common.py create mode 100644 tools/net/sunrpc/xdrgen/generators/__init__.py create mode 100644 tools/net/sunrpc/xdrgen/generators/boilerplate.py create mode 100644 tools/net/sunrpc/xdrgen/generators/constant.py create mode 100644 tools/net/sunrpc/xdrgen/generators/enum.py create mode 100644 tools/net/sunrpc/xdrgen/generators/program.py create mode 100644 tools/net/sunrpc/xdrgen/generators/struct.py create mode 100644 tools/net/sunrpc/xdrgen/generators/typedef.py create mode 100644 tools/net/sunrpc/xdrgen/generators/union.py create mode 100644 tools/net/sunrpc/xdrgen/subcmds/__init__.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/header.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/lint.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/source.py create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_bottom.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_top.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/source_top.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/constants/declaration.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enumerator.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2 create mode 100644 tools/net/sunrpc/xdrgen/tests/test.x create mode 120000 tools/net/sunrpc/xdrgen/xdr create mode 100644 tools/net/sunrpc/xdrgen/xdr.ebnf create mode 100644 tools/net/sunrpc/xdrgen/xdr_ast.py create mode 100644 tools/net/sunrpc/xdrgen/xdr_parse.py create mode 100755 tools/net/sunrpc/xdrgen/xdrgen
Signature · 1 line
2.45.1
[email protected]
maintainerRFC PATCH 1/2 tools: Add xdrgen
From: Chuck Lever <[email protected]>
Add a Python-based tool for translating XDR specifications into XDR encoder and decoder functions written in the Linux kernel's C coding style. The generator attempts to match the usual C coding style of the Linux kernel's sunrpc/ layer.
This approach is similar to the netlink code generator in tools/net/ynl .
The maintainability benefits of machine-generated XDR code include:
- Stronger type checking
- Reduces the number of bugs introduced by human error
- Makes the XDR code easier to audit and analyze
- Enables rapid prototyping of new RPC-based protocols
- Hardens the layering between protocol logic and marshaling
- Makes it easier to add observability on demand
- Unit tests might be built for both the tool and (automatically) for the generated code
In addition, converting the XDR layer to use memory-safe languages such as Rust will be easier if much of the code can be converted automatically.
--- include/linux/sunrpc/xdrgen-builtins.h | 253 ++++++++++ tools/net/sunrpc/xdrgen/.gitignore | 2 + tools/net/sunrpc/xdrgen/README | 231 +++++++++ tools/net/sunrpc/xdrgen/__init__.py | 0 tools/net/sunrpc/xdrgen/common.py | 21 + .../net/sunrpc/xdrgen/generators/__init__.py | 0 .../sunrpc/xdrgen/generators/boilerplate.py | 66 +++ .../net/sunrpc/xdrgen/generators/constant.py | 38 ++ tools/net/sunrpc/xdrgen/generators/enum.py | 67 +++ tools/net/sunrpc/xdrgen/generators/program.py | 96 ++++ tools/net/sunrpc/xdrgen/generators/struct.py | 435 +++++++++++++++++ tools/net/sunrpc/xdrgen/generators/typedef.py | 282 +++++++++++ tools/net/sunrpc/xdrgen/generators/union.py | 297 ++++++++++++ tools/net/sunrpc/xdrgen/subcmds/__init__.py | 0 tools/net/sunrpc/xdrgen/subcmds/header.py | 62 +++ tools/net/sunrpc/xdrgen/subcmds/lint.py | 28 ++ tools/net/sunrpc/xdrgen/subcmds/source.py | 82 ++++ .../templates/C/boilerplate/header_bottom.j2 | 3 + .../templates/C/boilerplate/header_top.j2 | 11 + .../templates/C/boilerplate/source_top.j2 | 5 + .../templates/C/constants/declaration.j2 | 5 + .../templates/C/enum/declaration/close.j2 | 7 + .../C/enum/declaration/enumerator.j2 | 2 + .../templates/C/enum/declaration/open.j2 | 3 + .../xdrgen/templates/C/enum/decoder/enum.j2 | 19 + .../xdrgen/templates/C/enum/encoder/enum.j2 | 14 + .../C/program/declaration/argument.j2 | 2 + .../templates/C/program/declaration/result.j2 | 2 + .../templates/C/program/decoder/argument.j2 | 21 + .../templates/C/program/encoder/result.j2 | 21 + .../templates/C/struct/declaration/basic.j2 | 5 + .../templates/C/struct/declaration/close.j2 | 7 + .../struct/declaration/fixed_length_array.j2 | 5 + .../struct/declaration/fixed_length_opaque.j2 | 5 + .../templates/C/struct/declaration/open.j2 | 6 + .../C/struct/declaration/optional_data.j2 | 5 + .../C/struct/declaration/pointer-open.j2 | 6 + .../declaration/variable_length_array.j2 | 8 + .../declaration/variable_length_opaque.j2 | 5 + .../declaration/variable_length_string.j2 | 5 + .../templates/C/struct/decoder/basic.j2 | 6 + .../templates/C/struct/decoder/close.j2 | 3 + .../C/struct/decoder/fixed_length_array.j2 | 8 + .../C/struct/decoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/decoder/open.j2 | 12 + .../C/struct/decoder/optional_data.j2 | 6 + .../C/struct/decoder/pointer-open.j2 | 22 + .../C/struct/decoder/variable_length_array.j2 | 13 + .../struct/decoder/variable_length_opaque.j2 | 6 + .../struct/decoder/variable_length_string.j2 | 6 + .../templates/C/struct/encoder/basic.j2 | 10 + .../templates/C/struct/encoder/close.j2 | 3 + .../C/struct/encoder/fixed_length_array.j2 | 12 + .../C/struct/encoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/encoder/open.j2 | 12 + .../C/struct/encoder/optional_data.j2 | 6 + .../C/struct/encoder/pointer-open.j2 | 20 + .../C/struct/encoder/variable_length_array.j2 | 15 + .../struct/encoder/variable_length_opaque.j2 | 8 + .../struct/encoder/variable_length_string.j2 | 8 + .../templates/C/typedef/declaration/basic.j2 | 11 + .../typedef/declaration/fixed_length_array.j2 | 11 + .../declaration/fixed_length_opaque.j2 | 11 + .../declaration/variable_length_array.j2 | 14 + .../declaration/variable_length_opaque.j2 | 11 + .../declaration/variable_length_string.j2 | 11 + .../templates/C/typedef/decoder/basic.j2 | 17 + .../C/typedef/decoder/fixed_length_array.j2 | 25 + .../C/typedef/decoder/fixed_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_array.j2 | 26 ++ .../typedef/decoder/variable_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_string.j2 | 17 + .../templates/C/typedef/encoder/basic.j2 | 21 + .../C/typedef/encoder/fixed_length_array.j2 | 25 + .../C/typedef/encoder/fixed_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_array.j2 | 30 ++ .../typedef/encoder/variable_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_string.j2 | 17 + .../C/union/declaration/case_spec.j2 | 2 + .../templates/C/union/declaration/close.j2 | 8 + .../C/union/declaration/default_spec.j2 | 2 + .../templates/C/union/declaration/open.j2 | 6 + .../C/union/declaration/switch_spec.j2 | 3 + .../xdrgen/templates/C/union/decoder/basic.j2 | 6 + .../xdrgen/templates/C/union/decoder/break.j2 | 2 + .../templates/C/union/decoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/close.j2 | 4 + .../templates/C/union/decoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/open.j2 | 12 + .../C/union/decoder/optional_data.j2 | 6 + .../templates/C/union/decoder/switch_spec.j2 | 7 + .../C/union/decoder/variable_length_array.j2 | 13 + .../C/union/decoder/variable_length_opaque.j2 | 6 + .../C/union/decoder/variable_length_string.j2 | 6 + .../xdrgen/templates/C/union/decoder/void.j2 | 3 + .../xdrgen/templates/C/union/encoder/basic.j2 | 10 + .../xdrgen/templates/C/union/encoder/break.j2 | 2 + .../templates/C/union/encoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/close.j2 | 4 + .../templates/C/union/encoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/open.j2 | 12 + .../templates/C/union/encoder/switch_spec.j2 | 7 + .../xdrgen/templates/C/union/encoder/void.j2 | 3 + tools/net/sunrpc/xdrgen/tests/test.x | 36 ++ tools/net/sunrpc/xdrgen/xdr | 1 + tools/net/sunrpc/xdrgen/xdr.ebnf | 117 +++++ tools/net/sunrpc/xdrgen/xdr_ast.py | 437 ++++++++++++++++++ tools/net/sunrpc/xdrgen/xdr_parse.py | 20 + tools/net/sunrpc/xdrgen/xdrgen | 95 ++++ 109 files changed, 3473 insertions(+) create mode 100644 include/linux/sunrpc/xdrgen-builtins.h create mode 100644 tools/net/sunrpc/xdrgen/.gitignore create mode 100644 tools/net/sunrpc/xdrgen/README create mode 100644 tools/net/sunrpc/xdrgen/__init__.py create mode 100644 tools/net/sunrpc/xdrgen/common.py create mode 100644 tools/net/sunrpc/xdrgen/generators/__init__.py create mode 100644 tools/net/sunrpc/xdrgen/generators/boilerplate.py create mode 100644 tools/net/sunrpc/xdrgen/generators/constant.py create mode 100644 tools/net/sunrpc/xdrgen/generators/enum.py create mode 100644 tools/net/sunrpc/xdrgen/generators/program.py create mode 100644 tools/net/sunrpc/xdrgen/generators/struct.py create mode 100644 tools/net/sunrpc/xdrgen/generators/typedef.py create mode 100644 tools/net/sunrpc/xdrgen/generators/union.py create mode 100644 tools/net/sunrpc/xdrgen/subcmds/__init__.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/header.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/lint.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/source.py create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_bottom.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_top.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/source_top.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/constants/declaration.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enumerator.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2 create mode 100644 tools/net/sunrpc/xdrgen/tests/test.x create mode 120000 tools/net/sunrpc/xdrgen/xdr create mode 100644 tools/net/sunrpc/xdrgen/xdr.ebnf create mode 100644 tools/net/sunrpc/xdrgen/xdr_ast.py create mode 100644 tools/net/sunrpc/xdrgen/xdr_parse.py create mode 100755 tools/net/sunrpc/xdrgen/xdrgen
include/linux/sunrpc/xdrgen-builtins.h new file +253 -0
@@ -0,0 +1,253 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2024 Oracle and/or its affiliates. +* +* This header defines the XDR data type primitives, specified in +* Section 4 of RFC 4506, that are used by RPC programs implemented +* in the Linux kernel. +*/ + +#ifndef _SUNRPC_XDRGEN_BUILTINS_H_ +#define _SUNRPC_XDRGEN_BUILTINS_H_ + +#include <linux/sunrpc/xdr.h> + +static inline bool +xdrgen_decode_void (struct xdr_stream *xdr) +{ +return true; +} + +static inline bool +xdrgen_encode_void (struct xdr_stream *xdr) +{ +return true; +} + +static inline bool +xdrgen_decode_bool (struct xdr_stream *xdr,bool *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *ptr = (*p != xdr_zero); +return true; +} + +static inline bool +xdrgen_encode_bool (struct xdr_stream *xdr,bool val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *p = val ? xdr_one : xdr_zero; +return true; +} + +static inline bool +xdrgen_decode_int (struct xdr_stream *xdr,s32 *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *ptr =be32_to_cpup (p); +return true; +} + +static inline bool +xdrgen_encode_int (struct xdr_stream *xdr,s32 val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *p =cpu_to_be32 (val); +return true; +} + +static inline bool +xdrgen_decode_unsigned_int (struct xdr_stream *xdr,u32 *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *ptr =be32_to_cpup (p); +return true; +} + +static inline bool +xdrgen_encode_unsigned_int (struct xdr_stream *xdr,u32 val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *p =cpu_to_be32 (val); +return true; +} + +static inline bool +xdrgen_decode_long (struct xdr_stream *xdr,s32 *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *ptr =be32_to_cpup (p); +return true; +} + +static inline bool +xdrgen_encode_long (struct xdr_stream *xdr,s32 val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *p =cpu_to_be32 (val); +return true; +} + +static inline bool +xdrgen_decode_unsigned_long (struct xdr_stream *xdr,u32 *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *ptr =be32_to_cpup (p); +return true; +} + +static inline bool +xdrgen_encode_unsigned_long (struct xdr_stream *xdr,u32 val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT ); + +if (unlikely (!p)) +return false; + *p =cpu_to_be32 (val); +return true; +} + +static inline bool +xdrgen_decode_hyper (struct xdr_stream *xdr,s64 *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT *2 ); + +if (unlikely (!p)) +return false; + *ptr =get_unaligned_be64 (p); +return true; +} + +static inline bool +xdrgen_encode_hyper (struct xdr_stream *xdr,s64 val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT *2 ); + +if (unlikely (!p)) +return false; +put_unaligned_be64 (val, p); +return true; +} + +static inline bool +xdrgen_decode_unsigned_hyper (struct xdr_stream *xdr,u64 *ptr) +{ +__be32 *p =xdr_inline_decode (xdr,XDR_UNIT *2 ); + +if (unlikely (!p)) +return false; + *ptr =get_unaligned_be64 (p); +return true; +} + +static inline bool +xdrgen_encode_unsigned_hyper (struct xdr_stream *xdr,u64 val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT *2 ); + +if (unlikely (!p)) +return false; +put_unaligned_be64 (val, p); +return true; +} + +typedef struct { +u32 len; +unsigned char *data; +}string ; + +static inline bool +xdrgen_decode_string (struct xdr_stream *xdr,string *ptr,u32 maxlen) +{ +__be32 *p; +u32 len; + +if (unlikely (xdr_stream_decode_u32 (xdr, &len) !=XDR_UNIT )) +return false; +if (unlikely (maxlen && len > maxlen)) +return false; +if (len !=0 ) { + p =xdr_inline_decode (xdr, len); +if (unlikely (!p)) +return false; + ptr->data = (unsigned char *)p; + } + ptr->len = len; +return true; +} + +static inline bool +xdrgen_encode_string (struct xdr_stream *xdr,string val,u32 maxlen) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT +xdr_align_size (val.len)); + +if (unlikely (!p)) +return false; +xdr_encode_opaque (p, val.data, val.len); +return true; +} + +typedef struct { +u32 len; +u8 *data; +}opaque ; + +static inline bool +xdrgen_decode_opaque (struct xdr_stream *xdr,opaque *ptr,u32 maxlen) +{ +__be32 *p; +u32 len; + +if (unlikely (xdr_stream_decode_u32 (xdr, &len) !=XDR_UNIT )) +return false; +if (unlikely (maxlen && len > maxlen)) +return false; +if (len !=0 ) { + p =xdr_inline_decode (xdr, len); +if (unlikely (!p)) +return false; + ptr->data = (u8 *)p; + } + ptr->len = len; +return true; +} + +static inline bool +xdrgen_encode_opaque (struct xdr_stream *xdr,opaque val) +{ +__be32 *p =xdr_reserve_space (xdr,XDR_UNIT +xdr_align_size (val.len)); + +if (unlikely (!p)) +return false; +xdr_encode_opaque (p, val.data, val.len); +return true; +} + +#endif /* _SUNRPC_XDRGEN_BUILTINS_H_ */
tools/net/sunrpc/xdrgen/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +__pycache__ +generators/__pycache__
tools/net/sunrpc/xdrgen/README new file +231 -0
231 lines not on this page · raw message
tools/net/sunrpc/xdrgen/__init__.py new file +0 -0
tools/net/sunrpc/xdrgen/common.py new file +21 -0
@@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +# ex: set filetype=python: + +"""Utility functions and global variables for xdrgen.""" + +global annotate +annotate = False + + +def set_xdr_annotate(set_it): + """Set 'annotate' if --annotate was specified on the command line""" + global annotate + + annotate = set_it + + +def get_xdr_annotate(): + """Return True if --annotate was specified on the command line""" + global annotate + + return annotate
tools/net/sunrpc/xdrgen/generators/__init__.py new file +0 -0
tools/net/sunrpc/xdrgen/generators/boilerplate.py new file +66 -0
66 lines not on this page · raw message
tools/net/sunrpc/xdrgen/generators/constant.py new file +38 -0
@@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# ex: set filetype=python: + +"""Generate code to handle XDR constants""" + +from jinja2 import Environment, FileSystemLoader + + +class SourceGenerator: + """Generate source code for XDR constants""" + + def __init__(self, language): + """Set the output language""" + match language: + case "C": + self.environment = Environment( + loader=FileSystemLoader("templates/C/constants/"), + trim_blocks=True, + lstrip_blocks=True, + ) + case _: + raise NotImplementedError("Language not supported") + + def emit_declaration(self, ast_node): + """Emit one declaration for a constant""" + template = self.environment.get_template("declaration.j2") + print( + template.render( + name=ast_node.name, + value=ast_node.value, + ) + ) + + def emit_decoder(self, ast_node): + """Emit one decoder for a constant""" + + def emit_encoder(self, ast_node): + """Emit one encoder for a constant"""
tools/net/sunrpc/xdrgen/generators/enum.py new file +67 -0
67 lines not on this page · raw message
tools/net/sunrpc/xdrgen/generators/program.py new file +96 -0
96 lines not on this page · raw message
tools/net/sunrpc/xdrgen/generators/struct.py new file +435 -0
435 lines not on this page · raw message
tools/net/sunrpc/xdrgen/generators/typedef.py new file +282 -0
282 lines not on this page · raw message
tools/net/sunrpc/xdrgen/generators/union.py new file +297 -0
297 lines not on this page · raw message
tools/net/sunrpc/xdrgen/subcmds/__init__.py new file +0 -0
tools/net/sunrpc/xdrgen/subcmds/header.py new file +62 -0
62 lines not on this page · raw message
tools/net/sunrpc/xdrgen/subcmds/lint.py new file +28 -0
@@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +# ex: set filetype=python: + +"""Translate an XDR specification into executable C code that +can be compiled for the Linux kernel.""" + +import logging + +from lark import logger +from xdr_parse import xdr_parser + +logger.setLevel(logging.DEBUG) + + +def handle_parse_error(e): + """Simple parse error reporting, no recovery attempted""" + print(e) + return True + + +def subcmd(args): + """Lexical and syntax check of an XDR specification""" + + parser = xdr_parser() + with open(args.filename, encoding="utf-8") as f: + parser.parse(f.read(), on_error=handle_parse_error) + + return 0
tools/net/sunrpc/xdrgen/subcmds/source.py new file +82 -0
82 lines not on this page · raw message
tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_bottom.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +#endif /* _LINUX_{{ program.upper() }}_XDRGEN_H */
tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_top.j2 new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification modification time: {{ mtime }} */ + +#ifndef _LINUX_{{ program.upper() }}_XDRGEN_H +#define _LINUX_{{ program.upper() }}_XDRGEN_H + +#include <linux/types.h> +#include <linux/sunrpc/svc.h> + +#include <linux/sunrpc/xdrgen-builtins.h>
tools/net/sunrpc/xdrgen/templates/C/boilerplate/source_top.j2 new file +5 -0
@@ -0,0 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0 +// Generated by xdrgen. Manual edits will be lost. +// XDR specification modification time: {{ mtime }} + +#include "{{ program }}xdr_gen.h"
tools/net/sunrpc/xdrgen/templates/C/constants/declaration.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +enum { + {{ name }} = {{ value }} +};
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2 new file +7 -0
@@ -0,0 +1,7 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, enum {{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, enum {{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enumerator.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + {{ name }} = {{ value }},
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/open.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +enum {{ name }} {
tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2 new file +19 -0
@@ -0,0 +1,19 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* enum {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, enum {{ name }} *ptr) +{ + u32 val; + + if (xdr_stream_decode_u32(xdr, &val) < 0) + return false; + *ptr = val; + return true; +}
tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2 new file +14 -0
@@ -0,0 +1,14 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* enum {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, enum {{ name }} value) +{ + return xdr_stream_encode_u32(xdr, value) == XDR_UNIT; +}
tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +bool {{ program }}_svc_decode_{{ argument }}(struct svc_rqst *rqstp, struct xdr_stream *xdr);
tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +bool {{ program }}_svc_encode_{{ result }}(struct svc_rqst *rqstp, struct xdr_stream *xdr);
tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 new file +21 -0
@@ -0,0 +1,21 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +/** + * {{ program }}_svc_decode_{{ argument }} - Decode a {{ argument }} argument + * @rqstp: RPC transaction context + * @xdr: source XDR data stream + * + * Return values: + * %true: procedure arguments decoded successfully + * %false: decode failed + */ +bool {{ program }}_svc_decode_{{ argument }}(struct svc_rqst *rqstp, struct xdr_stream *xdr) +{ +{% if argument == 'void' %} + return xdrgen_decode_void(xdr); +{% else %} + struct {{ argument }} *argp = rqstp->rq_argp; + + return xdrgen_decode_{{ argument }}(xdr, argp); +{% endif %} +}
tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 new file +21 -0
@@ -0,0 +1,21 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +/** + * {{ program }}_svc_encode_{{ result }} - Encode a {{ result }} result + * @rqstp: RPC transaction context + * @xdr: target XDR data stream + * + * Return values: + * %true: procedure results encoded successfully + * %false: encode failed + */ +bool {{ program }}_svc_encode_{{ result }}(struct svc_rqst *rqstp, struct xdr_stream *xdr) +{ +{% if result == 'void' %} + return xdrgen_encode_void(xdr); +{% else %} + struct {{ result }} *resp = rqstp->rq_resp; + + return xdrgen_encode_{{ result }}(xdr, resp); +{% endif %} +}
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/basic.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (basic) */ +{% endif %} + {{ ctype }}{{ type }} {{ name }};
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/close.j2 new file +7 -0
@@ -0,0 +1,7 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_array.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (fixed-length array) */ +{% endif %} + {{ type }} {{ name }}[{{ size }}];
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_opaque.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (fixed-length opaque) */ +{% endif %} + u8 {{ name }}[{{ size }}];
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/open.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* struct {{ name }} */ +{% endif %} +struct {{ name }} {
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/optional_data.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (optional data) */ +{% endif %} + {{ ctype }}{{ type }} *{{ name }};
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/pointer-open.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* pointer {{ name }} */ +{% endif %} +struct {{ name }} {
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_array.j2 new file +8 -0
@@ -0,0 +1,8 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (variable-length array) */ +{% endif %} + struct { + u32 count; + {{ ctype }}{{ type }} *element; + } {{ name }};
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_opaque.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (variable-length opaque) */ +{% endif %} + opaque {{ name }};
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_string.j2 new file +5 -0
@@ -0,0 +1,5 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* (variable-length string) */ +{% endif %} + string {{ name }};
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (basic) */ +{% endif %} + if (!xdrgen_decode_{{ type }}(xdr, &ptr->{{ name }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + return true; +};
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2 new file +8 -0
@@ -0,0 +1,8 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (fixed-length array) */ +{% endif %} + for (u32 i = 0; i < {{ size }}; i++) { + if (xdrgen_decode_{{ type }}(xdr, &ptr->{{ name }}.items[i]) < 0) + return false; + }
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (fixed-length opaque) */ +{% endif %} + if (xdr_stream_decode_opaque_fixed(xdr, ptr->{{ name }}, {{ size }}) < 0) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2 new file +12 -0
@@ -0,0 +1,12 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* struct {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr) +{
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (optional data) */ +{% endif %} + if (!xdrgen_decode_{{ type }}(xdr, ptr->{{ name }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/pointer-open.j2 new file +22 -0
@@ -0,0 +1,22 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* pointer {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr) +{ + bool opted; + +{% if annotate %} + /* opted */ +{% endif %} + if (!xdrgen_decode_bool(xdr, &opted)) + return false; + if (!opted) + return true; +
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2 new file +13 -0
@@ -0,0 +1,13 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length array) */ +{% endif %} + if (xdr_stream_decode_u32(xdr, &ptr->{{ name }}.count) != XDR_UNIT) + return false; +{% if maxsize != 0 %} + if (ptr->{{ name }}.count > {{ maxsize }}) + return false; +{% endif %} + for (u32 i = 0; i < ptr->{{ name }}.count; i++) + if (!xdrgen_decode_{{ type }}(xdr, &ptr->{{ name }}.element[i])) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length opaque) */ +{% endif %} + if (!xdrgen_decode_opaque(xdr, (opaque *)ptr, {{ maxsize }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length string) */ +{% endif %} + if (!xdrgen_decode_string(xdr, (string *)ptr, {{ maxsize }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2 new file +10 -0
@@ -0,0 +1,10 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (basic) */ +{% endif %} +{% if encode_needs_addressof %} + if (!xdrgen_encode_{{ type }}(xdr, &value->{{ name }})) +{% else %} + if (!xdrgen_encode_{{ type }}(xdr, value->{{ name }})) +{% endif %} + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + return true; +};
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2 new file +12 -0
@@ -0,0 +1,12 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (fixed-length array) */ +{% endif %} + for (u32 i = 0; i < {{ size }}; i++) { +{% if encode_needs_addressof %} + if (xdrgen_encode_{{ type }}(xdr, &value->items[i]) < 0) +{% else %} + if (xdrgen_encode_{{ type }}(xdr, value->items[i]) < 0) +{% endif %} + return false; + }
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (fixed-length opaque) */ +{% endif %} + if (xdr_stream_encode_opaque_fixed(xdr, value->{{ name }}, {{ size }}) < 0) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2 new file +12 -0
@@ -0,0 +1,12 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* struct {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *value) +{
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (optional data) */ +{% endif %} + if (!xdrgen_encode_{{ type }}(xdr, value->{{ name }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/pointer-open.j2 new file +20 -0
@@ -0,0 +1,20 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* pointer {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *value) +{ +{% if annotate %} + /* opted */ +{% endif %} + if (!xdrgen_encode_bool(xdr, value != NULL)) + return false; + if (!value) + return true; +
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2 new file +15 -0
@@ -0,0 +1,15 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length array) */ +{% endif %} + if (value->{{ name }}.count > {{ maxsize }}) + return false; + if (xdr_stream_encode_u32(xdr, value->{{ name }}.count) != XDR_UNIT) + return false; + for (u32 i = 0; i < value->{{ name }}.count; i++) +{% if encode_needs_addressof %} + if (!xdrgen_encode_{{ type }}(xdr, &value->{{ name }}.element[i])) +{% else %} + if (!xdrgen_encode_{{ type }}(xdr, value->{{ name }}.element[i])) +{% endif %} + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 new file +8 -0
@@ -0,0 +1,8 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length opaque) */ +{% endif %} + if (value->{{ name }}.len > {{ maxsize }}) + return false; + if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) + return false;
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2 new file +8 -0
@@ -0,0 +1,8 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length string) */ +{% endif %} + if (value->{{ name }}.len > {{ maxsize }}) + return false; + if (xdr_stream_encode_opaque(xdr, value->{{ name }}.data, value->{{ name }}.len) < 0) + return false;
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/basic.j2 new file +11 -0
@@ -0,0 +1,11 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} (basic) */ +{% endif %} +typedef {{ ctype }}{{ type }} {{ name }}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_array.j2 new file +11 -0
@@ -0,0 +1,11 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} (fixed-length array) */ +{% endif %} +typedef {{ type }}{{ name }}[{{ size }}]; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_opaque.j2 new file +11 -0
@@ -0,0 +1,11 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} (fixed-length opaque) */ +{% endif %} +typedef u8 {{ name }}[{{ size }}]; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_array.j2 new file +14 -0
@@ -0,0 +1,14 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} (variable-length array) */ +{% endif %} +typedef struct { + u32 count; + {{ ctype }}{{ type }} *element; +} {{ name }}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_opaque.j2 new file +11 -0
@@ -0,0 +1,11 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} (variable-length opaque) */ +{% endif %} +typedef opaque {{ name }}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_string.j2 new file +11 -0
@@ -0,0 +1,11 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} (variable-length string) */ +{% endif %} +typedef string {{ name }}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ name }} *ptr) +{ +{% if annotate %} + /* (basic) */ +{% endif %} + return xdrgen_decode_{{ type }}(xdr, ptr); +};
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2 new file +25 -0
@@ -0,0 +1,25 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr) +{ +{% if annotate %} + /* (fixed-length array) */ +{% endif %} + for (u32 i = 0; i < {{ size }}; i++) { +{%- if ctype == '' %} + if (xdrgen_decode_{{ type }}(xdr, ptr->items[i]) < 0) +{% else %} + if (xdrgen_decode_{{ type }}(xdr, &ptr->items[i]) < 0) +{% endif %} + return false; + } + return true; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr) +{ +{% if annotate %} + /* (fixed-length opaque) */ +{% endif %} + return xdr_stream_decode_opaque_fixed(xdr, ptr, {{ size }}) >= 0; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2 new file +26 -0
@@ -0,0 +1,26 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr) +{ +{% if annotate %} + /* (variable-length array) */ +{% endif %} + if (xdr_stream_decode_u32(xdr, &ptr->count) < 0) + return false; +{% if maxsize != 0 %} + if (ptr->count > {{ maxsize }}) + return false; +{% endif %} + for (u32 i = 0; i < ptr->count; i++) + if (!xdrgen_decode_{{ type }}(xdr, &ptr->element[i])) + return false; + return true; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr) +{ +{% if annotate %} + /* (variable-length opaque) */ +{% endif %} + return xdr_stream_decode_opaque(xdr, ptr->data, ptr->len) >= 0; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, {{ ctype }}{{ name }} *ptr) +{ +{% if annotate %} + /* (variable-length string) */ +{% endif %} + return xdr_stream_decode_opaque(xdr, ptr->data, ptr->len) >= 0; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2 new file +21 -0
@@ -0,0 +1,21 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value) +{ +{% if annotate %} + /* (basic) */ +{% endif %} +{% if encode_needs_addressof %} + return xdrgen_encode_{{ type }}(xdr, &value); +{% else %} + return xdrgen_encode_{{ type }}(xdr, value); +{% endif %} +};
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2 new file +25 -0
@@ -0,0 +1,25 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value) +{ +{% if annotate %} + /* (fixed-length array) */ +{% endif %} + for (u32 i = 0; i < {{ size }}; i++) { +{% elif encode_needs_deref %} + if (xdrgen_encode_{{ type }}(xdr, &value->items[i]) < 0) +{% else %} + if (xdrgen_encode_{{ type }}(xdr, value->items[i]) < 0) +{% endif %} + return false; + } + return true; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value) +{ +{% if annotate %} + /* (fixed-length opaque) */ +{% endif %} + return xdr_stream_encode_opaque_fixed(xdr, value, {{ size }}) >= 0; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2 new file +30 -0
@@ -0,0 +1,30 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value) +{ +{% if annotate %} + /* (variable-length array) */ +{% endif %} +{% if maxsize != 0 %} + if (unlikely(value.count > {{ maxsize }})) + return false; +{% endif %} + if (xdr_stream_encode_u32(xdr, value.count) != XDR_UNIT) + return false; + for (u32 i = 0; i < value.count; i++) +{% if encode_needs_addressof %} + if (!xdrgen_encode_{{ type }}(xdr, &value.element[i])) +{% else %} + if (!xdrgen_encode_{{ type }}(xdr, value.element[i])) +{% endif %} + return false; + return true; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value) +{ +{% if annotate %} + /* (variable-length opaque) */ +{% endif %} + return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0; +};
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2 new file +17 -0
@@ -0,0 +1,17 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* typedef {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const {{ ctype }}{{ name }} value) +{ +{% if annotate %} + /* (variable-length string) */ +{% endif %} + return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0; +};
tools/net/sunrpc/xdrgen/templates/C/union/declaration/case_spec.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + {{ ctype }}{{ type }} {{ name }};
tools/net/sunrpc/xdrgen/templates/C/union/declaration/close.j2 new file +8 -0
@@ -0,0 +1,8 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + } u; +}; +{%- if name in public_apis %} + +bool xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr); +bool xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *ptr); +{%- endif -%}
tools/net/sunrpc/xdrgen/templates/C/union/declaration/default_spec.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + {{ ctype }}{{ type }} {{ name }};
tools/net/sunrpc/xdrgen/templates/C/union/declaration/open.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* union {{ name }} */ +{% endif %} +struct {{ name }} {
tools/net/sunrpc/xdrgen/templates/C/union/declaration/switch_spec.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + {{ ctype }}{{ type }} {{ name }}; + union {
tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (basic) */ +{% endif %} + if (!xdrgen_decode_{{ type }}(xdr, &ptr->u.{{ name }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + break;
tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + case {{ case }}:
tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2 new file +4 -0
@@ -0,0 +1,4 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + } + return true; +};
tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + default:
tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2 new file +12 -0
@@ -0,0 +1,12 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* union {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_decode_{{ name }}(struct xdr_stream *xdr, struct {{ name }} *ptr) +{
tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (optional data) */ +{% endif %} + if (!xdrgen_decode_{{ type }}(xdr, &ptr->u.{{ name }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2 new file +7 -0
@@ -0,0 +1,7 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* discriminant {{ name }} */ +{% endif %} + if (!xdrgen_decode_{{ type }}(xdr, &ptr->{{ name }})) + return false; + switch (ptr->{{ name }}) {
tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2 new file +13 -0
@@ -0,0 +1,13 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length array) */ +{% endif %} + if (xdr_stream_decode_u32(xdr, &count) != XDR_UNIT) + return false; + if (count > {{ maxsize }}) + return false; + for (u32 i = 0; i < count; i++) { + if (xdrgen_decode_{{ type }}(xdr, &ptr->{{ name }}.items[i]) < 0) + return false; + } + ptr->{{ name }}.len = count;
tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length opaque) */ +{% endif %} + if (!xdrgen_decode_opaque(xdr, (struct opaque *)ptr->u.{{ name }}, {{ maxsize }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2 new file +6 -0
@@ -0,0 +1,6 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (variable-length string) */ +{% endif %} + if (!xdrgen_decode_string(xdr, (struct string *)ptr->u.{{ name }}, {{ maxsize }})) + return false;
tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + if (!xdrgen_decode_void(xdr)) + return false;
tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2 new file +10 -0
@@ -0,0 +1,10 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* member {{ name }} (basic) */ +{% endif %} +{% if encode_needs_addressof %} + if (!xdrgen_encode_{{ type }}(xdr, &ptr->u.{{ name }})) +{% else %} + if (!xdrgen_encode_{{ type }}(xdr, ptr->u.{{ name }})) +{% endif %} + return false;
tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + break;
tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + case {{ case }}:
tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2 new file +4 -0
@@ -0,0 +1,4 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + } + return true; +};
tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2 new file +2 -0
@@ -0,0 +1,2 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + default:
tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2 new file +12 -0
@@ -0,0 +1,12 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + +{% if annotate %} +/* union {{ name }} */ +{% endif %} +{% if name in public_apis %} +bool +{% else %} +static bool __maybe_unused +{% endif %} +xdrgen_encode_{{ name }}(struct xdr_stream *xdr, const struct {{ name }} *ptr) +{
tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2 new file +7 -0
@@ -0,0 +1,7 @@ +{# SPDX-License-Identifier: GPL-2.0 #} +{% if annotate %} + /* discriminant {{ name }} */ +{% endif %} + if (!xdrgen_encode_{{ type }}(xdr, ptr->{{ name }})) + return false; + switch (ptr->{{ name }}) {
tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2 new file +3 -0
@@ -0,0 +1,3 @@ +{# SPDX-License-Identifier: GPL-2.0 #} + if (!xdrgen_encode_void(xdr)) + return false;
tools/net/sunrpc/xdrgen/tests/test.x new file +36 -0
@@ -0,0 +1,36 @@ +/* Sample XDR specification from RFC 1832 Section 5.5 */ + +const MAXUSERNAME = 32; /* max length of a user name */ +const MAXFILELEN = 65535; /* max length of a file */ +const MAXNAMELEN = 255; /* max length of a file name */ + +/* + * Types of files: + */ +enum filekind { + TEXT = 0, /* ascii data */ + DATA = 1, /* raw data */ + EXEC = 2 /* executable */ +}; + +/* + * File information, per kind of file: + */ +union filetype switch (filekind kind) { +case TEXT: + void; /* no extra information */ +case DATA: + string creator<MAXNAMELEN>; /* data creator */ +case EXEC: + string interpretor<MAXNAMELEN>; /* program interpretor */ +}; + +/* + * A complete file: + */ +struct file { + string filename<MAXNAMELEN>; /* name of file */ + filetype type; /* info about file */ + string owner<MAXUSERNAME>; /* owner of file */ + opaque data<MAXFILELEN>; /* file data */ +};
tools/net/sunrpc/xdrgen/xdr new file +1 -0
@@ -0,0 +1 @@ +../../../../Documentation/sunrpc/xdr
tools/net/sunrpc/xdrgen/xdr.ebnf new file +117 -0
117 lines not on this page · raw message
tools/net/sunrpc/xdrgen/xdr_ast.py new file +437 -0
78 lines not on this page · raw message
tools/net/sunrpc/xdrgen/xdr_parse.py new file +20 -0
Lines of this file are not shown. View the raw message.
tools/net/sunrpc/xdrgen/xdrgen new file +95 -0
95 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.45.1
Part of the diff is not shown here. View the raw message.
[email protected]
maintainerRFC PATCH 2/2 NFSD: Create an initial nfs4_1.x file
In reply to [email protected]From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions. The new fs/nfsd/nfs4_1.x file can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.
--- fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 fs/nfsd/nfs4_1.x create mode 100644 fs/nfsd/nfs4xdr_gen.c create mode 100644 fs/nfsd/nfs4xdr_gen.h
fs/nfsd/nfs4_1.x new file +164 -0
@@ -0,0 +1,164 @@ +/* + * Copyright (c) 2010 IETF Trust and the persons identified + * as the document authors. All rights reserved. + * + * The document authors are identified in RFC 3530 and + * RFC 5661. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * - Neither the name of Internet Society, IETF or IETF + * Trust, nor the names of specific contributors, may be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +pragma header nfs4; + +/* + * Basic typedefs for RFC 1832 data type definitions + */ +typedef hyper int64_t; +typedef unsigned int uint32_t; + +/* + * Basic data types + */ +typedef uint32_t bitmap4<>; + +/* + * Timeval + */ +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + + +/* + * The following content was extracted from draft-ietf-nfsv4-delstid + */ + +typedef bool fattr4_offline; + + +const FATTR4_OFFLINE = 83; + + +struct open_arguments4 { + bitmap4 oa_share_access; + bitmap4 oa_share_deny; + bitmap4 oa_share_access_want; + bitmap4 oa_open_claim; + bitmap4 oa_create_mode; +}; + + +enum open_args_share_access4 { + OPEN_ARGS_SHARE_ACCESS_READ = 1, + OPEN_ARGS_SHARE_ACCESS_WRITE = 2, + OPEN_ARGS_SHARE_ACCESS_BOTH = 3 +}; + + +enum open_args_share_deny4 { + OPEN_ARGS_SHARE_DENY_NONE = 0, + OPEN_ARGS_SHARE_DENY_READ = 1, + OPEN_ARGS_SHARE_DENY_WRITE = 2, + OPEN_ARGS_SHARE_DENY_BOTH = 3 +}; + + +enum open_args_share_access_want4 { + OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG = 3, + OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG = 4, + OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL = 5, + OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL + = 17, + OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED + = 18, + OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 20, + OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 21 +}; + + +enum open_args_open_claim4 { + OPEN_ARGS_OPEN_CLAIM_NULL = 0, + OPEN_ARGS_OPEN_CLAIM_PREVIOUS = 1, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR = 2, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV = 3, + OPEN_ARGS_OPEN_CLAIM_FH = 4, + OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH = 5, + OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH = 6 +}; + + +enum open_args_createmode4 { + OPEN_ARGS_CREATEMODE_UNCHECKED4 = 0, + OPEN_ARGS_CREATE_MODE_GUARDED = 1, + OPEN_ARGS_CREATEMODE_EXCLUSIVE4 = 2, + OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 = 3 +}; + + +typedef open_arguments4 fattr4_open_arguments; +pragma public fattr4_open_arguments; + + +%/* +% * Determine what OPEN supports. +% */ +const FATTR4_OPEN_ARGUMENTS = 86; + + +const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 0x200000; + + +const OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010; + + +/* + * attributes for the delegation times being + * cached and served by the "client" + */ +typedef nfstime4 fattr4_time_deleg_access; +typedef nfstime4 fattr4_time_deleg_modify; + + +%/* +% * New RECOMMENDED Attribute for +% * delegation caching of times +% */ +const FATTR4_TIME_DELEG_ACCESS = 84; +const FATTR4_TIME_DELEG_MODIFY = 85; + + +const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000; +
fs/nfsd/nfs4xdr_gen.c new file +236 -0
236 lines not on this page · raw message
fs/nfsd/nfs4xdr_gen.h new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.45.1
Jeff Layton
maintainerRe: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 8 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions. The new
fs/nfsd/nfs4_1.xfile can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.Signed-off-by Chuck Lever <[email protected]>
Quoted 9 lines
--- fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 fs/nfsd/nfs4_1.x create mode 100644 fs/nfsd/nfs4xdr_gen.c create mode 100644 fs/nfsd/nfs4xdr_gen.h
I see the patches in your lkxdrgen branch. I gave this a try and started rebasing my delstid work on top of it, but I hit the same symbol conflicts I hit before once I started trying to include the full-blown nfs4xdr_gen.h header:
------------------------8<---------------------------
In file included from fs/nfsd/nfs4xdr.c:58:fs/nfsd/nfs4xdr_gen.h:86:9: error: redeclaration of enumerator ‘FATTR4_OPEN_ARGUMENTS’
86 | FATTR4_OPEN_ARGUMENTS = 86
| ^~~~~~~~~~~~~~~~~~~~~
In file included from fs/nfsd/nfsfh.h:15,
from fs/nfsd/state.h:41,
from fs/nfsd/xdr4.h:40,
from fs/nfsd/nfs4xdr.c:51:
./include/linux/nfs4.h:518:9: note: previous definition of ‘FATTR4_OPEN_ARGUMENTS’ with type ‘enum <anonymous>’
518 | FATTR4_OPEN_ARGUMENTS = 86,
| ^~~~~~~~~~~~~~~~~~~~~
fs/nfsd/nfs4xdr_gen.h:102:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_ACCESS’
102 | FATTR4_TIME_DELEG_ACCESS = 84
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/nfs4.h:516:9: note: previous definition of ‘FATTR4_TIME_DELEG_ACCESS’ with type ‘enum <anonymous>’
516 | FATTR4_TIME_DELEG_ACCESS = 84,
| ^~~~~~~~~~~~~~~~~~~~~~~~
fs/nfsd/nfs4xdr_gen.h:106:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_MODIFY’
106 | FATTR4_TIME_DELEG_MODIFY = 85
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/nfs4.h:517:9: note: previous definition of ‘FATTR4_TIME_DELEG_MODIFY’ with type ‘enum <anonymous>’
517 | FATTR4_TIME_DELEG_MODIFY = 85,
| ^~~~~~~~~~~~~~~~~~~~~~~~------------------------8<---------------------------
I'm not sure of the best way to work around this, unless we want to try to split up nfs4.h.
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr, &nfsd_open_arguments))
OPEN_ARGUMENTS4 is a large structure with 5 different bitmaps in it. We probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer instead (IMO).
Quoted 531 lines
fs/nfsd/nfs4_1.x new file +164
-0@@ -0,0 +1,164 @@ +/* + * Copyright (c) 2010 IETF Trust and the persons identified + * as the document authors. All rights reserved. + * + * The document authors are identified in RFC 3530 and + * RFC 5661. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * - Neither the name of Internet Society, IETF or IETF + * Trust, nor the names of specific contributors, may be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +pragma header nfs4; + +/* + * Basic typedefs for RFC 1832 data type definitions + */ +typedef hyper int64_t; +typedef unsigned int uint32_t; + +/* + * Basic data types + */ +typedef uint32_t bitmap4<>; + +/* + * Timeval + */ +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + + +/* + * The following content was extracted from draft-ietf-nfsv4-delstid + */ + +typedef bool fattr4_offline; + + +const FATTR4_OFFLINE = 83; + + +struct open_arguments4 { + bitmap4 oa_share_access; + bitmap4 oa_share_deny; + bitmap4 oa_share_access_want; + bitmap4 oa_open_claim; + bitmap4 oa_create_mode; +}; + + +enum open_args_share_access4 { + OPEN_ARGS_SHARE_ACCESS_READ = 1, + OPEN_ARGS_SHARE_ACCESS_WRITE = 2, + OPEN_ARGS_SHARE_ACCESS_BOTH = 3 +}; + + +enum open_args_share_deny4 { + OPEN_ARGS_SHARE_DENY_NONE = 0, + OPEN_ARGS_SHARE_DENY_READ = 1, + OPEN_ARGS_SHARE_DENY_WRITE = 2, + OPEN_ARGS_SHARE_DENY_BOTH = 3 +}; + + +enum open_args_share_access_want4 { + OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG = 3, + OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG = 4, + OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL = 5, + OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL + = 17, + OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED + = 18, + OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 20, + OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 21 +}; + + +enum open_args_open_claim4 { + OPEN_ARGS_OPEN_CLAIM_NULL = 0, + OPEN_ARGS_OPEN_CLAIM_PREVIOUS = 1, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR = 2, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV = 3, + OPEN_ARGS_OPEN_CLAIM_FH = 4, + OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH = 5, + OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH = 6 +}; + + +enum open_args_createmode4 { + OPEN_ARGS_CREATEMODE_UNCHECKED4 = 0, + OPEN_ARGS_CREATE_MODE_GUARDED = 1, + OPEN_ARGS_CREATEMODE_EXCLUSIVE4 = 2, + OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 = 3 +}; + + +typedef open_arguments4 fattr4_open_arguments; +pragma public fattr4_open_arguments; + + +%/* +% * Determine what OPEN supports. +% */ +const FATTR4_OPEN_ARGUMENTS = 86; + + +const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 0x200000; + + +const OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010; + + +/* + * attributes for the delegation times being + * cached and served by the "client" + */ +typedef nfstime4 fattr4_time_deleg_access; +typedef nfstime4 fattr4_time_deleg_modify; + + +%/* +% * New RECOMMENDED Attribute for +% * delegation caching of times +% */ +const FATTR4_TIME_DELEG_ACCESS = 84; +const FATTR4_TIME_DELEG_MODIFY = 85; + + +const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000; +fs/nfsd/nfs4xdr_gen.c new file +236
-0@@ -0,0 +1,236 @@ +// SPDX-License-Identifier: GPL-2.0 +// Generated by xdrgen. Manual edits will be lost. +// XDR specification modification time: Mon Aug 19 23:28:23 2024 + +#include "nfs4xdr_gen.h" + +static bool __maybe_unused +xdrgen_decode_int64_t (struct xdr_stream *xdr,int64_t *ptr) +{ +return xdrgen_decode_hyper (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_uint32_t (struct xdr_stream *xdr,uint32_t *ptr) +{ +return xdrgen_decode_unsigned_int (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_bitmap4 (struct xdr_stream *xdr,bitmap4 *ptr) +{ +if (xdr_stream_decode_u32 (xdr, &ptr->count) <0 ) +return false; +for (u32 i =0 ; i < ptr->count; i++) +if (!xdrgen_decode_uint32_t (xdr, &ptr->element[i])) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_nfstime4 (struct xdr_stream *xdr,struct nfstime4 *ptr) +{ +if (!xdrgen_decode_int64_t (xdr, &ptr->seconds)) +return false; +if (!xdrgen_decode_uint32_t (xdr, &ptr->nseconds)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_offline (struct xdr_stream *xdr,fattr4_offline *ptr) +{ +return xdrgen_decode_bool (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_open_arguments4 (struct xdr_stream *xdr,struct open_arguments4 *ptr) +{ +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_access)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_deny)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_access_want)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_open_claim)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_create_mode)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_open_args_share_access4 (struct xdr_stream *xdr,enum open_args_share_access4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_deny4 (struct xdr_stream *xdr,enum open_args_share_deny4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_access_want4 (struct xdr_stream *xdr,enum open_args_share_access_want4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_open_claim4 (struct xdr_stream *xdr,enum open_args_open_claim4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_createmode4 (struct xdr_stream *xdr,enum open_args_createmode4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +bool +xdrgen_decode_fattr4_open_arguments (struct xdr_stream *xdr,fattr4_open_arguments *ptr) +{ +return xdrgen_decode_open_arguments4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_time_deleg_access (struct xdr_stream *xdr,fattr4_time_deleg_access *ptr) +{ +return xdrgen_decode_nfstime4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_time_deleg_modify (struct xdr_stream *xdr,fattr4_time_deleg_modify *ptr) +{ +return xdrgen_decode_nfstime4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_encode_int64_t (struct xdr_stream *xdr,const int64_t value) +{ +return xdrgen_encode_hyper (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_uint32_t (struct xdr_stream *xdr,const uint32_t value) +{ +return xdrgen_encode_unsigned_int (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_bitmap4 (struct xdr_stream *xdr,const bitmap4 value) +{ +if (xdr_stream_encode_u32 (xdr, value.count) !=XDR_UNIT ) +return false; +for (u32 i =0 ; i < value.count; i++) +if (!xdrgen_encode_uint32_t (xdr, value.element[i])) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_nfstime4 (struct xdr_stream *xdr,const struct nfstime4 *value) +{ +if (!xdrgen_encode_int64_t (xdr, value->seconds)) +return false; +if (!xdrgen_encode_uint32_t (xdr, value->nseconds)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_offline (struct xdr_stream *xdr,const fattr4_offline value) +{ +return xdrgen_encode_bool (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_open_arguments4 (struct xdr_stream *xdr,const struct open_arguments4 *value) +{ +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_access)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_deny)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_access_want)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_open_claim)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_create_mode)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_open_args_share_access4 (struct xdr_stream *xdr,enum open_args_share_access4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_deny4 (struct xdr_stream *xdr,enum open_args_share_deny4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_access_want4 (struct xdr_stream *xdr,enum open_args_share_access_want4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_open_claim4 (struct xdr_stream *xdr,enum open_args_open_claim4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_createmode4 (struct xdr_stream *xdr,enum open_args_createmode4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +bool +xdrgen_encode_fattr4_open_arguments (struct xdr_stream *xdr,const fattr4_open_arguments value) +{ +return xdrgen_encode_open_arguments4 (xdr, &value); +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_time_deleg_access (struct xdr_stream *xdr,const fattr4_time_deleg_access value) +{ +return xdrgen_encode_nfstime4 (xdr, &value); +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_time_deleg_modify (struct xdr_stream *xdr,const fattr4_time_deleg_modify value) +{ +return xdrgen_encode_nfstime4 (xdr, &value); +};fs/nfsd/nfs4xdr_gen.h new file +113
-0@@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification modification time: Mon Aug 19 23:28:23 2024 */ + +#ifndef _LINUX_NFS4_XDRGEN_H +#define _LINUX_NFS4_XDRGEN_H + +#include <linux/types.h> +#include <linux/sunrpc/svc.h> + +#include <linux/sunrpc/xdrgen-builtins.h> + +typedef s64 int64_t ; + +typedef u32 uint32_t ; + +typedef struct { +u32 count; +uint32_t *element; +}bitmap4 ; + +struct nfstime4 { +int64_t seconds; +uint32_t nseconds; +}; + +typedef bool fattr4_offline ; + +enum { +FATTR4_OFFLINE =83 +}; + +struct open_arguments4 { +bitmap4 oa_share_access; +bitmap4 oa_share_deny; +bitmap4 oa_share_access_want; +bitmap4 oa_open_claim; +bitmap4 oa_create_mode; +}; + +enum open_args_share_access4 { +OPEN_ARGS_SHARE_ACCESS_READ =1 , +OPEN_ARGS_SHARE_ACCESS_WRITE =2 , +OPEN_ARGS_SHARE_ACCESS_BOTH =3 , +}; + +enum open_args_share_deny4 { +OPEN_ARGS_SHARE_DENY_NONE =0 , +OPEN_ARGS_SHARE_DENY_READ =1 , +OPEN_ARGS_SHARE_DENY_WRITE =2 , +OPEN_ARGS_SHARE_DENY_BOTH =3 , +}; + +enum open_args_share_access_want4 { +OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG =3 , +OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG =4 , +OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL =5 , +OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL =17 , +OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED =18 , +OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =20 , +OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =21 , +}; + +enum open_args_open_claim4 { +OPEN_ARGS_OPEN_CLAIM_NULL =0 , +OPEN_ARGS_OPEN_CLAIM_PREVIOUS =1 , +OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR =2 , +OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV =3 , +OPEN_ARGS_OPEN_CLAIM_FH =4 , +OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH =5 , +OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH =6 , +}; + +enum open_args_createmode4 { +OPEN_ARGS_CREATEMODE_UNCHECKED4 =0 , +OPEN_ARGS_CREATE_MODE_GUARDED =1 , +OPEN_ARGS_CREATEMODE_EXCLUSIVE4 =2 , +OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 =3 , +}; + +typedef struct open_arguments4 fattr4_open_arguments ; +bool xdrgen_decode_fattr4_open_arguments (struct xdr_stream *xdr,fattr4_open_arguments *ptr); +bool xdrgen_encode_fattr4_open_arguments (struct xdr_stream *xdr,const fattr4_open_arguments value); + +enum { +FATTR4_OPEN_ARGUMENTS =86 +}; + +enum { +OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =0x200000 +}; + +enum { +OPEN4_RESULT_NO_OPEN_STATEID =0x00000010 +}; + +typedef struct nfstime4 fattr4_time_deleg_access ; + +typedef struct nfstime4 fattr4_time_deleg_modify ; + +enum { +FATTR4_TIME_DELEG_ACCESS =84 +}; + +enum { +FATTR4_TIME_DELEG_MODIFY =85 +}; + +enum { +OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =0x100000 +}; + +#endif /* _LINUX_NFS4_XDRGEN_H */
Signature · 1 line
Jeff Layton <[email protected]>
Re: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 48 lines · Jeff Layton
Quoted 8 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions. The new
fs/nfsd/nfs4_1.xfile can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.Signed-off-by Chuck Lever <[email protected]>Quoted 9 lines
--- fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 fs/nfsd/nfs4_1.x create mode 100644 fs/nfsd/nfs4xdr_gen.c create mode 100644 fs/nfsd/nfs4xdr_gen.hI see the patches in your lkxdrgen branch. I gave this a try and started rebasing my delstid work on top of it, but I hit the same symbol conflicts I hit before once I started trying to include the full-blown
nfs4xdr_gen.hheader:------------------------8<---------------------------
In file included fromfs/nfsd/nfs4xdr.c:58:fs/nfsd/nfs4xdr_gen.h:86:9: error: redeclaration of enumerator ‘FATTR4_OPEN_ARGUMENTS’86 | FATTR4_OPEN_ARGUMENTS = 86 | ^~~~~~~~~~~~~~~~~~~~~ In file included from fs/nfsd/nfsfh.h:15, from fs/nfsd/state.h:41, from fs/nfsd/xdr4.h:40, from fs/nfsd/nfs4xdr.c:51: ./include/linux/nfs4.h:518:9: note: previous definition of ‘FATTR4_OPEN_ARGUMENTS’ with type ‘enum <anonymous>’ 518 | FATTR4_OPEN_ARGUMENTS = 86, | ^~~~~~~~~~~~~~~~~~~~~ fs/nfsd/nfs4xdr_gen.h:102:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_ACCESS’ 102 | FATTR4_TIME_DELEG_ACCESS = 84 | ^~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/nfs4.h:516:9: note: previous definition of ‘FATTR4_TIME_DELEG_ACCESS’ with type ‘enum <anonymous>’ 516 | FATTR4_TIME_DELEG_ACCESS = 84, | ^~~~~~~~~~~~~~~~~~~~~~~~ fs/nfsd/nfs4xdr_gen.h:106:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_MODIFY’ 106 | FATTR4_TIME_DELEG_MODIFY = 85 | ^~~~~~~~~~~~~~~~~~~~~~~~ ./include/linux/nfs4.h:517:9: note: previous definition of ‘FATTR4_TIME_DELEG_MODIFY’ with type ‘enum <anonymous>’ 517 | FATTR4_TIME_DELEG_MODIFY = 85, | ^~~~~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines
------------------------8<---------------------------
I'm not sure of the best way to work around this, unless we want to try to split up
nfs4.h.
That header is shared with the client, so I consider it immutable for our purposes here.
One option would be to namespace the generated data items. Eg, name them:
XG_FATTR4_TIME_DELEG_ACCESS
XG_FATTR4_TIME_DELEG_MODIFY
That way they don't conflict with existing definitions.
Quoted 11 lines
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr,&nfsd_open_arguments))
OPEN_ARGUMENTS4is a large structure with 5 different bitmaps in it. We probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer instead (IMO).
The decoders are passed structs by reference already, fwiw. I had been considering the same for the encoder functions, for efficiency. I can give it a try.
Signature · 1 line
Chuck Lever
Jeff Layton
maintainerRe: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 67 lines · Chuck Lever
Quoted 58 lines · Jeff Layton
Quoted 14 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions.
The newfs/nfsd/nfs4_1.xfile can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.Signed-off-by Chuck Lever <[email protected]>---
fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++fs/nfsd/nfs4xdr_gen.c| 236
++++++++++++++++++++++++++++++++++++++++++
fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++Quoted 5 lines
3 files changed, 513 insertions(+)create mode 100644
fs/nfsd/nfs4_1.x
create mode 100644fs/nfsd/nfs4xdr_gen.c
create mode 100644fs/nfsd/nfs4xdr_gen.hI see the patches in your lkxdrgen branch. I gave this a try and started rebasing my delstid work on top of it, but I hit the same symbol conflicts I hit before once I started trying to include the full-blown
nfs4xdr_gen.hheader:------------------------8<--------------------------- In file included from
fs/nfsd/nfs4xdr.c:58:fs/nfsd/nfs4xdr_gen.h:86:9: error: redeclaration of enumerator ‘FATTR4_OPEN_ARGUMENTS’
86 |FATTR4_OPEN_ARGUMENTS= 86
| ^~~~~~~~~~~~~~~~~~~~~
In file included fromfs/nfsd/nfsfh.h:15,
fromfs/nfsd/state.h:41,
fromfs/nfsd/xdr4.h:40,
fromfs/nfsd/nfs4xdr.c:51:./include/linux/nfs4.h:518:9: note: previous definition of ‘FATTR4_OPEN_ARGUMENTS’ with type ‘enum <anonymous>’ 518 | FATTR4_OPEN_ARGUMENTS = 86, | ^~~~~~~~~~~~~~~~~~~~~fs/nfsd/nfs4xdr_gen.h:102:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_ACCESS’
102 |FATTR4_TIME_DELEG_ACCESS= 84
| ^~~~~~~~~~~~~~~~~~~~~~~~./include/linux/nfs4.h:516:9: note: previous definition of ‘FATTR4_TIME_DELEG_ACCESS’ with type ‘enum <anonymous>’ 516 | FATTR4_TIME_DELEG_ACCESS = 84, | ^~~~~~~~~~~~~~~~~~~~~~~~fs/nfsd/nfs4xdr_gen.h:106:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_MODIFY’
106 |FATTR4_TIME_DELEG_MODIFY= 85
| ^~~~~~~~~~~~~~~~~~~~~~~~./include/linux/nfs4.h:517:9: note: previous definition of ‘FATTR4_TIME_DELEG_MODIFY’ with type ‘enum <anonymous>’ 517 | FATTR4_TIME_DELEG_MODIFY = 85, | ^~~~~~~~~~~~~~~~~~~~~~~~ ------------------------8<---------------------------Quoted 3 lines
I'm not sure of the best way to work around this, unless we want to try
to split upnfs4.h.That header is shared with the client, so I consider it immutable for our purposes here.
Quoted 8 lines
One option would be to namespace the generated data items. Eg, name them:
XG_FATTR4_TIME_DELEG_ACCESS
XG_FATTR4_TIME_DELEG_MODIFYThat way they don't conflict with existing definitions.
I'd rather avoid that if we can. Having things named exactly the same as in the spec makes the code easier to read and understand.
What might be best is to autogenerate a header from a (combined) nfs4.x, and then have the old nfs4.h file include it. Then we'd just have to eliminate anything from nfs4.h that conflicts with the autogenerated symbols.
That's definitely not treating include/linux/nfs4.h as immutable, but we might still be able to avoid a lot of changes to the client code that way.
We'd need Trond and Anna to buy in on that though.
Quoted 18 lines
Quoted 11 lines
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr,&nfsd_open_arguments))Quoted 6 lines
OPEN_ARGUMENTS4is a large structure with 5 different bitmaps in it. We
probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer
instead (IMO).
Quoted 4 lines
The decoders are passed structs by reference already, fwiw. I had been considering the same for the encoder functions, for efficiency. I can give it a try.
Sounds good.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 71 lines · Jeff Layton
Quoted 70 lines · Chuck Lever
Quoted 58 lines · Jeff Layton
Quoted 14 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions.
The newfs/nfsd/nfs4_1.xfile can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.Signed-off-by Chuck Lever <[email protected]>---
fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++fs/nfsd/nfs4xdr_gen.c| 236
++++++++++++++++++++++++++++++++++++++++++
fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++Quoted 5 lines
3 files changed, 513 insertions(+)create mode 100644
fs/nfsd/nfs4_1.x
create mode 100644fs/nfsd/nfs4xdr_gen.c
create mode 100644fs/nfsd/nfs4xdr_gen.hI see the patches in your lkxdrgen branch. I gave this a try and started rebasing my delstid work on top of it, but I hit the same symbol conflicts I hit before once I started trying to include the full-blown
nfs4xdr_gen.hheader:------------------------8<--------------------------- In file included from
fs/nfsd/nfs4xdr.c:58:fs/nfsd/nfs4xdr_gen.h:86:9: error: redeclaration of enumerator ‘FATTR4_OPEN_ARGUMENTS’
86 |FATTR4_OPEN_ARGUMENTS= 86
| ^~~~~~~~~~~~~~~~~~~~~
In file included fromfs/nfsd/nfsfh.h:15,
fromfs/nfsd/state.h:41,
fromfs/nfsd/xdr4.h:40,
fromfs/nfsd/nfs4xdr.c:51:./include/linux/nfs4.h:518:9: note: previous definition of ‘FATTR4_OPEN_ARGUMENTS’ with type ‘enum <anonymous>’ 518 | FATTR4_OPEN_ARGUMENTS = 86, | ^~~~~~~~~~~~~~~~~~~~~fs/nfsd/nfs4xdr_gen.h:102:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_ACCESS’
102 |FATTR4_TIME_DELEG_ACCESS= 84
| ^~~~~~~~~~~~~~~~~~~~~~~~./include/linux/nfs4.h:516:9: note: previous definition of ‘FATTR4_TIME_DELEG_ACCESS’ with type ‘enum <anonymous>’ 516 | FATTR4_TIME_DELEG_ACCESS = 84, | ^~~~~~~~~~~~~~~~~~~~~~~~fs/nfsd/nfs4xdr_gen.h:106:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_MODIFY’
106 |FATTR4_TIME_DELEG_MODIFY= 85
| ^~~~~~~~~~~~~~~~~~~~~~~~./include/linux/nfs4.h:517:9: note: previous definition of ‘FATTR4_TIME_DELEG_MODIFY’ with type ‘enum <anonymous>’ 517 | FATTR4_TIME_DELEG_MODIFY = 85, | ^~~~~~~~~~~~~~~~~~~~~~~~ ------------------------8<---------------------------Quoted 3 lines
I'm not sure of the best way to work around this, unless we want to try
to split upnfs4.h.That header is shared with the client, so I consider it immutable for our purposes here.
One option would be to namespace the generated data items. Eg, name them:
Quoted 8 lines
Quoted 5 lines
XG_FATTR4_TIME_DELEG_ACCESS
XG_FATTR4_TIME_DELEG_MODIFYThat way they don't conflict with existing definitions.
I'd rather avoid that if we can. Having things named exactly the same as in the spec makes the code easier to read and understand.
Agreed, matching names is one of the reasons I started this work.
My thought was that the prefixed names could be fixed eventually after the hand-rolled code has been replaced.
Quoted 8 lines
What might be best is to autogenerate a header from a (combined) nfs4.x, and then have the old
nfs4.hfile include it. Then we'd just have to eliminate anything fromnfs4.hthat conflicts with the autogenerated symbols.That's definitely not treating
include/linux/nfs4.has immutable, but we might still be able to avoid a lot of changes to the client code that way.
Include the current nfs4xdr_gen.h in nfs4.h, and then remove from nfs4.h anything that has a naming conflict?
The downside of that is that approach mixes generated and hand-rolled code. Not an objection from me, but it was something that made Neil uncomfortable.
Quoted 1 line
We'd need Trond and Anna to buy in on that though.
Or the client can continue to use include/linux/nfs4.h and the server can start using its own copy of that header.
Signature · 1 line
Chuck Lever
Jeff Layton
maintainerRe: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 106 lines · Chuck Lever
Quoted 81 lines · Jeff Layton
Quoted 80 lines · Chuck Lever
Quoted 63 lines · Jeff Layton
Quoted 16 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions.
The newfs/nfsd/nfs4_1.xfile can be added to over time as other
parts of NFSD's XDR functions are converted to machine- generated
code.Signed-off-by Chuck Lever <[email protected]>---
fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++fs/nfsd/nfs4xdr_gen.c| 236
++++++++++++++++++++++++++++++++++++++++++
fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++Quoted 5 lines
3 files changed, 513 insertions(+)create mode 100644
fs/nfsd/nfs4_1.x
create mode 100644fs/nfsd/nfs4xdr_gen.c
create mode 100644fs/nfsd/nfs4xdr_gen.hI see the patches in your lkxdrgen branch. I gave this a try and
started rebasing my delstid work on top of it, but I hit the same
symbol conflicts I hit before once I started trying to include the
full-blownnfs4xdr_gen.hheader:------------------------8<--------------------------- In file included from
fs/nfsd/nfs4xdr.c:58:fs/nfsd/nfs4xdr_gen.h:86:9: error: redeclaration of enumerator ‘FATTR4_OPEN_ARGUMENTS’
86 |FATTR4_OPEN_ARGUMENTS= 86
| ^~~~~~~~~~~~~~~~~~~~~
In file included fromfs/nfsd/nfsfh.h:15,
fromfs/nfsd/state.h:41,
fromfs/nfsd/xdr4.h:40,
fromfs/nfsd/nfs4xdr.c:51:./include/linux/nfs4.h:518:9: note: previous definition of ‘FATTR4_OPEN_ARGUMENTS’ with type ‘enum <anonymous>’ 518 | FATTR4_OPEN_ARGUMENTS = 86, | ^~~~~~~~~~~~~~~~~~~~~fs/nfsd/nfs4xdr_gen.h:102:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_ACCESS’
102 |FATTR4_TIME_DELEG_ACCESS= 84
| ^~~~~~~~~~~~~~~~~~~~~~~~./include/linux/nfs4.h:516:9: note: previous definition of ‘FATTR4_TIME_DELEG_ACCESS’ with type ‘enum <anonymous>’ 516 | FATTR4_TIME_DELEG_ACCESS = 84, | ^~~~~~~~~~~~~~~~~~~~~~~~fs/nfsd/nfs4xdr_gen.h:106:9: error: redeclaration of enumerator ‘FATTR4_TIME_DELEG_MODIFY’
106 |FATTR4_TIME_DELEG_MODIFY= 85
| ^~~~~~~~~~~~~~~~~~~~~~~~./include/linux/nfs4.h:517:9: note: previous definition of ‘FATTR4_TIME_DELEG_MODIFY’ with type ‘enum <anonymous>’ 517 | FATTR4_TIME_DELEG_MODIFY = 85, | ^~~~~~~~~~~~~~~~~~~~~~~~ ------------------------8<---------------------------Quoted 4 lines
I'm not sure of the best way to work around this, unless we want to
try
to split upnfs4.h.That header is shared with the client, so I consider it immutable for our purposes here.
One option would be to namespace the generated data items. Eg, name
them:
XG_FATTR4_TIME_DELEG_ACCESS
XG_FATTR4_TIME_DELEG_MODIFYQuoted 6 lines
Quoted 2 lines
That way they don't conflict with existing definitions.
I'd rather avoid that if we can. Having things named exactly the same
as in the spec makes the code easier to read and understand.Agreed, matching names is one of the reasons I started this work.
My thought was that the prefixed names could be fixed eventually after the hand-rolled code has been replaced.
Quoted 10 lines
What might be best is to autogenerate a header from a (combined) nfs4.x, and then have the old
nfs4.hfile include it. Then we'd just
have to eliminate anything fromnfs4.hthat conflicts with the autogenerated symbols.That's definitely not treating
include/linux/nfs4.has immutable, but
we might still be able to avoid a lot of changes to the client code that way.
Quoted 7 lines
Include the current
nfs4xdr_gen.hinnfs4.h, and then remove fromnfs4.hanything that has a naming conflict?The downside of that is that approach mixes generated and hand-rolled code. Not an objection from me, but it was something that made Neil uncomfortable.
Not exactly. The hand-rolled code would become dependent on the generated headers, but we shouldn't need make changes to the generated headers themselves.
Quoted 6 lines
Quoted 2 lines
We'd need Trond and Anna to buy in on that though.
Or the client can continue to use
include/linux/nfs4.hand the server can start using its own copy of that header.
Sure, that would work too.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
In reply to Jeff LaytonQuoted 2 lines · Jeff Layton
I'm not sure of the best way to work around this, unless we want to try to split up
nfs4.h.
Can we just replace the structure definitions with the generated ones ASAP in one big patch? And then only do the marshalling code piece by piece as needed/wanted?
Quoted 8 lines
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr,&nfsd_open_arguments))
Quoted 4 lines
OPEN_ARGUMENTS4is a large structure with 5 different bitmaps in it. We probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer instead (IMO).
Yes. Probably marked const to clarify that it isn't supposed to be modified.
Jeff Layton
maintainerRe: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 10 lines · Christoph Hellwig
Quoted 3 lines · Jeff Layton
I'm not sure of the best way to work around this, unless we want to try
to split upnfs4.h.Can we just replace the structure definitions with the generated ones ASAP in one big patch? And then only do the marshalling code piece by
piece as needed/wanted?
I'll have a look. That probably means that we'll need to split nfs4.h, as not everything in there is defined by the protocol headers.
Quoted 18 lines
Quoted 11 lines
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr,&nfsd_open_arguments))Quoted 6 lines
OPEN_ARGUMENTS4is a large structure with 5 different bitmaps in it. We
probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer
instead (IMO).
Quoted 4 lines
Yes. Probably marked const to clarify that it isn't supposed to be modified.
Definitely, on the encoding side. Obviously, we can't on the decoding side.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
In reply to Jeff LaytonQuoted 11 lines · Jeff Layton
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr,&nfsd_open_arguments))
OPEN_ARGUMENTS4is a large structure with 5 different bitmaps in it. We probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer instead (IMO).
Meh. xdrgen already generates pass-by-reference encoders for structs. The problem is actually this bit of nfs4_1.x:
typedef open_arguments4 fattr4_open_arguments;
which generates:
boolxdrgen_encode_fattr4_open_arguments(struct xdr_stream *xdr, const fattr4_open_arguments value)
{
return xdrgen_encode_open_arguments4(xdr, &value);
};So, it's a bug in the way that xdrgen handles /typedefs/ of structs, not in the way that it handles the structs themselves.
Signature · 1 line
Chuck Lever
Re: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 20 lines · Chuck Lever
Quoted 11 lines · Jeff Layton
Also, as a side note:
fs/nfsd/nfs4xdr.c: In function ‘nfsd4_encode_fattr4_open_arguments’:fs/nfsd/nfs4xdr.c:3446:55: error: incompatible type for argument 2 of ‘xdrgen_encode_fattr4_open_arguments’
3446 | if (!xdrgen_encode_fattr4_open_arguments(xdr,&nfsd_open_arguments))
OPEN_ARGUMENTS4is a large structure with 5 different bitmaps in it. We probably don't want to pass that by value. When the tool is dealing with a struct, we should have it generate functions that take a pointer instead (IMO).Meh. xdrgen already generates pass-by-reference encoders for structs. The problem is actually this bit of nfs4_1.x:
typedef open_arguments4 fattr4_open_arguments;which generates:
Quoted 8 lines
bool
xdrgen_encode_fattr4_open_arguments(struct xdr_stream *xdr, const fattr4_open_arguments value){ return xdrgen_encode_open_arguments4(xdr, &value); };So, it's a bug in the way that xdrgen handles /typedefs/ of structs, not in the way that it handles the structs themselves.
I've addressed this in the lkxdrgen branch on kernel.org. I'm sure there are still bugs ;-)
Signature · 1 line
Chuck Lever
Jeff Layton
maintainerRe: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
In reply to [email protected]Quoted 509 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions. The new
fs/nfsd/nfs4_1.xfile can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.Signed-off-by Chuck Lever <[email protected]>--- fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++ 3 files changed, 513 insertions(+) create mode 100644 fs/nfsd/nfs4_1.x create mode 100644 fs/nfsd/nfs4xdr_gen.c create mode 100644 fs/nfsd/nfs4xdr_gen.hfs/nfsd/nfs4_1.x new file +164
-0@@ -0,0 +1,164 @@ +/* + * Copyright (c) 2010 IETF Trust and the persons identified + * as the document authors. All rights reserved. + * + * The document authors are identified in RFC 3530 and + * RFC 5661. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * - Neither the name of Internet Society, IETF or IETF + * Trust, nor the names of specific contributors, may be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +pragma header nfs4; + +/* + * Basic typedefs for RFC 1832 data type definitions + */ +typedef hyper int64_t; +typedef unsigned int uint32_t; + +/* + * Basic data types + */ +typedef uint32_t bitmap4<>; + +/* + * Timeval + */ +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + + +/* + * The following content was extracted from draft-ietf-nfsv4-delstid + */ + +typedef bool fattr4_offline; + + +const FATTR4_OFFLINE = 83; + + +struct open_arguments4 { + bitmap4 oa_share_access; + bitmap4 oa_share_deny; + bitmap4 oa_share_access_want; + bitmap4 oa_open_claim; + bitmap4 oa_create_mode; +}; + + +enum open_args_share_access4 { + OPEN_ARGS_SHARE_ACCESS_READ = 1, + OPEN_ARGS_SHARE_ACCESS_WRITE = 2, + OPEN_ARGS_SHARE_ACCESS_BOTH = 3 +}; + + +enum open_args_share_deny4 { + OPEN_ARGS_SHARE_DENY_NONE = 0, + OPEN_ARGS_SHARE_DENY_READ = 1, + OPEN_ARGS_SHARE_DENY_WRITE = 2, + OPEN_ARGS_SHARE_DENY_BOTH = 3 +}; + + +enum open_args_share_access_want4 { + OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG = 3, + OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG = 4, + OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL = 5, + OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL + = 17, + OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED + = 18, + OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 20, + OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 21 +}; + + +enum open_args_open_claim4 { + OPEN_ARGS_OPEN_CLAIM_NULL = 0, + OPEN_ARGS_OPEN_CLAIM_PREVIOUS = 1, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR = 2, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV = 3, + OPEN_ARGS_OPEN_CLAIM_FH = 4, + OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH = 5, + OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH = 6 +}; + + +enum open_args_createmode4 { + OPEN_ARGS_CREATEMODE_UNCHECKED4 = 0, + OPEN_ARGS_CREATE_MODE_GUARDED = 1, + OPEN_ARGS_CREATEMODE_EXCLUSIVE4 = 2, + OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 = 3 +}; + + +typedef open_arguments4 fattr4_open_arguments; +pragma public fattr4_open_arguments; + + +%/* +% * Determine what OPEN supports. +% */ +const FATTR4_OPEN_ARGUMENTS = 86; + + +const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 0x200000; + + +const OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010; + + +/* + * attributes for the delegation times being + * cached and served by the "client" + */ +typedef nfstime4 fattr4_time_deleg_access; +typedef nfstime4 fattr4_time_deleg_modify; + + +%/* +% * New RECOMMENDED Attribute for +% * delegation caching of times +% */ +const FATTR4_TIME_DELEG_ACCESS = 84; +const FATTR4_TIME_DELEG_MODIFY = 85; + + +const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000; +fs/nfsd/nfs4xdr_gen.c new file +236
-0@@ -0,0 +1,236 @@ +// SPDX-License-Identifier: GPL-2.0 +// Generated by xdrgen. Manual edits will be lost. +// XDR specification modification time: Mon Aug 19 23:28:23 2024 + +#include "nfs4xdr_gen.h" + +static bool __maybe_unused +xdrgen_decode_int64_t (struct xdr_stream *xdr,int64_t *ptr) +{ +return xdrgen_decode_hyper (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_uint32_t (struct xdr_stream *xdr,uint32_t *ptr) +{ +return xdrgen_decode_unsigned_int (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_bitmap4 (struct xdr_stream *xdr,bitmap4 *ptr) +{ +if (xdr_stream_decode_u32 (xdr, &ptr->count) <0 ) +return false; +for (u32 i =0 ; i < ptr->count; i++) +if (!xdrgen_decode_uint32_t (xdr, &ptr->element[i])) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_nfstime4 (struct xdr_stream *xdr,struct nfstime4 *ptr) +{ +if (!xdrgen_decode_int64_t (xdr, &ptr->seconds)) +return false; +if (!xdrgen_decode_uint32_t (xdr, &ptr->nseconds)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_offline (struct xdr_stream *xdr,fattr4_offline *ptr) +{ +return xdrgen_decode_bool (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_open_arguments4 (struct xdr_stream *xdr,struct open_arguments4 *ptr) +{ +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_access)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_deny)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_access_want)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_open_claim)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_create_mode)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_open_args_share_access4 (struct xdr_stream *xdr,enum open_args_share_access4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_deny4 (struct xdr_stream *xdr,enum open_args_share_deny4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_access_want4 (struct xdr_stream *xdr,enum open_args_share_access_want4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_open_claim4 (struct xdr_stream *xdr,enum open_args_open_claim4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_createmode4 (struct xdr_stream *xdr,enum open_args_createmode4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +bool +xdrgen_decode_fattr4_open_arguments (struct xdr_stream *xdr,fattr4_open_arguments *ptr) +{ +return xdrgen_decode_open_arguments4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_time_deleg_access (struct xdr_stream *xdr,fattr4_time_deleg_access *ptr) +{ +return xdrgen_decode_nfstime4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_time_deleg_modify (struct xdr_stream *xdr,fattr4_time_deleg_modify *ptr) +{ +return xdrgen_decode_nfstime4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_encode_int64_t (struct xdr_stream *xdr,const int64_t value) +{ +return xdrgen_encode_hyper (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_uint32_t (struct xdr_stream *xdr,const uint32_t value) +{ +return xdrgen_encode_unsigned_int (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_bitmap4 (struct xdr_stream *xdr,const bitmap4 value) +{ +if (xdr_stream_encode_u32 (xdr, value.count) !=XDR_UNIT ) +return false; +for (u32 i =0 ; i < value.count; i++) +if (!xdrgen_encode_uint32_t (xdr, value.element[i])) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_nfstime4 (struct xdr_stream *xdr,const struct nfstime4 *value) +{ +if (!xdrgen_encode_int64_t (xdr, value->seconds)) +return false; +if (!xdrgen_encode_uint32_t (xdr, value->nseconds)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_offline (struct xdr_stream *xdr,const fattr4_offline value) +{ +return xdrgen_encode_bool (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_open_arguments4 (struct xdr_stream *xdr,const struct open_arguments4 *value) +{ +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_access)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_deny)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_access_want)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_open_claim)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_create_mode)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_open_args_share_access4 (struct xdr_stream *xdr,enum open_args_share_access4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_deny4 (struct xdr_stream *xdr,enum open_args_share_deny4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_access_want4 (struct xdr_stream *xdr,enum open_args_share_access_want4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_open_claim4 (struct xdr_stream *xdr,enum open_args_open_claim4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_createmode4 (struct xdr_stream *xdr,enum open_args_createmode4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +bool +xdrgen_encode_fattr4_open_arguments (struct xdr_stream *xdr,const fattr4_open_arguments value) +{ +return xdrgen_encode_open_arguments4 (xdr, &value); +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_time_deleg_access (struct xdr_stream *xdr,const fattr4_time_deleg_access value) +{ +return xdrgen_encode_nfstime4 (xdr, &value); +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_time_deleg_modify (struct xdr_stream *xdr,const fattr4_time_deleg_modify value) +{ +return xdrgen_encode_nfstime4 (xdr, &value); +};fs/nfsd/nfs4xdr_gen.h new file +73
-0@@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification modification time: Mon Aug 19 23:28:23 2024 */ + +#ifndef _LINUX_NFS4_XDRGEN_H +#define _LINUX_NFS4_XDRGEN_H + +#include <linux/types.h> +#include <linux/sunrpc/svc.h> + +#include <linux/sunrpc/xdrgen-builtins.h> + +typedef s64 int64_t ; + +typedef u32 uint32_t ; + +typedef struct { +u32 count; +uint32_t *element; +}bitmap4 ; + +struct nfstime4 { +int64_t seconds; +uint32_t nseconds; +}; + +typedef bool fattr4_offline ; + +enum { +FATTR4_OFFLINE =83 +}; + +struct open_arguments4 { +bitmap4 oa_share_access; +bitmap4 oa_share_deny; +bitmap4 oa_share_access_want; +bitmap4 oa_open_claim; +bitmap4 oa_create_mode; +}; + +enum open_args_share_access4 { +OPEN_ARGS_SHARE_ACCESS_READ =1 , +OPEN_ARGS_SHARE_ACCESS_WRITE =2 , +OPEN_ARGS_SHARE_ACCESS_BOTH =3 , +}; + +enum open_args_share_deny4 { +OPEN_ARGS_SHARE_DENY_NONE =0 , +OPEN_ARGS_SHARE_DENY_READ =1 , +OPEN_ARGS_SHARE_DENY_WRITE =2 , +OPEN_ARGS_SHARE_DENY_BOTH =3 , +}; + +enum open_args_share_access_want4 { +OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG =3 , +OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG =4 , +OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL =5 , +OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL =17 , +OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED =18 , +OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =20 , +OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =21 , +}; + +enum open_args_open_claim4 { +OPEN_ARGS_OPEN_CLAIM_NULL =0 , +OPEN_ARGS_OPEN_CLAIM_PREVIOUS =1 , +OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR =2 , +OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV =3 , +OPEN_ARGS_OPEN_CLAIM_FH =4 , +OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH =5 , +OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH =6 , +}; +
fs/nfsd/nfs4xdr_gen.h line 83
Quoted 10 lines
fs/nfsd/nfs4xdr_gen.h new file +10
-0+enum open_args_createmode4 { +OPEN_ARGS_CREATEMODE_UNCHECKED4 =0 , +OPEN_ARGS_CREATE_MODE_GUARDED =1 , +OPEN_ARGS_CREATEMODE_EXCLUSIVE4 =2 , +OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 =3 , +}; + +typedef struct open_arguments4 fattr4_open_arguments ; +bool xdrgen_decode_fattr4_open_arguments (struct xdr_stream *xdr,fattr4_open_arguments *ptr); +bool xdrgen_encode_fattr4_open_arguments (struct xdr_stream *xdr,const fattr4_open_arguments value);
Question: why does xdrgen generate the above prototype functions for the encoder and decoder for that typedef, but no corresponding prototypes for the nfstime4 ones below?
Quoted 31 lines
fs/nfsd/nfs4xdr_gen.h new file +30
-0+ +enum { +FATTR4_OPEN_ARGUMENTS =86 +}; + +enum { +OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =0x200000 +}; + +enum { +OPEN4_RESULT_NO_OPEN_STATEID =0x00000010 +}; + +typedef struct nfstime4 fattr4_time_deleg_access ; + +typedef struct nfstime4 fattr4_time_deleg_modify ; + +enum { +FATTR4_TIME_DELEG_ACCESS =84 +}; + +enum { +FATTR4_TIME_DELEG_MODIFY =85 +}; + +enum { +OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =0x100000 +}; + +#endif /* _LINUX_NFS4_XDRGEN_H */
Signature · 4 lines
Jeff Layton <[email protected]> -- Jeff Layton <[email protected]>
Re: [RFC PATCH 2/2] NFSD: Create an initial nfs4_1.x file
Quoted 520 lines · Jeff Layton
Quoted 515 lines · On Tue, 2024-08-20 at 10:46 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
Build an NFSv4 protocol snippet to support the delstid extensions. The new
fs/nfsd/nfs4_1.xfile can be added to over time as other parts of NFSD's XDR functions are converted to machine-generated code.Signed-off-by Chuck Lever <[email protected]>---
fs/nfsd/nfs4_1.x | 164 +++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++++++++++++++++++++++++++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 ++++++++++++++++++++ 3 files changed, 513 insertions(+)create mode 100644
fs/nfsd/nfs4_1.x
create mode 100644fs/nfsd/nfs4xdr_gen.c
create mode 100644fs/nfsd/nfs4xdr_gen.hfs/nfsd/nfs4_1.x new file +164
-0@@ -0,0 +1,164 @@ +/* + * Copyright (c) 2010 IETF Trust and the persons identified + * as the document authors. All rights reserved. + * + * The document authors are identified in RFC 3530 and + * RFC 5661. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * - Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * - Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * - Neither the name of Internet Society, IETF or IETF + * Trust, nor the names of specific contributors, may be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS + * AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +pragma header nfs4; + +/* + * Basic typedefs for RFC 1832 data type definitions + */ +typedef hyper int64_t; +typedef unsigned int uint32_t; + +/* + * Basic data types + */ +typedef uint32_t bitmap4<>; + +/* + * Timeval + */ +struct nfstime4 { + int64_t seconds; + uint32_t nseconds; +}; + + +/* + * The following content was extracted from draft-ietf-nfsv4-delstid + */ + +typedef bool fattr4_offline; + + +const FATTR4_OFFLINE = 83; + + +struct open_arguments4 { + bitmap4 oa_share_access; + bitmap4 oa_share_deny; + bitmap4 oa_share_access_want; + bitmap4 oa_open_claim; + bitmap4 oa_create_mode; +}; + + +enum open_args_share_access4 { + OPEN_ARGS_SHARE_ACCESS_READ = 1, + OPEN_ARGS_SHARE_ACCESS_WRITE = 2, + OPEN_ARGS_SHARE_ACCESS_BOTH = 3 +}; + + +enum open_args_share_deny4 { + OPEN_ARGS_SHARE_DENY_NONE = 0, + OPEN_ARGS_SHARE_DENY_READ = 1, + OPEN_ARGS_SHARE_DENY_WRITE = 2, + OPEN_ARGS_SHARE_DENY_BOTH = 3 +}; + + +enum open_args_share_access_want4 { + OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG = 3, + OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG = 4, + OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL = 5, + OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL + = 17, + OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED + = 18, + OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 20, + OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 21 +}; + + +enum open_args_open_claim4 { + OPEN_ARGS_OPEN_CLAIM_NULL = 0, + OPEN_ARGS_OPEN_CLAIM_PREVIOUS = 1, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR = 2, + OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV = 3, + OPEN_ARGS_OPEN_CLAIM_FH = 4, + OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH = 5, + OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH = 6 +}; + + +enum open_args_createmode4 { + OPEN_ARGS_CREATEMODE_UNCHECKED4 = 0, + OPEN_ARGS_CREATE_MODE_GUARDED = 1, + OPEN_ARGS_CREATEMODE_EXCLUSIVE4 = 2, + OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 = 3 +}; + + +typedef open_arguments4 fattr4_open_arguments; +pragma public fattr4_open_arguments; + + +%/* +% * Determine what OPEN supports. +% */ +const FATTR4_OPEN_ARGUMENTS = 86; + + +const OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION = 0x200000; + + +const OPEN4_RESULT_NO_OPEN_STATEID = 0x00000010; + + +/* + * attributes for the delegation times being + * cached and served by the "client" + */ +typedef nfstime4 fattr4_time_deleg_access; +typedef nfstime4 fattr4_time_deleg_modify; + + +%/* +% * New RECOMMENDED Attribute for +% * delegation caching of times +% */ +const FATTR4_TIME_DELEG_ACCESS = 84; +const FATTR4_TIME_DELEG_MODIFY = 85; + + +const OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS = 0x100000; +fs/nfsd/nfs4xdr_gen.c new file +236
-0@@ -0,0 +1,236 @@ +// SPDX-License-Identifier: GPL-2.0 +// Generated by xdrgen. Manual edits will be lost. +// XDR specification modification time: Mon Aug 19 23:28:23 2024 + +#include "nfs4xdr_gen.h" + +static bool __maybe_unused +xdrgen_decode_int64_t (struct xdr_stream *xdr,int64_t *ptr) +{ +return xdrgen_decode_hyper (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_uint32_t (struct xdr_stream *xdr,uint32_t *ptr) +{ +return xdrgen_decode_unsigned_int (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_bitmap4 (struct xdr_stream *xdr,bitmap4 *ptr) +{ +if (xdr_stream_decode_u32 (xdr, &ptr->count) <0 ) +return false; +for (u32 i =0 ; i < ptr->count; i++) +if (!xdrgen_decode_uint32_t (xdr, &ptr->element[i])) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_nfstime4 (struct xdr_stream *xdr,struct nfstime4 *ptr) +{ +if (!xdrgen_decode_int64_t (xdr, &ptr->seconds)) +return false; +if (!xdrgen_decode_uint32_t (xdr, &ptr->nseconds)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_offline (struct xdr_stream *xdr,fattr4_offline *ptr) +{ +return xdrgen_decode_bool (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_open_arguments4 (struct xdr_stream *xdr,struct open_arguments4 *ptr) +{ +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_access)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_deny)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_share_access_want)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_open_claim)) +return false; +if (!xdrgen_decode_bitmap4 (xdr, &ptr->oa_create_mode)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_decode_open_args_share_access4 (struct xdr_stream *xdr,enum open_args_share_access4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_deny4 (struct xdr_stream *xdr,enum open_args_share_deny4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_share_access_want4 (struct xdr_stream *xdr,enum open_args_share_access_want4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_open_claim4 (struct xdr_stream *xdr,enum open_args_open_claim4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +static bool __maybe_unused +xdrgen_decode_open_args_createmode4 (struct xdr_stream *xdr,enum open_args_createmode4 *ptr) +{ +u32 val; + +if (xdr_stream_decode_u32 (xdr, &val) <0 ) +return false; + *ptr = val; +return true; +} + +bool +xdrgen_decode_fattr4_open_arguments (struct xdr_stream *xdr,fattr4_open_arguments *ptr) +{ +return xdrgen_decode_open_arguments4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_time_deleg_access (struct xdr_stream *xdr,fattr4_time_deleg_access *ptr) +{ +return xdrgen_decode_nfstime4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_decode_fattr4_time_deleg_modify (struct xdr_stream *xdr,fattr4_time_deleg_modify *ptr) +{ +return xdrgen_decode_nfstime4 (xdr, ptr); +}; + +static bool __maybe_unused +xdrgen_encode_int64_t (struct xdr_stream *xdr,const int64_t value) +{ +return xdrgen_encode_hyper (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_uint32_t (struct xdr_stream *xdr,const uint32_t value) +{ +return xdrgen_encode_unsigned_int (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_bitmap4 (struct xdr_stream *xdr,const bitmap4 value) +{ +if (xdr_stream_encode_u32 (xdr, value.count) !=XDR_UNIT ) +return false; +for (u32 i =0 ; i < value.count; i++) +if (!xdrgen_encode_uint32_t (xdr, value.element[i])) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_nfstime4 (struct xdr_stream *xdr,const struct nfstime4 *value) +{ +if (!xdrgen_encode_int64_t (xdr, value->seconds)) +return false; +if (!xdrgen_encode_uint32_t (xdr, value->nseconds)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_offline (struct xdr_stream *xdr,const fattr4_offline value) +{ +return xdrgen_encode_bool (xdr, value); +}; + +static bool __maybe_unused +xdrgen_encode_open_arguments4 (struct xdr_stream *xdr,const struct open_arguments4 *value) +{ +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_access)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_deny)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_share_access_want)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_open_claim)) +return false; +if (!xdrgen_encode_bitmap4 (xdr, value->oa_create_mode)) +return false; +return true; +}; + +static bool __maybe_unused +xdrgen_encode_open_args_share_access4 (struct xdr_stream *xdr,enum open_args_share_access4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_deny4 (struct xdr_stream *xdr,enum open_args_share_deny4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_share_access_want4 (struct xdr_stream *xdr,enum open_args_share_access_want4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_open_claim4 (struct xdr_stream *xdr,enum open_args_open_claim4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +static bool __maybe_unused +xdrgen_encode_open_args_createmode4 (struct xdr_stream *xdr,enum open_args_createmode4 value) +{ +return xdr_stream_encode_u32 (xdr, value) ==XDR_UNIT ; +} + +bool +xdrgen_encode_fattr4_open_arguments (struct xdr_stream *xdr,const fattr4_open_arguments value) +{ +return xdrgen_encode_open_arguments4 (xdr, &value); +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_time_deleg_access (struct xdr_stream *xdr,const fattr4_time_deleg_access value) +{ +return xdrgen_encode_nfstime4 (xdr, &value); +}; + +static bool __maybe_unused +xdrgen_encode_fattr4_time_deleg_modify (struct xdr_stream *xdr,const fattr4_time_deleg_modify value) +{ +return xdrgen_encode_nfstime4 (xdr, &value); +};fs/nfsd/nfs4xdr_gen.h new file +80
-0@@ -0,0 +1,113 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Generated by xdrgen. Manual edits will be lost. */ +/* XDR specification modification time: Mon Aug 19 23:28:23 2024 */ + +#ifndef _LINUX_NFS4_XDRGEN_H +#define _LINUX_NFS4_XDRGEN_H + +#include <linux/types.h> +#include <linux/sunrpc/svc.h> + +#include <linux/sunrpc/xdrgen-builtins.h> + +typedef s64 int64_t ; + +typedef u32 uint32_t ; + +typedef struct { +u32 count; +uint32_t *element; +}bitmap4 ; + +struct nfstime4 { +int64_t seconds; +uint32_t nseconds; +}; + +typedef bool fattr4_offline ; + +enum { +FATTR4_OFFLINE =83 +}; + +struct open_arguments4 { +bitmap4 oa_share_access; +bitmap4 oa_share_deny; +bitmap4 oa_share_access_want; +bitmap4 oa_open_claim; +bitmap4 oa_create_mode; +}; + +enum open_args_share_access4 { +OPEN_ARGS_SHARE_ACCESS_READ =1 , +OPEN_ARGS_SHARE_ACCESS_WRITE =2 , +OPEN_ARGS_SHARE_ACCESS_BOTH =3 , +}; + +enum open_args_share_deny4 { +OPEN_ARGS_SHARE_DENY_NONE =0 , +OPEN_ARGS_SHARE_DENY_READ =1 , +OPEN_ARGS_SHARE_DENY_WRITE =2 , +OPEN_ARGS_SHARE_DENY_BOTH =3 , +}; + +enum open_args_share_access_want4 { +OPEN_ARGS_SHARE_ACCESS_WANT_ANY_DELEG =3 , +OPEN_ARGS_SHARE_ACCESS_WANT_NO_DELEG =4 , +OPEN_ARGS_SHARE_ACCESS_WANT_CANCEL =5 , +OPEN_ARGS_SHARE_ACCESS_WANT_SIGNAL_DELEG_WHEN_RESRC_AVAIL =17 , +OPEN_ARGS_SHARE_ACCESS_WANT_PUSH_DELEG_WHEN_UNCONTENDED =18 , +OPEN_ARGS_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =20 , +OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =21 , +}; + +enum open_args_open_claim4 { +OPEN_ARGS_OPEN_CLAIM_NULL =0 , +OPEN_ARGS_OPEN_CLAIM_PREVIOUS =1 , +OPEN_ARGS_OPEN_CLAIM_DELEGATE_CUR =2 , +OPEN_ARGS_OPEN_CLAIM_DELEGATE_PREV =3 , +OPEN_ARGS_OPEN_CLAIM_FH =4 , +OPEN_ARGS_OPEN_CLAIM_DELEG_CUR_FH =5 , +OPEN_ARGS_OPEN_CLAIM_DELEG_PREV_FH =6 , +}; + +enum open_args_createmode4 { +OPEN_ARGS_CREATEMODE_UNCHECKED4 =0 , +OPEN_ARGS_CREATE_MODE_GUARDED =1 , +OPEN_ARGS_CREATEMODE_EXCLUSIVE4 =2 , +OPEN_ARGS_CREATE_MODE_EXCLUSIVE4_1 =3 , +}; +
Quoted 8 lines
fs/nfsd/nfs4xdr_gen.h line 83
Quoted 4 lines
fs/nfsd/nfs4xdr_gen.h new file +3
-0+typedef struct open_arguments4 fattr4_open_arguments ; +bool xdrgen_decode_fattr4_open_arguments (struct xdr_stream *xdr,fattr4_open_arguments *ptr); +bool xdrgen_encode_fattr4_open_arguments (struct xdr_stream *xdr,const fattr4_open_arguments value);Question: why does xdrgen generate the above prototype functions for the encoder and decoder for that typedef, but no corresponding prototypes for the nfstime4 ones below?
Because I added a "pragma public" in the .x file for the fattr4_open_arguments type.
You can add a "pragma public" for nfstime4 as well. Have a look in the README for examples.
But I don't think you need one unless you have code that wants to call xdrgen_encode_nfstime4().
Quoted 22 lines
Quoted 22 lines
fs/nfsd/nfs4xdr_gen.h new file +22
-0+ +enum { +FATTR4_OPEN_ARGUMENTS =86 +}; + +enum { +OPEN4_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION =0x200000 +}; + +enum { +OPEN4_RESULT_NO_OPEN_STATEID =0x00000010 +}; + +typedef struct nfstime4 fattr4_time_deleg_access ; + +typedef struct nfstime4 fattr4_time_deleg_modify ; + +enum { +FATTR4_TIME_DELEG_ACCESS =84 +}; + +enum {
Quoted 14 lines
Quoted 8 lines
fs/nfsd/nfs4xdr_gen.h new file +8
-0+FATTR4_TIME_DELEG_MODIFY =85 +}; + +enum { +OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS =0x100000 +}; + +#endif /* _LINUX_NFS4_XDRGEN_H */ Signature · 4 lines
Jeff Layton <[email protected]> -- Jeff Layton <[email protected]>
--
Chuck Lever
Jeff Layton
maintainerQuoted 249 lines · On Tue, 2024-08-20 at 10:45 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
For a description of this work-in-progress, see the new README file. For unfinished work items, ditto.
The first patch adds the tool.
The second patch is an nfs4_1.x file that I created to confirm that the tool indeed works for Jeff's purposes. Actual generated header and source are in
fs/nfsd/nfs4xdr_gen.? .Feel free to ignore 2/2. It is included here only to demonstrate the tool's new "pragma" directives that I think can avoid the need to hand-edit generated source, as discussed in an earlier thread. Grep the new README or nfs4_1.x for "pragma".
These patches apply to v6.11-rc4, but can be rebased on nfsd-next if they are found merge-worthy. See also:
https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=lkxdrgen
For review, note that the numerous .j2 files are all tiny and can be skimmed in favor of the .py files, where the tool's logic is.
All Python-related advice and guidance is gratefully accepted.
--
Chuck Lever (2):
tools: Add xdrgen
NFSD: Create an initial nfs4_1.x filefs/nfsd/nfs4_1.x | 164 +++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 +++++ include/linux/sunrpc/xdrgen-builtins.h | 253 ++++++++++ tools/net/sunrpc/xdrgen/.gitignore | 2 + tools/net/sunrpc/xdrgen/README | 231 +++++++++ tools/net/sunrpc/xdrgen/__init__.py | 0 tools/net/sunrpc/xdrgen/common.py | 21 + .../net/sunrpc/xdrgen/generators/__init__.py | 0 .../sunrpc/xdrgen/generators/boilerplate.py | 66 +++ .../net/sunrpc/xdrgen/generators/constant.py | 38 ++ tools/net/sunrpc/xdrgen/generators/enum.py | 67 +++ tools/net/sunrpc/xdrgen/generators/program.py | 96 ++++ tools/net/sunrpc/xdrgen/generators/struct.py | 435 +++++++++++++++++ tools/net/sunrpc/xdrgen/generators/typedef.py | 282 +++++++++++ tools/net/sunrpc/xdrgen/generators/union.py | 297 ++++++++++++ tools/net/sunrpc/xdrgen/subcmds/__init__.py | 0 tools/net/sunrpc/xdrgen/subcmds/header.py | 62 +++ tools/net/sunrpc/xdrgen/subcmds/lint.py | 28 ++ tools/net/sunrpc/xdrgen/subcmds/source.py | 82 ++++ .../templates/C/boilerplate/header_bottom.j2 | 3 + .../templates/C/boilerplate/header_top.j2 | 11 + .../templates/C/boilerplate/source_top.j2 | 5 + .../templates/C/constants/declaration.j2 | 5 + .../templates/C/enum/declaration/close.j2 | 7 + .../C/enum/declaration/enumerator.j2 | 2 + .../templates/C/enum/declaration/open.j2 | 3 + .../xdrgen/templates/C/enum/decoder/enum.j2 | 19 + .../xdrgen/templates/C/enum/encoder/enum.j2 | 14 + .../C/program/declaration/argument.j2 | 2 + .../templates/C/program/declaration/result.j2 | 2 + .../templates/C/program/decoder/argument.j2 | 21 + .../templates/C/program/encoder/result.j2 | 21 + .../templates/C/struct/declaration/basic.j2 | 5 + .../templates/C/struct/declaration/close.j2 | 7 + .../struct/declaration/fixed_length_array.j2 | 5 + .../struct/declaration/fixed_length_opaque.j2 | 5 + .../templates/C/struct/declaration/open.j2 | 6 + .../C/struct/declaration/optional_data.j2 | 5 + .../C/struct/declaration/pointer-open.j2 | 6 + .../declaration/variable_length_array.j2 | 8 + .../declaration/variable_length_opaque.j2 | 5 + .../declaration/variable_length_string.j2 | 5 + .../templates/C/struct/decoder/basic.j2 | 6 + .../templates/C/struct/decoder/close.j2 | 3 + .../C/struct/decoder/fixed_length_array.j2 | 8 + .../C/struct/decoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/decoder/open.j2 | 12 + .../C/struct/decoder/optional_data.j2 | 6 + .../C/struct/decoder/pointer-open.j2 | 22 + .../C/struct/decoder/variable_length_array.j2 | 13 + .../struct/decoder/variable_length_opaque.j2 | 6 + .../struct/decoder/variable_length_string.j2 | 6 + .../templates/C/struct/encoder/basic.j2 | 10 + .../templates/C/struct/encoder/close.j2 | 3 + .../C/struct/encoder/fixed_length_array.j2 | 12 + .../C/struct/encoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/encoder/open.j2 | 12 + .../C/struct/encoder/optional_data.j2 | 6 + .../C/struct/encoder/pointer-open.j2 | 20 + .../C/struct/encoder/variable_length_array.j2 | 15 + .../struct/encoder/variable_length_opaque.j2 | 8 + .../struct/encoder/variable_length_string.j2 | 8 + .../templates/C/typedef/declaration/basic.j2 | 11 + .../typedef/declaration/fixed_length_array.j2 | 11 + .../declaration/fixed_length_opaque.j2 | 11 + .../declaration/variable_length_array.j2 | 14 + .../declaration/variable_length_opaque.j2 | 11 + .../declaration/variable_length_string.j2 | 11 + .../templates/C/typedef/decoder/basic.j2 | 17 + .../C/typedef/decoder/fixed_length_array.j2 | 25 + .../C/typedef/decoder/fixed_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_array.j2 | 26 ++ .../typedef/decoder/variable_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_string.j2 | 17 + .../templates/C/typedef/encoder/basic.j2 | 21 + .../C/typedef/encoder/fixed_length_array.j2 | 25 + .../C/typedef/encoder/fixed_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_array.j2 | 30 ++ .../typedef/encoder/variable_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_string.j2 | 17 + .../C/union/declaration/case_spec.j2 | 2 + .../templates/C/union/declaration/close.j2 | 8 + .../C/union/declaration/default_spec.j2 | 2 + .../templates/C/union/declaration/open.j2 | 6 + .../C/union/declaration/switch_spec.j2 | 3 + .../xdrgen/templates/C/union/decoder/basic.j2 | 6 + .../xdrgen/templates/C/union/decoder/break.j2 | 2 + .../templates/C/union/decoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/close.j2 | 4 + .../templates/C/union/decoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/open.j2 | 12 + .../C/union/decoder/optional_data.j2 | 6 + .../templates/C/union/decoder/switch_spec.j2 | 7 + .../C/union/decoder/variable_length_array.j2 | 13 + .../C/union/decoder/variable_length_opaque.j2 | 6 + .../C/union/decoder/variable_length_string.j2 | 6 + .../xdrgen/templates/C/union/decoder/void.j2 | 3 + .../xdrgen/templates/C/union/encoder/basic.j2 | 10 + .../xdrgen/templates/C/union/encoder/break.j2 | 2 + .../templates/C/union/encoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/close.j2 | 4 + .../templates/C/union/encoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/open.j2 | 12 + .../templates/C/union/encoder/switch_spec.j2 | 7 + .../xdrgen/templates/C/union/encoder/void.j2 | 3 + tools/net/sunrpc/xdrgen/tests/test.x | 36 ++ tools/net/sunrpc/xdrgen/xdr | 1 + tools/net/sunrpc/xdrgen/xdr.ebnf | 117 +++++ tools/net/sunrpc/xdrgen/xdr_ast.py | 437 ++++++++++++++++++ tools/net/sunrpc/xdrgen/xdr_parse.py | 20 + tools/net/sunrpc/xdrgen/xdrgen | 95 ++++ 112 files changed, 3986 insertions(+) create mode 100644 fs/nfsd/nfs4_1.x create mode 100644 fs/nfsd/nfs4xdr_gen.c create mode 100644 fs/nfsd/nfs4xdr_gen.h create mode 100644 include/linux/sunrpc/xdrgen-builtins.h create mode 100644 tools/net/sunrpc/xdrgen/.gitignore create mode 100644 tools/net/sunrpc/xdrgen/README create mode 100644 tools/net/sunrpc/xdrgen/__init__.py create mode 100644 tools/net/sunrpc/xdrgen/common.py create mode 100644 tools/net/sunrpc/xdrgen/generators/__init__.py create mode 100644 tools/net/sunrpc/xdrgen/generators/boilerplate.py create mode 100644 tools/net/sunrpc/xdrgen/generators/constant.py create mode 100644 tools/net/sunrpc/xdrgen/generators/enum.py create mode 100644 tools/net/sunrpc/xdrgen/generators/program.py create mode 100644 tools/net/sunrpc/xdrgen/generators/struct.py create mode 100644 tools/net/sunrpc/xdrgen/generators/typedef.py create mode 100644 tools/net/sunrpc/xdrgen/generators/union.py create mode 100644 tools/net/sunrpc/xdrgen/subcmds/__init__.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/header.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/lint.py create mode 100755 tools/net/sunrpc/xdrgen/subcmds/source.py create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_bottom.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_top.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/source_top.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/constants/declaration.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enumerator.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/pointer-open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/declaration/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2
Quoted 9 lines
create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2 create mode 100644 tools/net/sunrpc/xdrgen/tests/test.x create mode 120000 tools/net/sunrpc/xdrgen/xdr create mode 100644 tools/net/sunrpc/xdrgen/xdr.ebnf create mode 100644 tools/net/sunrpc/xdrgen/xdr_ast.py create mode 100644 tools/net/sunrpc/xdrgen/xdr_parse.py create mode 100755 tools/net/sunrpc/xdrgen/xdrgen
This all looks great to me. I really support autogenerating our XDR boilerplate, particularly as I've been looking at implementing CB_NOTIFY (which would be quite tedious to roll by hand). This would make it a lot simpler and less error prone.
Do you have these patches in a branch in your tree that I could pick from?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 264 lines · Jeff Layton
Quoted 249 lines · On Tue, 2024-08-20 at 10:45 -0400, [email protected] wrote:
From: Chuck Lever <[email protected]>
For a description of this work-in-progress, see the new README file. For unfinished work items, ditto.
The first patch adds the tool.
The second patch is an nfs4_1.x file that I created to confirm that the tool indeed works for Jeff's purposes. Actual generated header and source are in
fs/nfsd/nfs4xdr_gen.? .Feel free to ignore 2/2. It is included here only to demonstrate the tool's new "pragma" directives that I think can avoid the need to hand-edit generated source, as discussed in an earlier thread. Grep the new README or nfs4_1.x for "pragma".
These patches apply to v6.11-rc4, but can be rebased on nfsd-next if they are found merge-worthy. See also:
https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=lkxdrgen
For review, note that the numerous .j2 files are all tiny and can be skimmed in favor of the .py files, where the tool's logic is.
All Python-related advice and guidance is gratefully accepted.
--
Chuck Lever (2):
tools: Add xdrgen
NFSD: Create an initial nfs4_1.x filefs/nfsd/nfs4_1.x | 164 +++++++ fs/nfsd/nfs4xdr_gen.c | 236 ++++++++++ fs/nfsd/nfs4xdr_gen.h | 113 +++++ include/linux/sunrpc/xdrgen-builtins.h | 253 ++++++++++ tools/net/sunrpc/xdrgen/.gitignore | 2 + tools/net/sunrpc/xdrgen/README | 231 +++++++++ tools/net/sunrpc/xdrgen/__init__.py | 0 tools/net/sunrpc/xdrgen/common.py | 21 + .../net/sunrpc/xdrgen/generators/__init__.py | 0 .../sunrpc/xdrgen/generators/boilerplate.py | 66 +++ .../net/sunrpc/xdrgen/generators/constant.py | 38 ++ tools/net/sunrpc/xdrgen/generators/enum.py | 67 +++ tools/net/sunrpc/xdrgen/generators/program.py | 96 ++++ tools/net/sunrpc/xdrgen/generators/struct.py | 435 +++++++++++++++++ tools/net/sunrpc/xdrgen/generators/typedef.py | 282 +++++++++++ tools/net/sunrpc/xdrgen/generators/union.py | 297 ++++++++++++ tools/net/sunrpc/xdrgen/subcmds/__init__.py | 0 tools/net/sunrpc/xdrgen/subcmds/header.py | 62 +++ tools/net/sunrpc/xdrgen/subcmds/lint.py | 28 ++ tools/net/sunrpc/xdrgen/subcmds/source.py | 82 ++++ .../templates/C/boilerplate/header_bottom.j2 | 3 + .../templates/C/boilerplate/header_top.j2 | 11 + .../templates/C/boilerplate/source_top.j2 | 5 + .../templates/C/constants/declaration.j2 | 5 + .../templates/C/enum/declaration/close.j2 | 7 + .../C/enum/declaration/enumerator.j2 | 2 + .../templates/C/enum/declaration/open.j2 | 3 + .../xdrgen/templates/C/enum/decoder/enum.j2 | 19 + .../xdrgen/templates/C/enum/encoder/enum.j2 | 14 + .../C/program/declaration/argument.j2 | 2 + .../templates/C/program/declaration/result.j2 | 2 + .../templates/C/program/decoder/argument.j2 | 21 + .../templates/C/program/encoder/result.j2 | 21 + .../templates/C/struct/declaration/basic.j2 | 5 + .../templates/C/struct/declaration/close.j2 | 7 + .../struct/declaration/fixed_length_array.j2 | 5 + .../struct/declaration/fixed_length_opaque.j2 | 5 + .../templates/C/struct/declaration/open.j2 | 6 + .../C/struct/declaration/optional_data.j2 | 5 + .../C/struct/declaration/pointer-open.j2 | 6 + .../declaration/variable_length_array.j2 | 8 + .../declaration/variable_length_opaque.j2 | 5 + .../declaration/variable_length_string.j2 | 5 + .../templates/C/struct/decoder/basic.j2 | 6 + .../templates/C/struct/decoder/close.j2 | 3 + .../C/struct/decoder/fixed_length_array.j2 | 8 + .../C/struct/decoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/decoder/open.j2 | 12 + .../C/struct/decoder/optional_data.j2 | 6 + .../C/struct/decoder/pointer-open.j2 | 22 + .../C/struct/decoder/variable_length_array.j2 | 13 + .../struct/decoder/variable_length_opaque.j2 | 6 + .../struct/decoder/variable_length_string.j2 | 6 + .../templates/C/struct/encoder/basic.j2 | 10 + .../templates/C/struct/encoder/close.j2 | 3 + .../C/struct/encoder/fixed_length_array.j2 | 12 + .../C/struct/encoder/fixed_length_opaque.j2 | 6 + .../xdrgen/templates/C/struct/encoder/open.j2 | 12 + .../C/struct/encoder/optional_data.j2 | 6 + .../C/struct/encoder/pointer-open.j2 | 20 + .../C/struct/encoder/variable_length_array.j2 | 15 + .../struct/encoder/variable_length_opaque.j2 | 8 + .../struct/encoder/variable_length_string.j2 | 8 + .../templates/C/typedef/declaration/basic.j2 | 11 + .../typedef/declaration/fixed_length_array.j2 | 11 + .../declaration/fixed_length_opaque.j2 | 11 + .../declaration/variable_length_array.j2 | 14 + .../declaration/variable_length_opaque.j2 | 11 + .../declaration/variable_length_string.j2 | 11 + .../templates/C/typedef/decoder/basic.j2 | 17 + .../C/typedef/decoder/fixed_length_array.j2 | 25 + .../C/typedef/decoder/fixed_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_array.j2 | 26 ++ .../typedef/decoder/variable_length_opaque.j2 | 17 + .../typedef/decoder/variable_length_string.j2 | 17 + .../templates/C/typedef/encoder/basic.j2 | 21 + .../C/typedef/encoder/fixed_length_array.j2 | 25 + .../C/typedef/encoder/fixed_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_array.j2 | 30 ++ .../typedef/encoder/variable_length_opaque.j2 | 17 + .../typedef/encoder/variable_length_string.j2 | 17 + .../C/union/declaration/case_spec.j2 | 2 + .../templates/C/union/declaration/close.j2 | 8 + .../C/union/declaration/default_spec.j2 | 2 + .../templates/C/union/declaration/open.j2 | 6 + .../C/union/declaration/switch_spec.j2 | 3 + .../xdrgen/templates/C/union/decoder/basic.j2 | 6 + .../xdrgen/templates/C/union/decoder/break.j2 | 2 + .../templates/C/union/decoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/close.j2 | 4 + .../templates/C/union/decoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/decoder/open.j2 | 12 + .../C/union/decoder/optional_data.j2 | 6 + .../templates/C/union/decoder/switch_spec.j2 | 7 + .../C/union/decoder/variable_length_array.j2 | 13 + .../C/union/decoder/variable_length_opaque.j2 | 6 + .../C/union/decoder/variable_length_string.j2 | 6 + .../xdrgen/templates/C/union/decoder/void.j2 | 3 + .../xdrgen/templates/C/union/encoder/basic.j2 | 10 + .../xdrgen/templates/C/union/encoder/break.j2 | 2 + .../templates/C/union/encoder/case_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/close.j2 | 4 + .../templates/C/union/encoder/default_spec.j2 | 2 + .../xdrgen/templates/C/union/encoder/open.j2 | 12 + .../templates/C/union/encoder/switch_spec.j2 | 7 + .../xdrgen/templates/C/union/encoder/void.j2 | 3 + tools/net/sunrpc/xdrgen/tests/test.x | 36 ++ tools/net/sunrpc/xdrgen/xdr | 1 + tools/net/sunrpc/xdrgen/xdr.ebnf | 117 +++++ tools/net/sunrpc/xdrgen/xdr_ast.py | 437 ++++++++++++++++++ tools/net/sunrpc/xdrgen/xdr_parse.py | 20 + tools/net/sunrpc/xdrgen/xdrgen | 95 ++++ 112 files changed, 3986 insertions(+)create mode 100644
fs/nfsd/nfs4_1.x
create mode 100644fs/nfsd/nfs4xdr_gen.c
create mode 100644fs/nfsd/nfs4xdr_gen.h
create mode 100644include/linux/sunrpc/xdrgen-builtins.h
create mode 100644tools/net/sunrpc/xdrgen/.gitignore
create mode 100644tools/net/sunrpc/xdrgen/README
create mode 100644tools/net/sunrpc/xdrgen/__init__.py
create mode 100644tools/net/sunrpc/xdrgen/common.py
create mode 100644tools/net/sunrpc/xdrgen/generators/__init__.py
create mode 100644tools/net/sunrpc/xdrgen/generators/boilerplate.py
create mode 100644tools/net/sunrpc/xdrgen/generators/constant.py
create mode 100644tools/net/sunrpc/xdrgen/generators/enum.py
create mode 100644tools/net/sunrpc/xdrgen/generators/program.py
create mode 100644tools/net/sunrpc/xdrgen/generators/struct.py
create mode 100644tools/net/sunrpc/xdrgen/generators/typedef.py
create mode 100644tools/net/sunrpc/xdrgen/generators/union.py
create mode 100644tools/net/sunrpc/xdrgen/subcmds/__init__.py
create mode 100755tools/net/sunrpc/xdrgen/subcmds/header.py
create mode 100755tools/net/sunrpc/xdrgen/subcmds/lint.py
create mode 100755tools/net/sunrpc/xdrgen/subcmds/source.py
create mode 100644tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_bottom.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_top.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/boilerplate/source_top.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/constants/declaration.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enumerator.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/enum/declaration/open.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/basic.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/close.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/fixed_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/open.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/optional_data.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/pointer-open.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/declaration/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/pointer-open.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/pointer-open.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/basic.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/declaration/case_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/declaration/close.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/declaration/default_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/declaration/open.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/declaration/switch_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2
create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2Quoted 9 lines
create mode 100644
tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2create mode 100644tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2create mode 100644tools/net/sunrpc/xdrgen/tests/test.x
create mode 120000tools/net/sunrpc/xdrgen/xdr
create mode 100644tools/net/sunrpc/xdrgen/xdr.ebnf
create mode 100644tools/net/sunrpc/xdrgen/xdr_ast.py
create mode 100644tools/net/sunrpc/xdrgen/xdr_parse.py
create mode 100755tools/net/sunrpc/xdrgen/xdrgen
Quoted 7 lines
This all looks great to me. I really support autogenerating our XDR boilerplate, particularly as I've been looking at implementing
CB_NOTIFY(which would be quite tedious to roll by hand). This would make it a lot simpler and less error prone.Do you have these patches in a branch in your tree that I could pick from?
Mentioned above:
Quoted 4 lines
Quoted 4 lines
These patches apply to v6.11-rc4, but can be rebased on nfsd-next if they are found merge-worthy. See also:
https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git/log/?h=lkxdrgen
The lkxdrgen branch in my kernel.org <http://kernel.org/> git repo.
However, do you need it rebased on nfsd-next? I can do that today if so.
--
Chuck Lever