Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp2735309rdb; Tue, 26 Dec 2023 03:35:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMeTTaBUG0GsusU4X6DZEPMBqf2LbKn+sP6YUxwvd9xxpYNb2Eeu/SY5C9m3rxBIeik8ag X-Received: by 2002:a05:6a20:938c:b0:195:3b7f:f91b with SMTP id x12-20020a056a20938c00b001953b7ff91bmr2232686pzh.19.1703590505280; Tue, 26 Dec 2023 03:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703590505; cv=none; d=google.com; s=arc-20160816; b=aIobDMJ9274hWaF1MgtoSIGCU9S1OtHFg6RWFXOlzf6SUoClVOEmxJneagA4+aRj0v 8WuDDJbpiGIPvsT8kId1zLRsmc9csgAridRxVdp6Ws3PUwzONFngA3FkW08kwGWI2Lwj zbeQ+LJl5hm7NNhIRV7u9QmAzKnRo2eL8HmJSzzFCXZVS53GRqY7S5M6x70mAkHzJYtS JEKjH1TvLOlMDDQZaRbbCoDUD/ZeurBPFNrfmH55n0h1ZSpdU5IIA8cDmGST2YZMo5zL DfqAa4qS+gE71Yy+2QYIovoNpJ3QmkYaIBat6hvw36mfUhp0Yi4z/XNPj/HQ5ykQRcOv iWYQ== 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=F00S+DwGPtrmee57oubpUQOn3FhJk/AcjAah40ZMZuI=; fh=mL0lp98nCa/OPvHpjHb1CtZuW34GhYDzI2Ze+Ry5Jg8=; b=YZvYe5sqkVQMaFDIf6/61AgRdZsrfA3LTdQ/RiT3c5+6d6aCwxt9L7x1A2LJKLLDVq pY6LrxCgwP5tbjelEgi/u/hCtcdKHTR5wkbXYqMlmZGtFfOjfWmocQVAXnc5RMKjJ1J+ B9Si+K2w1yjSag7kd+dNvZb74uDkWAv/caEEwnjce7Kb6YYOLReRm3iK9NhzPmifTAot hxDIueyHcXx6vAZsxz1KlOjeju7bo78drUXiHueLXY/rkD16EZ0ilbGWgv5uQsjCGKVM WGDLZx8USY1LZlf2nTbkXKXuM32NhOyLQs/06e7JZKML1eJcbBa11+2EJ6hrAe9AedO7 yXeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=YjXj42CU; spf=pass (google.com: domain of linux-kernel+bounces-11488-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11488-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j7-20020a170902758700b001d33a1454adsi9227720pll.363.2023.12.26.03.35.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 03:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11488-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=YjXj42CU; spf=pass (google.com: domain of linux-kernel+bounces-11488-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11488-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 23215B21C88 for ; Tue, 26 Dec 2023 11:35:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DFD6F4E1CD; Tue, 26 Dec 2023 11:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="YjXj42CU" 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 77FCD4E1C9 for ; Tue, 26 Dec 2023 11:34:48 +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=1703590480; bh=IjVldST9wmzuoDkc/uKjDTattvtdRDpSrjV+wFQaAqk=; h=From:Date:Subject:To:Cc:From; b=YjXj42CU7AqY6+JqV96Avn2c/wZTiJv+xwQyQMA8X/k8EsPgMsXPufzGWYltxS/VG qgEddtuin0uFw+evNtw/PjGi8bJKVrIE6EXEZe/i6y59/Z5lHlcXpensyQz8vUF82H BFQ76elUq8vuEy85lRwYtihCIS4k1WbvXdcszQjw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 26 Dec 2023 12:34:38 +0100 Subject: [PATCH v2] 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: <20231226-sysctl-check-v2-1-2d4f50b30d34@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAE26imUC/3XMQQ6CMBCF4auQWVvTjoDgynsYFqQd7URTTKeih PTuVvYu/5e8bwWhyCRwqlaINLPwFErgrgLrx3Ajxa40oMaDQdRKFrHpoawne1ddp7FtjOvrxkG 5PCNd+bNxl6G0Z0lTXDZ9Nr/1DzQbZVSN2pKrx7Z3x/ObWESsf/l9oARDzvkLnt5s3a0AAAA= 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=1703590479; l=4093; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=IjVldST9wmzuoDkc/uKjDTattvtdRDpSrjV+wFQaAqk=; b=X6yO+bhslli+/1O/kJu+ygceT5rJuVd4SiNTOUoL2C1Npi6eudaDZNFo2tjZtFuv99q4gicRQ DglDOwTGYbuCo0cJMZHM282Fm6AvY1gc5KQp9XE4hYGknIEXkn8WHqT 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 --- Changes in v2: - Remove unused global variable "paths" - Remove docs for deleted variables "children" and "paths" - Link to v1: https://lore.kernel.org/r/20231220-sysctl-check-v1-1-420ced4a69d7@weissschuh.net --- scripts/check-sysctl-docs | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/scripts/check-sysctl-docs b/scripts/check-sysctl-docs index 4f163e0bf6a4..739afd766708 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,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) @@ -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] @@ -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 { --- base-commit: de2ee5e9405e12600c81e39837362800cee433a2 change-id: 20231220-sysctl-check-8802651d945d Best regards, -- Thomas Weißschuh