From patchwork Wed Feb 26 15:20:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 11406569 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCEC71395 for ; Wed, 26 Feb 2020 15:22:04 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9A412467D for ; Wed, 26 Feb 2020 15:22:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qy+Lmqcn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9A412467D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6yUh-0001CK-Ph; Wed, 26 Feb 2020 15:21:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6yUg-0001C9-MU for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 15:21:02 +0000 X-Inumbo-ID: 97d1ba78-58ab-11ea-a490-bc764e2007e4 Received: from mail-qt1-x841.google.com (unknown [2607:f8b0:4864:20::841]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 97d1ba78-58ab-11ea-a490-bc764e2007e4; Wed, 26 Feb 2020 15:20:59 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id r5so2480833qtt.9 for ; Wed, 26 Feb 2020 07:20:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VFOAd65lQswkmbzdAMYJGUSVTalFZ80HbsJPAnnzq2k=; b=Qy+LmqcnrO4tFK9DKfrKCg5Xis7lwdWKVieMep9iDcrcSHJ2Jpvhaz9JsSc+6qxkhv 3JWWZUBFyGe728K9iYsFiFzQ6B5kgvFoB/UVaOaP2jIxVRomPkq1y6sBVk4zyUfHTKcf 8f+j8NeauX6qJ3g2J7J46aYdnVZbE5ROYGAWY+gdHvuKLzAzcuSVF+XgCauVRpGwOk5l x3p2NYqzUzhUgtSp+7OEP/g+/yqpd1BzVrxUAXfnXi2WQQlwm1tSLd8wvtjU7wNfLn6N qAenp6eU1BfcwKbmGFPYKb1z2I1hnaLahBjMCJU+ed+oqQz/PXRKw5loICccv5uaV5VM GaAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VFOAd65lQswkmbzdAMYJGUSVTalFZ80HbsJPAnnzq2k=; b=OimENtyiGpT/VDy5nnjuyVCseCvHGac0LrB2tN/afUP9/jtJ4KUAQ1bgbuSsC3dLgw wcnnWi64DodHKbP2TRPXEe8ubgzdnbIjNHtOFFqG7UCjO2ThQRYayDY4VYSTa4Qm4OqM Vz+oFvtgjSm72dVE+GoZrW1aQ0qpxMX6Rq6m1B10jZRfts0L9M6LEXczXLmO5F7n3rBP bMDMSVk57L7vjvHueNMqBht+9jRG7NbdM0LfkBAAtUv8npXcqksa8wxl/kaxl3YQd3Yi /tljjNZ0ASC8DaICnFvUd69K9rzzyWtiCGTidfxf9nNrYSJP6ayd00yq687du7tTp12k JoiQ== X-Gm-Message-State: APjAAAVODoJ65JMxYRAKA1UlrfXYvFl8Oc2CBKGkCxeGkogA3bj4Ab+y Ko8PbdNaGwxZQdPazZV23KqvQhC6 X-Google-Smtp-Source: APXvYqxKwRrFeHXykdEtDwbAPXl/JpTWF8CC8F9DYXFbHDP37dpEi7+p/90GZQv8TsCu4GHmv/9csw== X-Received: by 2002:ac8:7101:: with SMTP id z1mr5242193qto.333.1582730459173; Wed, 26 Feb 2020 07:20:59 -0800 (PST) Received: from pm2-ws13.praxislan02.com ([2001:470:8:67e:ba27:ebff:fee8:ce27]) by smtp.gmail.com with ESMTPSA id q196sm327187qke.80.2020.02.26.07.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Feb 2020 07:20:58 -0800 (PST) From: Jason Andryuk To: xen-devel@lists.xenproject.org Date: Wed, 26 Feb 2020 10:20:13 -0500 Message-Id: <20200226152013.12200-3-jandryuk@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200226152013.12200-1-jandryuk@gmail.com> References: <20200226152013.12200-1-jandryuk@gmail.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/2] Linux/locking.sh: Use cmp-fd-file-inode for lock check X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ian Jackson , Wei Liu , Jason Andryuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Replace perl with cmp-fd-file-inode when checking that the lock file descriptor and lockfile inodes match. Signed-off-by: Jason Andryuk --- tools/hotplug/Linux/locking.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/hotplug/Linux/locking.sh b/tools/hotplug/Linux/locking.sh index c6a7e96ff9..de468c4bb5 100644 --- a/tools/hotplug/Linux/locking.sh +++ b/tools/hotplug/Linux/locking.sh @@ -50,14 +50,8 @@ claim_lock() # actually a synthetic symlink in /proc and we aren't # guaranteed that our stat(2) won't lose the race with an # rm(1) between reading the synthetic link and traversing the - # file system to find the inum. Perl is very fast so use that. - rightfile=$( perl -e ' - open STDIN, "<&'$_lockfd'" or die $!; - my $fd_inum = (stat STDIN)[1]; die $! unless defined $fd_inum; - my $file_inum = (stat $ARGV[0])[1]; - print "y\n" if $fd_inum eq $file_inum; - ' "$_lockfile" ) - if [ x$rightfile = xy ]; then break; fi + # file system to find the inum. + if cmp-fd-file-inode $_lockfd $_lockfile ; then break; fi # Some versions of bash appear to be buggy if the same # $_lockfile is opened repeatedly. Close the current fd here. eval "exec $_lockfd<&-"