Re: [PATCH v2 1/4] virfile: Add virFileGetLockOwner function

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

 



On 1/13/22 13:42, Vasiliy Ulyanov wrote:
> The function is used to retrieve the PID of the process holding an
> exclusive lock on the file.
> 
> Signed-off-by: Vasiliy Ulyanov <vulyanov@xxxxxxx>
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virfile.c       | 45 ++++++++++++++++++++++++++++++++++++++++
>  src/util/virfile.h       |  2 ++
>  3 files changed, 48 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 5b76e66e61..214f375a91 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2224,6 +2224,7 @@ virFileFreeACLs;
>  virFileGetACLs;
>  virFileGetDefaultHugepage;
>  virFileGetHugepageSize;
> +virFileGetLockOwner;
>  virFileGetMountReverseSubtree;
>  virFileGetMountSubtree;
>  virFileGetXAttr;
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index d6faf7e3d2..b9149fb0d7 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -460,6 +460,43 @@ int virFileUnlock(int fd, off_t start, off_t len)
>  }
>  
>  
> +/**
> + * virFileGetLockOwner:
> + * @fd: file descriptor to get the lock from
> + * @start: byte offset for the lock
> + * @len: length of the lock (0 to specify entire remaining file from @start)
> + * @pid: variable to return the PID of the process owning the lock
> + *
> + * Attempt to retrieve the PID of the process holding an exclusive lock
> + * on the file @fd.

Here I'd mention that the lock has to be acquired via virFileLock(),
because there are plenty of file locks (at least on Linux) that are not
compatible with each other.

But I don't think we will need this function after all.

Michal




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux