[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1/2] tools/helpers: Introduce cmp-fd-file-inode utility

On Wed, Feb 26, 2020 at 10:48 AM Ian Jackson <ian.jackson@xxxxxxxxxx> wrote:
> Jason Andryuk writes ("[PATCH 1/2] tools/helpers: Introduce cmp-fd-file-inode 
> utility"):
> > This is a C implementation of the perl code inside of locking.sh to
> > check that the locked file descriptor and lock file share the same inode
> > and therefore match.  One change from the perl version is replacing
> > printing "y" on success with exit values of 0 (shell True) and 1 (shell
> > False).
> Maybe it would be better to use stat(1) ?  On Linux
>    stat -L -c%D.%i /dev/stdin blah.lock
> or some such, and then compare the two numbers.
> I'm reluctant to host a general-purpose shell utility in xen.git, no
> matter how useful...

Thanks for taking a look.

I'd be happy to use stat if it works.  The comment in locking.sh above
the usage is:
        # We can't just stat /dev/stdin or /proc/self/fd/$_lockfd or
        # use bash's test -ef because those all go through what is
        # 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.

...which I thought ruled out stat.


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.