Pull in fcntl GETLK/SETLK/UNLK compat functions from SVR4 sibling.
This commit is contained in:
parent
4a0b2d1b52
commit
5641a30a30
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sunos_ioctl.c,v 1.27 1997/10/19 20:59:32 is Exp $ */
|
||||
/* $NetBSD: sunos_ioctl.c,v 1.28 1997/12/11 09:52:57 pk Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Markus Wild.
|
||||
@ -46,6 +46,7 @@
|
||||
#include <sys/syscallargs.h>
|
||||
#include <compat/sunos/sunos.h>
|
||||
#include <compat/sunos/sunos_syscallargs.h>
|
||||
#include <compat/sunos/sunos_util.h>
|
||||
|
||||
/*
|
||||
* SunOS ioctl calls.
|
||||
@ -821,6 +822,77 @@ sunos_sys_ioctl(p, v, retval)
|
||||
#define SUN_F_CNVT 12
|
||||
#define SUN_F_RSETLKW 13
|
||||
|
||||
/* SunOS flock translation */
|
||||
struct sunos_flock {
|
||||
short l_type;
|
||||
short l_whence;
|
||||
long l_start;
|
||||
long l_len;
|
||||
short l_pid;
|
||||
short l_xxx;
|
||||
};
|
||||
|
||||
static void bsd_to_sunos_flock __P((struct flock *, struct sunos_flock *));
|
||||
static void sunos_to_bsd_flock __P((struct sunos_flock *, struct flock *));
|
||||
|
||||
#define SUNOS_F_RDLCK 1
|
||||
#define SUNOS_F_WRLCK 2
|
||||
#define SUNOS_F_UNLCK 3
|
||||
|
||||
static void
|
||||
bsd_to_sunos_flock(iflp, oflp)
|
||||
struct flock *iflp;
|
||||
struct sunos_flock *oflp;
|
||||
{
|
||||
switch (iflp->l_type) {
|
||||
case F_RDLCK:
|
||||
oflp->l_type = SUNOS_F_RDLCK;
|
||||
break;
|
||||
case F_WRLCK:
|
||||
oflp->l_type = SUNOS_F_WRLCK;
|
||||
break;
|
||||
case F_UNLCK:
|
||||
oflp->l_type = SUNOS_F_UNLCK;
|
||||
break;
|
||||
default:
|
||||
oflp->l_type = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
oflp->l_whence = (short) iflp->l_whence;
|
||||
oflp->l_start = (long) iflp->l_start;
|
||||
oflp->l_len = (long) iflp->l_len;
|
||||
oflp->l_pid = (short) iflp->l_pid;
|
||||
oflp->l_xxx = 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
sunos_to_bsd_flock(iflp, oflp)
|
||||
struct sunos_flock *iflp;
|
||||
struct flock *oflp;
|
||||
{
|
||||
switch (iflp->l_type) {
|
||||
case SUNOS_F_RDLCK:
|
||||
oflp->l_type = F_RDLCK;
|
||||
break;
|
||||
case SUNOS_F_WRLCK:
|
||||
oflp->l_type = F_WRLCK;
|
||||
break;
|
||||
case SUNOS_F_UNLCK:
|
||||
oflp->l_type = F_UNLCK;
|
||||
break;
|
||||
default:
|
||||
oflp->l_type = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
oflp->l_whence = iflp->l_whence;
|
||||
oflp->l_start = (off_t) iflp->l_start;
|
||||
oflp->l_len = (off_t) iflp->l_len;
|
||||
oflp->l_pid = (pid_t) iflp->l_pid;
|
||||
|
||||
}
|
||||
static struct {
|
||||
long sun_flg;
|
||||
long bsd_flg;
|
||||
@ -866,6 +938,45 @@ sunos_sys_fcntl(p, v, retval)
|
||||
SCARG(uap, arg) = (void *)flg;
|
||||
break;
|
||||
|
||||
case F_GETLK:
|
||||
case F_SETLK:
|
||||
case F_SETLKW:
|
||||
{
|
||||
int error;
|
||||
struct sunos_flock ifl;
|
||||
struct flock *flp, fl;
|
||||
caddr_t sg = stackgap_init(p->p_emul);
|
||||
struct sys_fcntl_args fa;
|
||||
|
||||
SCARG(&fa, fd) = SCARG(uap, fd);
|
||||
SCARG(&fa, cmd) = SCARG(uap, cmd);
|
||||
|
||||
flp = stackgap_alloc(&sg, sizeof(struct flock));
|
||||
SCARG(&fa, arg) = (void *) flp;
|
||||
|
||||
error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
sunos_to_bsd_flock(&ifl, &fl);
|
||||
|
||||
error = copyout(&fl, flp, sizeof fl);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = sys_fcntl(p, &fa, retval);
|
||||
if (error || SCARG(&fa, cmd) != F_GETLK)
|
||||
return error;
|
||||
|
||||
error = copyin(flp, &fl, sizeof fl);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
bsd_to_sunos_flock(&fl, &ifl);
|
||||
|
||||
return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
|
||||
}
|
||||
break;
|
||||
case SUN_F_RGETLK:
|
||||
case SUN_F_RSETLK:
|
||||
case SUN_F_CNVT:
|
||||
|
Loading…
Reference in New Issue
Block a user