/* $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */

/*	Copyright (c) 1984 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident	"$Header: fcntl.h 1.9 90/07/29 $"

#ifndef	_SYS_FCNTL_H_

#include <sys/types.h>

/* $Log:	fcntl.h,v $
*/

/*____________________________________________________________________*
 * This file forms part of the POSIX requirement described in sections*
 * 5.3 & 6.5 of 1003.1-1988 which should be refered to before making  *
 * any changes.							      *
 *____________________________________________________________________*/

/* POSIX 1003.1-1988 5.3.1.2 & 6.5.1 */
/* Flag values accessible to open(2) and fcntl(2) */
/*  (The first three can only be set by open) */
#define	O_RDONLY 0
#define	O_WRONLY 1
#define	O_RDWR	 2
#define	O_NONBLOCK 04   /* Non-blocking I/O */
#define	O_APPEND 010	/* append (writes guaranteed at the end) */
#ifndef	_POSIX_SOURCE
#define O_SYNC	 020	/* synchronous write option */
#define	O_NDELAY 04	/* Non-blocking I/O for SVID compliance */
#endif	/*_POSIX_SOURCE*/

/* POSIX 1003.1-1988 6.5.1 */
#define	FD_CLOEXEC	1		/* Close-on-exec flag */
#ifndef	_POSIX_SOURCE
#define	FD_MAPPED	2		/* Mapped from device */
#define	FD_BITS		(FD_CLOEXEC)	/* User-visible bits in flags */
#endif	/*_POSIX_SOURCE*/
#define	O_ACCMODE  	(O_RDONLY | O_WRONLY | O_RDWR) /* Access mode mask*/


/* Flag values accessible only to open(2) */
#define	O_CREAT	00400	/* open with file create (uses third open arg)*/
#define	O_TRUNC	01000	/* open with truncation */
#define	O_EXCL	02000	/* exclusive open */
#define	O_NOCTTY 04000	/* don't assign a controlling terminal */

/* fcntl(2) requests */
#define	F_DUPFD		0	/* Duplicate fildes */
#define	F_GETFD		1	/* Get fildes flags */
#define	F_SETFD		2	/* Set fildes flags */
#define	F_GETFL		3	/* Get file flags */
#define	F_SETFL		4	/* Set file flags */
#define	F_GETLK		5	/* Get file lock */
#define	F_SETLK		6	/* Set file lock */
#define	F_SETLKW	7	/* Set file lock and wait */
#ifndef	_POSIX_SOURCE
#define	F_CHKFL		8	/* Check legality of file flag changes */
#define	F_ALLOCSP	10	/* reserved */
#define	F_FREESP	11	/* reserved */
#endif	/*_POSIX_SOURCE*/

/* file segment locking set data type - information passed to system by user */
struct flock {
	short	l_type;
	short	l_whence;
	long	l_start;
	long	l_len;		/* len = 0 means until end of file */
	short	l_sysid;
	pid_t	l_pid;
};

/* file segment locking types */
	/* Read lock */
#define	F_RDLCK	01
	/* Write lock */
#define	F_WRLCK	02
	/* Remove lock(s) */
#define	F_UNLCK	03

#define	_SYS_FCNTL_H_
#endif	/*_SYS_FCNTL_H_*/

