From 9ef0becaa64d91f0414ca48d4fb61cfabaed6fdb Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 30 Aug 2013 22:35:47 -0700 Subject: [PATCH] do_lock(): open file in read/write mode Apparently, flock(LOCK_EX) requires a read/write opened file descriptor in order to succeed on NFSv4. This should fix the following error trying to use ploop on NFSv4 share: Error in do_lock (lock.c:136): Error in flock(<....>/DiskDescriptor.xml.lck): Bad file descriptor https://bugzilla.openvz.org/2730 Reported-by: Pavel Odintsov Signed-off-by: Kir Kolyshkin --- lib/lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lock.c b/lib/lock.c index 1e1dc54..737d5a2 100644 --- a/lib/lock.c +++ b/lib/lock.c @@ -98,7 +98,7 @@ static int do_lock(const char *fname, unsigned int timeout) .sa_handler = timer_handler, }; - if ((fd = open(fname, O_RDONLY)) == -1) { + if ((fd = open(fname, O_RDWR)) == -1) { ploop_err(errno, "Can't open lock file %s", fname); return -1; } -- 1.8.1.4