meson: rework generation of file system lookup helpers

Previously, the gperf table was the main "source of truth", and additional
information (e.g. which file system names are obsolete) was scattered in
various files. We would then parse the gperf file, using python, awk, grep, and
bash, and use the results in various ways. This is hard to understand and
maintain. Let's replace all of this with a single python script that generates
the requested outputs as appropriate.

$ diff -u <(git show @{u}:src/basic/filesystems-gperf.gperf) \
          <(src/basic/filesystem-sets.py gperf)
shows that the outputs are the same except for comments.

Similarly, 'src/basic/filesystem-sets.py fs-type-to-string' and
'src/basic/filesystem-sets.py filesystem-sets' can be used to view
the generated code.

The check that the kernel doesn't define any new file system magics is
converted into a normal test. It doesn't seem necessary to fail the build
when that happens.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-07-27 13:13:54 +02:00
parent c136be3f04
commit b0123576f4
7 changed files with 373 additions and 389 deletions
+20 -29
View File
@@ -168,41 +168,32 @@ basic_sources += generated_gperf_headers
############################################################
r = run_command(
[
'env', '--chdir', meson.project_build_root(),
files('check-filesystems.sh'),
cpp,
files('filesystems-gperf.gperf'),
system_include_args,
],
check: false,
)
if r.returncode() != 0
warning('Unknown filesystems defined in kernel headers:\n\n' + r.stdout())
endif
filesystem_sets_py = files('filesystem-sets.py')
filesystem_sets_c = custom_target(
output : 'filesystem-sets.c',
command : [filesystem_sets_py,
'fs-type-to-string',
'filesystem-sets'],
capture : true)
filesystems_gperf_gperf = custom_target(
output : 'filesystems-gperf.gperf',
command : [filesystem_sets_py,
'gperf'],
capture : true)
filesystems_gperf_h = custom_target(
input : 'filesystems-gperf.gperf',
input : filesystems_gperf_gperf,
output : 'filesystems-gperf.h',
command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
filesystem_list_inc = custom_target(
input : 'filesystems-gperf.gperf',
output : 'filesystem-list.inc',
command : [files('generate-filesystem-list.py'),
'@INPUT@'],
capture : true)
generated_sources += [filesystem_sets_c, filesystems_gperf_gperf, filesystems_gperf_h]
basic_sources += [filesystem_sets_c, filesystems_gperf_h]
filesystem_switch_case_inc = custom_target(
input : 'filesystems-gperf.gperf',
output : 'filesystem-switch-case.inc',
command : [files('generate-filesystem-switch-case.py'),
'@INPUT@'],
capture : true)
generated_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h]
basic_sources += [filesystem_list_inc, filesystem_switch_case_inc, filesystems_gperf_h]
test('kernel-filesystem-magics',
filesystem_sets_py,
args : ['check'],
env : ['CPP=@0@'.format(cpp)])
libbasic_static = static_library(
'basic',