On 07/07/2011 08:17 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Add some simple wrappers around the fcntl() discretionary file
locking capability.
* src/util/util.c, src/util/util.h, src/libvirt_private.syms: Add
virFileLock and virFileUnlock APIs
---
src/libvirt_private.syms | 2 ++
src/util/util.c | 33 +++++++++++++++++++++++++++++++++
src/util/util.h | 3 +++
3 files changed, 38 insertions(+), 0 deletions(-)
+
+int virFileLock(int fd, bool shared, off_t start, off_t len)
+{
+ struct flock fl = {
+ .l_type = shared ? F_RDLCK : F_WRLCK,
+ .l_whence = SEEK_SET,
+ .l_start = start,
+ .l_len = len,
+ };
This won't compile on mingw. We need to either make a no-op stub, or
figure out how to do rudimentary file locking on mingw, or get gnulib to
figure it out (probably the first option is easiest for now).
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org