Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2013-06-04 14:24:43 +0400
committerCorinna Vinschen <corinna@vinschen.de>2013-06-04 14:24:43 +0400
commitedd73646f3c33f22d90957f1675308f902c6a00e (patch)
tree9e923948b0d9d08f9e4997b051fa2486fddfb029 /winsup/cygwin/flock.cc
parentca1dd3a9b5ac53f50c12ea146cd9aa4485ad9aa4 (diff)
* fhandler.cc (fhandler_base::lock): Move to flock.cc.
(fhandler_base::fixup_after_exec): Reset mandatory_locking. * fhandler.h (class fhandler_base): Add mandatory_locking status flag. Add mandatory_locking accessor methods. Accommodate change throughout. (fhandler_base::mand_lock): Declare. (class fhandler_disk_file): Drop in favor of new status flag. * (fhandler_disk_file::fcntl): Call need_fork_fixup if mandatory_locking flag gets set. * flock.cc (fhandler_base::lock): Define here. (flock): Handle mandatory_locking. (lockf): Ditto. (fhandler_base::mand_lock): Define.
Diffstat (limited to 'winsup/cygwin/flock.cc')
-rw-r--r--winsup/cygwin/flock.cc28
1 files changed, 23 insertions, 5 deletions
diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc
index f7d19398b..c9d7eb6ea 100644
--- a/winsup/cygwin/flock.cc
+++ b/winsup/cygwin/flock.cc
@@ -919,6 +919,13 @@ static void lf_wakelock (lockf_t *, HANDLE);
of mandatory locks using the Windows mandatory locking functions, see the
fhandler_disk_file::mand_lock method at the end of this file. */
int
+fhandler_base::lock (int, struct flock *)
+{
+ set_errno (EINVAL);
+ return -1;
+}
+
+int
fhandler_disk_file::lock (int a_op, struct flock *fl)
{
off_t start, end, oadd;
@@ -1733,19 +1740,22 @@ flock (int fd, int operation)
switch (operation & (~LOCK_NB))
{
case LOCK_EX:
- fl.l_type = F_WRLCK | F_FLOCK;
+ fl.l_type = F_WRLCK;
break;
case LOCK_SH:
- fl.l_type = F_RDLCK | F_FLOCK;
+ fl.l_type = F_RDLCK;
break;
case LOCK_UN:
- fl.l_type = F_UNLCK | F_FLOCK;
+ fl.l_type = F_UNLCK;
break;
default:
set_errno (EINVAL);
goto done;
}
- res = cfd->lock (cmd, &fl);
+ if (!cfd->mandatory_locking ())
+ fl.l_type |= F_FLOCK;
+ res = cfd->mandatory_locking () ? cfd->mand_lock (cmd, &fl)
+ : cfd->lock (cmd, &fl);
if ((res == -1) && ((get_errno () == EAGAIN) || (get_errno () == EACCES)))
set_errno (EWOULDBLOCK);
done:
@@ -1803,7 +1813,8 @@ lockf (int filedes, int function, off_t size)
goto done;
/* NOTREACHED */
}
- res = cfd->lock (cmd, &fl);
+ res = cfd->mandatory_locking () ? cfd->mand_lock (cmd, &fl)
+ : cfd->lock (cmd, &fl);
done:
syscall_printf ("%R = lockf(%d, %d, %D)", res, filedes, function, size);
return res;
@@ -1832,6 +1843,13 @@ blocking_lock_thr (LPVOID param)
}
int
+fhandler_base::mand_lock (int, struct flock *)
+{
+ set_errno (EINVAL);
+ return -1;
+}
+
+int
fhandler_disk_file::mand_lock (int a_op, struct flock *fl)
{
NTSTATUS status;