8
8
# Example invocation:
9
9
# scripts/check-sysctl-docs -vtable="kernel" \
10
10
# Documentation/admin-guide/sysctl/kernel.rst \
11
- # $(git grep -l register_sysctl_ )
11
+ # $(git grep -l register_sysctl )
12
12
#
13
13
# Specify -vdebug=1 to see debugging information
14
14
@@ -20,14 +20,10 @@ BEGIN {
20
20
}
21
21
22
22
# The following globals are used:
23
- # children: maps ctl_table names and procnames to child ctl_table names
24
23
# documented: maps documented entries (each key is an entry)
25
24
# entries: maps ctl_table names and procnames to counts (so
26
25
# enumerating the subkeys for a given ctl_table lists its
27
26
# 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
31
27
# curtable: the name of the current ctl_table struct
32
28
# curentry: the name of the current proc entry (procname when parsing
33
29
# a ctl_table, constructed path when parsing a ctl_path)
@@ -94,44 +90,23 @@ FNR == NR {
94
90
95
91
# Stage 2: process each file and find all sysctl tables
96
92
BEGINFILE {
97
- delete children
98
93
delete entries
99
- delete paths
100
- curpath = " "
101
94
curtable = " "
102
95
curentry = " "
103
96
if (debug) print " Processing file " FILENAME
104
97
}
105
98
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 ]
115
102
if (debug) print " Processing table " curtable
116
103
}
117
104
118
105
/^ };$ / {
119
- curpath = " "
120
106
curtable = " "
121
107
curentry = " "
122
108
}
123
109
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
-
135
110
curtable && /\. procname[\t ]* =[\t ]* ". + " / {
136
111
match ($0 , /. procname[\t ]* =[\t ]* "([^ " ]+ )" /, names)
137
112
curentry = names[ 1 ]
@@ -140,10 +115,14 @@ curtable && /\.procname[\t ]*=[\t ]*".+"/ {
140
115
file[ curentry] = FILENAME
141
116
}
142
117
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
+ }
147
126
}
148
127
149
128
END {
0 commit comments