* 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.
This commit is contained in:
Corinna Vinschen
2013-06-04 10:24:43 +00:00
parent ca1dd3a9b5
commit edd73646f3
6 changed files with 51 additions and 22 deletions

View File

@@ -918,6 +918,13 @@ static void lf_wakelock (lockf_t *, HANDLE);
/* This is the fcntl advisory lock implementation. For the implementation
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)
{
@@ -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;
@@ -1831,6 +1842,13 @@ blocking_lock_thr (LPVOID param)
return 0;
}
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)
{