Skip to content

Commit 0f6588b

Browse files
t-8chJoelgranados
authored andcommitted
scripts: check-sysctl-docs: adapt to new API
The script expects the old sysctl_register_paths() API which was removed some time ago. Adapt it to work with the new sysctl_register()/sysctl_register_sz()/sysctl_register_init() APIs. Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Joel Granados <[email protected]> Signed-off-by: Joel Granados <[email protected]>
1 parent cec030e commit 0f6588b

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

scripts/check-sysctl-docs

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Example invocation:
99
# scripts/check-sysctl-docs -vtable="kernel" \
1010
# Documentation/admin-guide/sysctl/kernel.rst \
11-
# $(git grep -l register_sysctl_)
11+
# $(git grep -l register_sysctl)
1212
#
1313
# Specify -vdebug=1 to see debugging information
1414

@@ -20,14 +20,10 @@ BEGIN {
2020
}
2121

2222
# The following globals are used:
23-
# children: maps ctl_table names and procnames to child ctl_table names
2423
# documented: maps documented entries (each key is an entry)
2524
# entries: maps ctl_table names and procnames to counts (so
2625
# enumerating the subkeys for a given ctl_table lists its
2726
# procnames)
28-
# files: maps procnames to source file names
29-
# paths: maps ctl_path names to paths
30-
# curpath: the name of the current ctl_path struct
3127
# curtable: the name of the current ctl_table struct
3228
# curentry: the name of the current proc entry (procname when parsing
3329
# a ctl_table, constructed path when parsing a ctl_path)
@@ -94,44 +90,23 @@ FNR == NR {
9490

9591
# Stage 2: process each file and find all sysctl tables
9692
BEGINFILE {
97-
delete children
9893
delete entries
99-
delete paths
100-
curpath = ""
10194
curtable = ""
10295
curentry = ""
10396
if (debug) print "Processing file " FILENAME
10497
}
10598

106-
/^static struct ctl_path/ {
107-
match($0, /static struct ctl_path ([^][]+)/, tables)
108-
curpath = tables[1]
109-
if (debug) print "Processing path " curpath
110-
}
111-
112-
/^static struct ctl_table/ {
113-
match($0, /static struct ctl_table ([^][]+)/, tables)
114-
curtable = tables[1]
99+
/^static( const)? struct ctl_table/ {
100+
match($0, /static( const)? struct ctl_table ([^][]+)/, tables)
101+
curtable = tables[2]
115102
if (debug) print "Processing table " curtable
116103
}
117104

118105
/^};$/ {
119-
curpath = ""
120106
curtable = ""
121107
curentry = ""
122108
}
123109

124-
curpath && /\.procname[\t ]*=[\t ]*".+"/ {
125-
match($0, /.procname[\t ]*=[\t ]*"([^"]+)"/, names)
126-
if (curentry) {
127-
curentry = curentry "/" names[1]
128-
} else {
129-
curentry = names[1]
130-
}
131-
if (debug) print "Setting path " curpath " to " curentry
132-
paths[curpath] = curentry
133-
}
134-
135110
curtable && /\.procname[\t ]*=[\t ]*".+"/ {
136111
match($0, /.procname[\t ]*=[\t ]*"([^"]+)"/, names)
137112
curentry = names[1]
@@ -140,10 +115,14 @@ curtable && /\.procname[\t ]*=[\t ]*".+"/ {
140115
file[curentry] = FILENAME
141116
}
142117

143-
/\.child[\t ]*=/ {
144-
child = trimpunct($NF)
145-
if (debug) print "Linking child " child " to table " curtable " entry " curentry
146-
children[curtable][curentry] = child
118+
/register_sysctl.*/ {
119+
match($0, /register_sysctl(|_init|_sz)\("([^"]+)" *, *([^,)]+)/, tables)
120+
if (debug) print "Registering table " tables[3] " at " tables[2]
121+
if (tables[2] == table) {
122+
for (entry in entries[tables[3]]) {
123+
printentry(entry)
124+
}
125+
}
147126
}
148127

149128
END {

0 commit comments

Comments
 (0)