diff mbox series

[2/2] Linux/locking.sh: Use cmp-fd-file-inode for lock check

Message ID 20200226152013.12200-3-jandryuk@gmail.com (mailing list archive)
State New, archived
Headers show
Series Remove locking.sh dependency on perl | expand

Commit Message

Jason Andryuk Feb. 26, 2020, 3:20 p.m. UTC
Replace perl with cmp-fd-file-inode when checking that the lock file
descriptor and lockfile inodes match.

Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/hotplug/Linux/locking.sh | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
diff mbox series

Patch

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<&-"