fcntl.c revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <unistd.h>
#include <fcntl.h>
#include <stropts.h>
#include <libintl.h>
#include <errno.h>
#include <string.h>
#include <sys/lx_fcntl.h>
#include <sys/lx_debug.h>
static int lx_fcntl_getfl(int fd);
int
{
int rc;
}
int
{
int lk = 0;
int rc;
/*
* The 64-bit fcntl commands must go through fcntl64().
*/
cmd == LX_F_SETLKW64)
return (-EINVAL);
cmd == LX_F_GETLEASE) {
"fcntl", cmd);
return (-ENOTSUP);
}
cmd == LX_F_SETLKW) {
sizeof (struct lx_flock)) != 0)
return (-errno);
lk = 1;
}
if (lk)
return (rc);
}
int
{
struct lx_flock64 lxflk64;
int rc;
cmd == LX_F_GETLEASE) {
"fcntl64", cmd);
return (-ENOTSUP);
}
sizeof (struct lx_flock)) != 0)
return (-errno);
cmd == LX_F_SETLK64) {
sizeof (struct lx_flock64)) != 0)
return (-errno);
} else {
}
return (rc);
}
static int
{
int rc = 0;
switch (cmd) {
case LX_F_DUPFD:
break;
case LX_F_GETFD:
break;
case LX_F_SETFD:
break;
case LX_F_GETFL:
break;
case LX_F_SETFL:
break;
case LX_F_GETLK:
break;
case LX_F_SETLK:
break;
case LX_F_SETLKW:
break;
case LX_F_GETLK64:
break;
case LX_F_SETLK64:
break;
case LX_F_SETLKW64:
break;
case LX_F_SETOWN:
break;
case LX_F_GETOWN:
lx_debug("\tioctl(%d, 0x%x - %s, ...)",
break;
default:
return (-EINVAL);
}
}
#define LTOS_FLOCK(l, s) \
{ \
s->l_sysid = 0; /* not defined in linux */ \
}
#define STOL_FLOCK(s, l) \
{ \
}
static void
{
LTOS_FLOCK(l, s)
}
static void
{
STOL_FLOCK(s, l)
}
static void
{
LTOS_FLOCK(l, s)
}
static void
{
STOL_FLOCK(s, l)
}
static short
{
switch (l_type) {
case LX_F_RDLCK:
return (F_RDLCK);
case LX_F_WRLCK:
return (F_WRLCK);
case LX_F_UNLCK:
return (F_UNLCK);
default:
return (-1);
}
}
static short
{
switch (l_type) {
case F_RDLCK:
return (LX_F_RDLCK);
case F_WRLCK:
return (LX_F_WRLCK);
case F_UNLCK:
return (LX_F_UNLCK);
default:
/* can't ever happen */
return (0);
}
}
int
lx_fcntl_getfl(int fd)
{
int retval;
int rc;
rc = LX_O_RDONLY;
rc = LX_O_WRONLY;
else
/* O_NDELAY != O_NONBLOCK, so we need to check for both */
rc |= LX_O_NDELAY;
if (retval & O_NONBLOCK)
rc |= LX_O_NONBLOCK;
rc |= LX_O_APPEND;
if (retval & O_LARGEFILE)
rc |= LX_O_LARGEFILE;
return (rc);
}
int
{
int new_arg;
new_arg = 0;
/* LX_O_NDELAY == LX_O_NONBLOCK, so we only check for one */
if (arg & LX_O_NDELAY)
new_arg |= O_NONBLOCK;
if (arg & LX_O_APPEND)
if (arg & LX_O_LARGEFILE)
new_arg |= O_LARGEFILE;
}
/*
* flock() applies or removes an advisory lock on the file
* associated with the file descriptor fd.
*
*
* operation is: LX_LOCK_SH, LX_LOCK_EX, LX_LOCK_UN, LX_LOCK_NB
*/
int
{
int cmd;
int ret;
/* In non-blocking lock, use F_SETLK for cmd, F_SETLKW otherwise */
if (operation & LX_LOCK_NB) {
} else
switch (operation) {
case LX_LOCK_UN:
break;
case LX_LOCK_SH:
break;
case LX_LOCK_EX:
break;
default:
return (-EINVAL);
}
return (-EWOULDBLOCK);
}