Skip to content

Commit

Permalink
scripts: check-sysctl-docs: adapt to new API
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
t-8ch authored and Joelgranados committed Feb 23, 2024
1 parent cec030e commit 0f6588b
Showing 1 changed file with 12 additions and 33 deletions.
45 changes: 12 additions & 33 deletions scripts/check-sysctl-docs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Example invocation:
# scripts/check-sysctl-docs -vtable="kernel" \
# Documentation/admin-guide/sysctl/kernel.rst \
# $(git grep -l register_sysctl_)
# $(git grep -l register_sysctl)
#
# Specify -vdebug=1 to see debugging information

Expand All @@ -20,14 +20,10 @@ BEGIN {
}

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

# Stage 2: process each file and find all sysctl tables
BEGINFILE {
delete children
delete entries
delete paths
curpath = ""
curtable = ""
curentry = ""
if (debug) print "Processing file " FILENAME
}

/^static struct ctl_path/ {
match($0, /static struct ctl_path ([^][]+)/, tables)
curpath = tables[1]
if (debug) print "Processing path " curpath
}

/^static struct ctl_table/ {
match($0, /static struct ctl_table ([^][]+)/, tables)
curtable = tables[1]
/^static( const)? struct ctl_table/ {
match($0, /static( const)? struct ctl_table ([^][]+)/, tables)
curtable = tables[2]
if (debug) print "Processing table " curtable
}

/^};$/ {
curpath = ""
curtable = ""
curentry = ""
}

curpath && /\.procname[\t ]*=[\t ]*".+"/ {
match($0, /.procname[\t ]*=[\t ]*"([^"]+)"/, names)
if (curentry) {
curentry = curentry "/" names[1]
} else {
curentry = names[1]
}
if (debug) print "Setting path " curpath " to " curentry
paths[curpath] = curentry
}

curtable && /\.procname[\t ]*=[\t ]*".+"/ {
match($0, /.procname[\t ]*=[\t ]*"([^"]+)"/, names)
curentry = names[1]
Expand All @@ -140,10 +115,14 @@ curtable && /\.procname[\t ]*=[\t ]*".+"/ {
file[curentry] = FILENAME
}

/\.child[\t ]*=/ {
child = trimpunct($NF)
if (debug) print "Linking child " child " to table " curtable " entry " curentry
children[curtable][curentry] = child
/register_sysctl.*/ {
match($0, /register_sysctl(|_init|_sz)\("([^"]+)" *, *([^,)]+)/, tables)
if (debug) print "Registering table " tables[3] " at " tables[2]
if (tables[2] == table) {
for (entry in entries[tables[3]]) {
printentry(entry)
}
}
}

END {
Expand Down

0 comments on commit 0f6588b

Please sign in to comment.