Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp577012pxb; Thu, 23 Sep 2021 06:32:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPC2cHXaoRvpJEQnNKcsDHY+vbbXZowtPD0ert5T1NK3VArQK9r7jPrh60ZOeLltqmuf/D X-Received: by 2002:a05:6e02:19cd:: with SMTP id r13mr3640740ill.165.1632403959959; Thu, 23 Sep 2021 06:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632403959; cv=none; d=google.com; s=arc-20160816; b=WquXCzHQWZ1JvGM3XeXIm7eBMz0wopXInGUbzn5aD28QqOm02gUmMnMR0Blikgk+Y9 /jLSH36jxy/hq682PUunXguOgIj4NmRL1cncRzVNOfw2R3H3TTVt6Uj1lN24CAM2r82X 5TuXqHvo+0YbEYSgwaDC+kIC2woenIIIsCfGkzWPZN3CfSp+8oBSAI/S4ZfH6VfKENBs DvjT8CNsxDLsKxHXUzHARdK91WjFY8pEOAqONmDvDIM6SeiDMbGNhrdika7Mtz06hlja n0pfTO6tfU6KW4vsm3FcTNS34BrLJUCveliQdttPP8cAFcHd6oMBMP6PnNNZky0xjAQO HZdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d8uQW7u8tjgwVoVWsD/x6Z1FzWvuahEcg+KBAX3s65o=; b=bIrAc9aj1LKIhcpkxutqGeHtPigTwUOGv1ggIiuHmbI8kW3gwd8vOr2H19HUdQbMsE KQbRDBKFK9ciS1KSTdz69TBrWul/DX/95RJGt27PoOEDAdge6DpK5noAi655nFYjPLcv 5j7IuhlUUWhHYc5V9iki/Q1+4FQRnypRJTyioyBlSlk2CNIWzT/hP6d+wkqsBcXXTBt2 8TgD1UDtS2e9mv6orscIw4WS+tj8dg6bvBTJLYfeydprQAwlDfyxoQFEtSQkABy2y+dt GxjTPuEu4NKLcwpZ3oDaTkvU9Rbe4axR3Vhri86V28RjsMkgzQL7ZL/ZFtjyYj+Iju/x xxgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nrXBUe+S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c184si6937717iof.111.2021.09.23.06.32.27; Thu, 23 Sep 2021 06:32:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nrXBUe+S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241514AbhIWNcN (ORCPT + 99 others); Thu, 23 Sep 2021 09:32:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:44098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241224AbhIWNbq (ORCPT ); Thu, 23 Sep 2021 09:31:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BD3CF6126A; Thu, 23 Sep 2021 13:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632403814; bh=GfTG4NevTekER0PTzKJU9hfUyfF7/nFfc5ACOcb887E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nrXBUe+SWZjuRn7FRHxODDjRJk/ysp0Qyr5Xy0+vqdIKxhJ41YDvCx3Q5VYEnaM9F BMbSB+WYbWAnvb4uqzUuuyjOhSpULMoFsEgIyZs6fHCuPQ4ZresRU8iB+s3kSyHdLV 01hdVRY/jSRcuI12GgE56qnfQFxOJzl0IaFHjNsK7xJJL8iSgjqxBrlA3HMokzaXlw d5yfHpxY7bluKJ4zQy2vKCB9GXYXGbqSjHKlWlE7NJjlM3vBCswpVGVVQWouE9sAxs GLs/S4wAhvb/PcI/xZlsAodgDarLGMHuWXQTIbAH1A0tXFAkPz/1FQnLN2v2x1CQZg PqhMhP9ODSkNQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1mTOnk-000nds-OW; Thu, 23 Sep 2021 15:30:12 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Greg Kroah-Hartman Cc: Mauro Carvalho Chehab , "Jonathan Corbet" , Alexei Starovoitov , Andrii Nakryiko , Anton Vorontsov , Colin Cross , Daniel Borkmann , John Fastabend , KP Singh , Kees Cook , Martin KaFai Lau , Song Liu , Tony Luck , Yonghong Song , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 02/13] scripts: get_abi.pl: Check for missing symbols at the ABI specs Date: Thu, 23 Sep 2021 15:30:00 +0200 Message-Id: <8612c609e77b1b057172ab13685bdfd3ce37995f.1632402570.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check for the symbols that exists under /sys but aren't defined at Documentation/ABI. Signed-off-by: Mauro Carvalho Chehab --- scripts/get_abi.pl | 90 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl index 48077feea89c..e714bf75f5c2 100755 --- a/scripts/get_abi.pl +++ b/scripts/get_abi.pl @@ -13,7 +13,9 @@ my $help = 0; my $man = 0; my $debug = 0; my $enable_lineno = 0; +my $show_warnings = 1; my $prefix="Documentation/ABI"; +my $sysfs_prefix="/sys"; # # If true, assumes that the description is formatted with ReST @@ -36,7 +38,7 @@ pod2usage(2) if (scalar @ARGV < 1 || @ARGV > 2); my ($cmd, $arg) = @ARGV; -pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate"); +pod2usage(2) if ($cmd ne "search" && $cmd ne "rest" && $cmd ne "validate" && $cmd ne "undefined"); pod2usage(2) if ($cmd eq "search" && !$arg); require Data::Dumper if ($debug); @@ -50,6 +52,8 @@ my %symbols; sub parse_error($$$$) { my ($file, $ln, $msg, $data) = @_; + return if (!$show_warnings); + $data =~ s/\s+$/\n/; print STDERR "Warning: file $file#$ln:\n\t$msg"; @@ -522,11 +526,88 @@ sub search_symbols { } } +# Exclude /sys/kernel/debug and /sys/kernel/tracing from the search path +sub skip_debugfs { + if (($File::Find::dir =~ m,^/sys/kernel,)) { + return grep {!/(debug|tracing)/ } @_; + } + + if (($File::Find::dir =~ m,^/sys/fs,)) { + return grep {!/(pstore|bpf|fuse)/ } @_; + } + + return @_ +} + +my %leaf; + +my $escape_symbols = qr { ([\x01-\x08\x0e-\x1f\x21-\x29\x2b-\x2d\x3a-\x40\x7b-\xff]) }x; +sub parse_existing_sysfs { + my $file = $File::Find::name; + + my $mode = (stat($file))[2]; + return if ($mode & S_IFDIR); + + my $leave = $file; + $leave =~ s,.*/,,; + + if (defined($leaf{$leave})) { + # FIXME: need to check if the path makes sense + my $what = $leaf{$leave}; + + $what =~ s/,/ /g; + + $what =~ s/\<[^\>]+\>/.*/g; + $what =~ s/\{[^\}]+\}/.*/g; + $what =~ s/\[[^\]]+\]/.*/g; + $what =~ s,/\.\.\./,/.*/,g; + $what =~ s,/\*/,/.*/,g; + + $what =~ s/\s+/ /g; + + # Escape all other symbols + $what =~ s/$escape_symbols/\\$1/g; + + foreach my $i (split / /,$what) { + if ($file =~ m#^$i$#) { +# print "$file: $i: OK!\n"; + return; + } + } + + print "$file: $leave is defined at $what\n"; + + return; + } + + print "$file not found.\n"; +} + +sub undefined_symbols { + foreach my $w (sort keys %data) { + foreach my $what (split /\xac /,$w) { + my $leave = $what; + $leave =~ s,.*/,,; + + if (defined($leaf{$leave})) { + $leaf{$leave} .= " " . $what; + } else { + $leaf{$leave} = $what; + } + } + } + + find({wanted =>\&parse_existing_sysfs, preprocess =>\&skip_debugfs, no_chdir => 1}, $sysfs_prefix); +} + # Ensure that the prefix will always end with a slash # While this is not needed for find, it makes the patch nicer # with --enable-lineno $prefix =~ s,/?$,/,; +if ($cmd eq "undefined" || $cmd eq "search") { + $show_warnings = 0; +} # # Parses all ABI files located at $prefix dir # @@ -537,7 +618,9 @@ print STDERR Data::Dumper->Dump([\%data], [qw(*data)]) if ($debug); # # Handles the command # -if ($cmd eq "search") { +if ($cmd eq "undefined") { + undefined_symbols; +} elsif ($cmd eq "search") { search_symbols; } else { if ($cmd eq "rest") { @@ -576,6 +659,9 @@ B - output the ABI in ReST markup language B - validate the ABI contents +B - existing symbols at the system that aren't + defined at Documentation/ABI + =back =head1 OPTIONS -- 2.31.1