Received: by 2002:a05:7412:a986:b0:f9:90c9:de9f with SMTP id o6csp32077rdh; Wed, 20 Dec 2023 13:30:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9GwJiGuwdcoco1WLcetdl/9gNRmUbjS6h0IhWWo7FMWK8luxfDhGFgZomYwonXJbjg/89 X-Received: by 2002:a17:906:348d:b0:a23:3ef8:aa8c with SMTP id g13-20020a170906348d00b00a233ef8aa8cmr1433316ejb.165.1703107843481; Wed, 20 Dec 2023 13:30:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703107843; cv=none; d=google.com; s=arc-20160816; b=i7cPlOXw96fSf6JxcNKhipx9WljYEpylzyJ3XJaXGzoJJ0A4Ae2CF0Dxh0duY/Uk90 lyrkEg0V2k8zahtmNxTEYHe/ACbAmSzjLuua96EmZGJ//d56Fh+dhaIRe8w5dioU+BwH FQK/DO6IZaH7rJ/YVBmsxfPMGKcP4ydBZoN50tF73POEl9dsC1PeNJhwFFoP9/4uyipp 0LCMyFonUc+12+892u2MNW0bcWIzpGE3J1AN9i4H3HSFlYzcEbNKz6fwaJ1De2xA17a3 iuY82sp4FBoku/QVOiVcUq49+h+lfzflzr3mjKCbZV8leP6L7M9LS26IcvVjs1I1D6tx 3NlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=j3p6p3aym2SP07IW6vLAdctaqtx6pU2fVv5Z8OohKZo=; fh=mL0lp98nCa/OPvHpjHb1CtZuW34GhYDzI2Ze+Ry5Jg8=; b=E7+UkYqDFAKoaYB4U4/A9DJmPokL+m4wWPD18xYMt0b6hQ4YIr6xu/ghUsRJ2kGBE1 vRSskYxAf69jLHkqdPssvt6rA4mHixJ2yFe1t0P6qN8HUWlklf8bkPfHDaf/UOv0LmBN Qj6DzO31pQcf1jXie9f0qdEuyOfPMvjkdPmqLq/wjh4vcPp0KUTA3VJ6GX85853dhRC/ sYAXTGpUKrLOFMkmo42e9MKREcPH8nX2CCxz0s9vXv+AANAqpBV8bPyIh1n2vwpobeYZ zlmpeqIJ46sBdU8D5vKWcI+SaeddG25YEeDnx3fgdYaOWSRl8WE+WHy9/l+Ye6HkRCDV dd3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="L+Y6/CPo"; spf=pass (google.com: domain of linux-kernel+bounces-7451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7451-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p10-20020a1709060e8a00b00a236fc6a8a9si182625ejf.962.2023.12.20.13.30.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 13:30:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="L+Y6/CPo"; spf=pass (google.com: domain of linux-kernel+bounces-7451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7451-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 407851F22714 for ; Wed, 20 Dec 2023 21:30:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 873EA48CEA; Wed, 20 Dec 2023 21:30:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="L+Y6/CPo" X-Original-To: linux-kernel@vger.kernel.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 168B2482F3 for ; Wed, 20 Dec 2023 21:30:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1703107827; bh=apG/0nxexGD8jzeDg1TQ5uayt4o+qoJssflxQnwQMyk=; h=From:Date:Subject:To:Cc:From; b=L+Y6/CPojcMvH8rFRxFL78k+BevxBAcM2X44Xaa376nR286Q7vvLVZRw1ZAFyHh4N EyIpGu7hYn/IUFCCgCGKeEVvWqM6HkUUSVlsCEbD0x6eXGV1cg+iXxrgtgPH3c5Z/r u4qckiCFoVKwfJjNJ7LNL0RC7ZTyEFylsODOhSr8= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Wed, 20 Dec 2023 22:30:26 +0100 Subject: [PATCH] scripts: check-sysctl-docs: adapt to new API Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231220-sysctl-check-v1-1-420ced4a69d7@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAPFcg2UC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI2NDIyMD3eLK4uSSHN3kjNTkbF0LCwMjM1PDFEsT0xQloJaCotS0zAqwcdG xtbUARy0jD14AAAA= To: Luis Chamberlain , Joel Granados Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703107827; l=3872; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=apG/0nxexGD8jzeDg1TQ5uayt4o+qoJssflxQnwQMyk=; b=IPRmOoGhjV/CzmZ+/wrZpbjhW+2S18UAmkS0CL8I9bHAue6ob1a9P/gekVVaDcPIgLAVShnej qe7yUa0kh/pBNqtbXhd1Uw3Ih1nl9rd0aWx71lVAXILQK+pVu/5FZ+J X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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. In its reference invocation the script won't be able to parse the tables from ipc/ipc_sysctl.c as they are using dynamically built tables which are to complex to parse. Note that the script is already prepared for a potential constification of the ctl_table structs. Signed-off-by: Thomas Weißschuh --- scripts/check-sysctl-docs | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/scripts/check-sysctl-docs b/scripts/check-sysctl-docs index 4f163e0bf6a4..bd18ab4b950b 100755 --- a/scripts/check-sysctl-docs +++ b/scripts/check-sysctl-docs @@ -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 @@ -20,14 +20,12 @@ 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) @@ -94,44 +92,24 @@ 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] @@ -140,10 +118,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 { --- base-commit: 1a44b0073b9235521280e19d963b6dfef7888f18 change-id: 20231220-sysctl-check-8802651d945d Best regards, -- Thomas Weißschuh