/*	Copyright (c) 1984, 1986, 1987, 1988 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.	*/

/*	Copyright (c) 1987, 1988 Microsoft Corporation	*/
/*	  All Rights Reserved	*/

/*	This Module contains Proprietary Information of Microsoft  */
/*	Corporation and should be treated as Confidential.	   */

#ident	"@(#)head.sys:fcntl.h	1.3.1.3"

/* 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_NDELAY 04	/* Non-blocking I/O */
#define	O_APPEND 010	/* append (writes guaranteed at the end) */
#define O_SYNC	 020	/* synchronous write option */

/* 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 */

/* 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 */
#define	F_CHKFL		8	/* reserved */
#define	F_ALLOCSP	10	/* reserved */
#define	F_FREESP	11	/* reserved */
#define F_CHSIZE	0x6000 	/* XENIX chsize() system call */	
#define F_RDCHK		0x6001	/* XENIX rdchk() system call */

/*
 * Fcntl(2) requests made from the XENIX locking(S) system call.  These fcntl() 
 * requests are made only from the kernel.
 *
 * N.B.  The high nibble of the high byte is F_SETLK or F_SETLKW, and the low
 *       nibble of the high byte is F_UNLCK, F_WRLCK, or F_RDLCK.  However,
 *	 no code actually relies on this.  
 */ 

#define F_LK_UNLCK	0x6300	/* locking() LK_UNLCK request */
#define F_LK_LOCK	0x7200	/* locking() LK_LOCK request */
#define F_LK_NBLCK	0x6200	/* locking() LK_NBLCK request */
#define F_LK_RLCK	0x7100	/* locking() LK_RLCK request */
#define F_LK_NBRLCK	0x6100	/* locking() LK_NBRLCK request */

#define LK_CMDTYPE(x)	((x >> 12) & 0x7) /* get high nibble of high byte */
#define LK_LCKTYPE(x)	((x >> 8) & 0x7)  /* get low nibble of high byte */


/* 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;
        short   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
