Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2263145ybg; Sun, 27 Oct 2019 14:41:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxU7XmzBjytp2sQRhykF9Ijh7SyUYEATsqnrmjc7J2H4KF8CchFhUnkubxWqGU/2AufYHRd X-Received: by 2002:aa7:dc44:: with SMTP id g4mr16205534edu.266.1572212510276; Sun, 27 Oct 2019 14:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572212510; cv=none; d=google.com; s=arc-20160816; b=g8bZqXKGZQIG2/W1Y2UaLLQL9TPUc0EVqC8FsrtdWLcl7/KxDak6mAhjA6GXuhQ/d9 MwVNCHVIvOHfKH1mfEK9UBHfKeXBs4BNozEqzPCa1eida0eVmylzK2D8oSNDEC+QLT/0 0xH682E9KCLolBu31KBAEomGNJCvIPtGQE0Bj+R7UwrfAQY0NzIRh3JkOL+XJTeNa24c XIaJ63Wp7gKQJZgvgOYRgS25eLnfgqxYAA07XUJ0gJxYlSl16vJm+4iaB7pf18IYnlRX G5Wz8ynRAcV8diEPvbE3yCZJffKHTWarxX0cD3XNtt9I5XLELLWoqfECe7aDEfG1sxjQ nGbQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+T0Hf+ONqCKbYknecjuqEObOj4r72LH4uB9N7Z/2cTo=; b=devbyW+vynd74kZP6L6Spj8rXqx/SfxR6SDhE0WWM+5OvP1MlscQNQIrFn7k1Pveq+ wT1VHq69aO8l//0FCvr66GAO6Nd/Lr+JEseq8DXEDntrtG+1AkMEkiZsEwqcSPzK4S7b Sx4Z3LpMN9s3qRliB4Gx/4yoNIui2IBMccfko623WgjbkL+MLB/DhIYNJXQDT/cP2Yka 7+Jgt56I5kgF2PuybKOeGFXYnpxX+4V+N5LxnJw3c43LR4V+vOBMbf81vn1FL3aW4j8K 3PH8Mp/J+MIZApgUIF4ra3Ih2asq1TEcpmYJT9VZrkNgsULB7SNXsCLnpOBq5mFKAyEj sAxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PMFDrB8T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h37si5976025eda.249.2019.10.27.14.41.26; Sun, 27 Oct 2019 14:41:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PMFDrB8T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728429AbfJ0VDq (ORCPT + 99 others); Sun, 27 Oct 2019 17:03:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:49048 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728421AbfJ0VDn (ORCPT ); Sun, 27 Oct 2019 17:03:43 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EB0892064A; Sun, 27 Oct 2019 21:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572210222; bh=7//GOyKEzo7xrJIfyzR+9RrVrjKnqDbQZAYgTiMrUSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PMFDrB8TX2V358/PWkdLH9c/u8RS+k70V0Q2SGTDk6BeEUxBIQao/BZejW4fQ8Ud1 Mt3yRqfTYsmonh3So6pe0jwCdnk4FAxumxUnRb8yvjIndG6INzO5CkgieNnGEDxkFA NofOtwYnzYLZLa/G4FzPagdjUWgrHm3Lz5RPHtDM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jacob Keller , Randy Dunlap , Masahiro Yamada , Sasha Levin Subject: [PATCH 4.4 09/41] namespace: fix namespace.pl script to support relative paths Date: Sun, 27 Oct 2019 22:00:47 +0100 Message-Id: <20191027203106.620485889@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203056.220821342@linuxfoundation.org> References: <20191027203056.220821342@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jacob Keller [ Upstream commit 82fdd12b95727640c9a8233c09d602e4518e71f7 ] The namespace.pl script does not work properly if objtree is not set to an absolute path. The do_nm function is run from within the find function, which changes directories. Because of this, appending objtree, $File::Find::dir, and $source, will return a path which is not valid from the current directory. This used to work when objtree was set to an absolute path when using "make namespacecheck". It appears to have not worked when calling ./scripts/namespace.pl directly. This behavior was changed in 7e1c04779efd ("kbuild: Use relative path for $(objtree)", 2014-05-14) Rather than fixing the Makefile to set objtree to an absolute path, just fix namespace.pl to work when srctree and objtree are relative. Also fix the script to use an absolute path for these by default. Use the File::Spec module for this purpose. It's been part of perl 5 since 5.005. The curdir() function is used to get the current directory when the objtree and srctree aren't set in the environment. rel2abs() is used to convert possibly relative objtree and srctree environment variables to absolute paths. Finally, the catfile() function is used instead of string appending paths together, since this is more robust when joining paths together. Signed-off-by: Jacob Keller Acked-by: Randy Dunlap Tested-by: Randy Dunlap Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/namespace.pl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/namespace.pl b/scripts/namespace.pl index a71be6b7cdec5..9a2a32ce8a3b4 100755 --- a/scripts/namespace.pl +++ b/scripts/namespace.pl @@ -65,13 +65,14 @@ require 5; # at least perl 5 use strict; use File::Find; +use File::Spec; my $nm = ($ENV{'NM'} || "nm") . " -p"; my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; -my $srctree = ""; -my $objtree = ""; -$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); -$objtree = "$ENV{'objtree'}/" if (exists($ENV{'objtree'})); +my $srctree = File::Spec->curdir(); +my $objtree = File::Spec->curdir(); +$srctree = File::Spec->rel2abs($ENV{'srctree'}) if (exists($ENV{'srctree'})); +$objtree = File::Spec->rel2abs($ENV{'objtree'}) if (exists($ENV{'objtree'})); if ($#ARGV != -1) { print STDERR "usage: $0 takes no parameters\n"; @@ -229,9 +230,9 @@ sub do_nm } ($source = $basename) =~ s/\.o$//; if (-e "$source.c" || -e "$source.S") { - $source = "$objtree$File::Find::dir/$source"; + $source = File::Spec->catfile($objtree, $File::Find::dir, $source) } else { - $source = "$srctree$File::Find::dir/$source"; + $source = File::Spec->catfile($srctree, $File::Find::dir, $source) } if (! -e "$source.c" && ! -e "$source.S") { # No obvious source, exclude the object if it is conglomerate -- 2.20.1