Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1527433pxj; Fri, 18 Jun 2021 09:02:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7D19dNWWEmGBYKcRiQ2QMc0wdoTQs54OY4exotAClNit4bEbs1KNTvPIO9+Vr+/uXw3/q X-Received: by 2002:a92:c741:: with SMTP id y1mr1670548ilp.155.1624032127435; Fri, 18 Jun 2021 09:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624032127; cv=none; d=google.com; s=arc-20160816; b=N4G/EDeTlu6IYQMWE5+pzXvsaF3N4q26WU7OaaiCkFLFxyxfQDnuFK/Pmi/WgsffRj 7a4bWMmqEwSW1wXwYf3NLPsZNwkSRVXpVobvq6qMGMRuxfzNbAItv5Uc5W2eo5BbVagB VGclaPYaEhAjXe/HmuPGnp7fn3kdzZrspLBtnK9l1DMNqH8IFjOtG2+/DUAFQMPur8Qf bfrVp577QYgQN1fWuDWqmlTqrC4HItcFXnj0giO/YM+U2B903+U7V0+jHchFPKBlZYzI I4DSbN4Xy27pyuE2jj2Ircr8pVrjUSBG1z7xR3Jm9azi18MemH90cXN0qXOD2zKmRFXY kfAA== 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=1qxU4G2PBSf5cuhvarGqglCcdeWkMXLcVVVU/Zoiepo=; b=wi2ipMabIlqurJ1pSKtEqA0UjCUEKJo7d1mqxxQwypRpfOiqAkQvVkjnpjOUtm6yvX 0hgu+L9AXbpXXBQbi476b7NBzyjZZWANbzEiKn2+fmNP0D5x/faNwOZWw5VwRyiPvBak wrNsa3Z3/zxjy1NPtWADz24g6XW8fgJEiItH9taADA/1MYaqeQ/KntlwkBZOXxbz48oL 3HxW35Y/nTsmEoAxlp1wleZL02139BisQSXIyOBHCfFAWNNgyzmhCrfKeV4PU8xOpx+x Lhqmnu1Luk735eS8nZaKjwcvuAGVhHuKVZ/iPVZNONG7UqIFWcDTd1d6l0aP5IfEfA0i 1ztQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=As9lj7p7; 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 i2si9846222jar.26.2021.06.18.09.01.54; Fri, 18 Jun 2021 09:02:07 -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=As9lj7p7; 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 S233058AbhFRLay (ORCPT + 99 others); Fri, 18 Jun 2021 07:30:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232090AbhFRLau (ORCPT ); Fri, 18 Jun 2021 07:30:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 254E261351; Fri, 18 Jun 2021 11:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624015721; bh=5Pz1lNiWEhdxcezIWbGtg4zMJZ0g3vMwrjj21gjwJ1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=As9lj7p7HqC2AMpE5ep3GslM0kgf7qfGXiINV/Bnk47S7/h+eX3aC/rQ51jrd/Xdu V7SDFyAeTI9Wuv4ZnRvX1lpi5s4pWaEtIZvmTek8DdglDyaLR8ilG3ZuF3VsDL2/cs 7EkuWLPwcMX8ji0g1Y35UPku43ifRausmNUwh9trft93TRXvM5B3yxzy/TInxNyxaT kJGxf5QQNvIM8PgV8aO3JVV+qZnSNxbs5w+TJAdeKvcVwTy1d7glQ3lZaXWEPqE9dL ISP8oNxxrpWgkyLzX+gMYRvs0irJi/FIHyFB/eT7A8FNkbaAAAdUtDhwsOY3iZqFiQ /gaqPfZcQlayQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1luCfu-008agM-Sk; Fri, 18 Jun 2021 13:28:38 +0200 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Greg KH Cc: Mauro Carvalho Chehab , "Jonathan Cameron" , "Jonathan Corbet" , linux-kernel@vger.kernel.org Subject: [PATCH RFC 1/1] get_abi.pl: Check for missing symbols at the ABI specs Date: Fri, 18 Jun 2021 13:28:37 +0200 Message-Id: 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 | 72 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/scripts/get_abi.pl b/scripts/get_abi.pl index d7aa82094296..e85cee0f8901 100755 --- a/scripts/get_abi.pl +++ b/scripts/get_abi.pl @@ -14,6 +14,7 @@ my $man = 0; my $debug = 0; my $enable_lineno = 0; my $prefix="Documentation/ABI"; +my $sysfs_prefix="/sys"; # # If true, assumes that the description is formatted with ReST @@ -36,7 +37,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); @@ -521,6 +522,68 @@ sub search_symbols { } } +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); + + # /sys/.*/ + return if ($file =~ m/(initstate|bind|unbind)/); + + 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 $what (sort keys %data) { + my $leave = $what; + $leave =~ s,.*/,,; + + if (defined($leaf{$leave})) { + $leaf{$leave} .= " " . $what; + } else { + $leaf{$leave} = $what; + } + } + + find({wanted =>\&parse_existing_sysfs, 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 @@ -536,7 +599,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") { @@ -575,6 +640,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