xref: /illumos-gate/usr/src/uts/common/sys/fcntl.h (revision da6c28aa)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5a5f69788Scraigm  * Common Development and Distribution License (the "License").
6a5f69788Scraigm  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22b9238976Sth  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*
307c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
317c478bd9Sstevel@tonic-gate  * The Regents of the University of California
327c478bd9Sstevel@tonic-gate  * All Rights Reserved
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
357c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
367c478bd9Sstevel@tonic-gate  * contributors.
377c478bd9Sstevel@tonic-gate  */
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #ifndef	_SYS_FCNTL_H
407c478bd9Sstevel@tonic-gate #define	_SYS_FCNTL_H
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h>
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate #include <sys/types.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Flag values accessible to open(2) and fcntl(2)
547c478bd9Sstevel@tonic-gate  * (the first three can only be set by open(2)).
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate #define	O_RDONLY	0
577c478bd9Sstevel@tonic-gate #define	O_WRONLY	1
587c478bd9Sstevel@tonic-gate #define	O_RDWR		2
597c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE)
607c478bd9Sstevel@tonic-gate #define	O_NDELAY	0x04	/* non-blocking I/O */
617c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) */
627c478bd9Sstevel@tonic-gate #define	O_APPEND	0x08	/* append (writes guaranteed at the end) */
637c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) || \
647c478bd9Sstevel@tonic-gate 	(_POSIX_C_SOURCE > 2) || defined(_XOPEN_SOURCE)
657c478bd9Sstevel@tonic-gate #define	O_SYNC		0x10	/* synchronized file update option */
667c478bd9Sstevel@tonic-gate #define	O_DSYNC		0x40	/* synchronized data update option */
677c478bd9Sstevel@tonic-gate #define	O_RSYNC		0x8000	/* synchronized file update option */
687c478bd9Sstevel@tonic-gate 				/* defines read/write file integrity */
697c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(_POSIX_C_SOURCE) ... */
707c478bd9Sstevel@tonic-gate #define	O_NONBLOCK	0x80	/* non-blocking I/O (POSIX) */
717c478bd9Sstevel@tonic-gate #ifdef	SUN_SRC_COMPAT
727c478bd9Sstevel@tonic-gate #define	O_PRIV 		0x1000  /* Private access to file */
737c478bd9Sstevel@tonic-gate #endif /* SUN_SRC_COMPAT */
747c478bd9Sstevel@tonic-gate #ifdef	_LARGEFILE_SOURCE
757c478bd9Sstevel@tonic-gate #define	O_LARGEFILE	0x2000
767c478bd9Sstevel@tonic-gate #endif
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * Flag values accessible only to open(2).
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate #define	O_CREAT		0x100	/* open with file create (uses third arg) */
827c478bd9Sstevel@tonic-gate #define	O_TRUNC		0x200	/* open with truncation */
837c478bd9Sstevel@tonic-gate #define	O_EXCL		0x400	/* exclusive open */
847c478bd9Sstevel@tonic-gate #define	O_NOCTTY	0x800	/* don't allocate controlling tty (POSIX) */
857c478bd9Sstevel@tonic-gate #define	O_XATTR		0x4000	/* extended attribute */
867c478bd9Sstevel@tonic-gate #define	O_NOFOLLOW	0x20000	/* don't follow symlinks */
877c478bd9Sstevel@tonic-gate #define	O_NOLINKS	0x40000	/* don't allow multiple hard links */
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate  * fcntl(2) requests
917c478bd9Sstevel@tonic-gate  *
927c478bd9Sstevel@tonic-gate  * N.B.: values are not necessarily assigned sequentially below.
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate #define	F_DUPFD		0	/* Duplicate fildes */
957c478bd9Sstevel@tonic-gate #define	F_GETFD		1	/* Get fildes flags */
967c478bd9Sstevel@tonic-gate #define	F_SETFD		2	/* Set fildes flags */
977c478bd9Sstevel@tonic-gate #define	F_GETFL		3	/* Get file flags */
987c478bd9Sstevel@tonic-gate #define	F_GETXFL	45	/* Get file flags including open-only flags */
997c478bd9Sstevel@tonic-gate #define	F_SETFL		4	/* Set file flags */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * Applications that read /dev/mem must be built like the kernel.  A
1037c478bd9Sstevel@tonic-gate  * new symbol "_KMEMUSER" is defined for this purpose.
1047c478bd9Sstevel@tonic-gate  */
1057c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER)
1067c478bd9Sstevel@tonic-gate #define	F_O_GETLK	5	/* SVR3 Get file lock (need for rfs, across */
1077c478bd9Sstevel@tonic-gate 				/* the wire compatibility */
1087c478bd9Sstevel@tonic-gate /* clustering: lock id contains both per-node sysid and node id */
1097c478bd9Sstevel@tonic-gate #define	SYSIDMASK		0x0000ffff
1107c478bd9Sstevel@tonic-gate #define	GETSYSID(id)		(id & SYSIDMASK)
1117c478bd9Sstevel@tonic-gate #define	NODEIDMASK		0xffff0000
1127c478bd9Sstevel@tonic-gate #define	BITS_IN_SYSID		16
1137c478bd9Sstevel@tonic-gate #define	GETNLMID(sysid)		((int)(((uint_t)(sysid) & NODEIDMASK) >> \
1147c478bd9Sstevel@tonic-gate 				    BITS_IN_SYSID))
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate /* Clustering: Macro used for PXFS locks */
1177c478bd9Sstevel@tonic-gate #define	GETPXFSID(sysid)	((int)(((uint_t)(sysid) & NODEIDMASK) >> \
1187c478bd9Sstevel@tonic-gate 				    BITS_IN_SYSID))
1197c478bd9Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate #define	F_CHKFL		8	/* Unused */
1227c478bd9Sstevel@tonic-gate #define	F_DUP2FD	9	/* Duplicate fildes at third arg */
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate #define	F_ISSTREAM	13	/* Is the file desc. a stream ? */
1257c478bd9Sstevel@tonic-gate #define	F_PRIV		15	/* Turn on private access to file */
1267c478bd9Sstevel@tonic-gate #define	F_NPRIV		16	/* Turn off private access to file */
1277c478bd9Sstevel@tonic-gate #define	F_QUOTACTL	17	/* UFS quota call */
1287c478bd9Sstevel@tonic-gate #define	F_BLOCKS	18	/* Get number of BLKSIZE blocks allocated */
1297c478bd9Sstevel@tonic-gate #define	F_BLKSIZE	19	/* Get optimal I/O block size */
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * Numbers 20-22 have been removed and should not be reused.
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate #define	F_GETOWN	23	/* Get owner (socket emulation) */
1347c478bd9Sstevel@tonic-gate #define	F_SETOWN	24	/* Set owner (socket emulation) */
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate #ifdef C2_AUDIT
1377c478bd9Sstevel@tonic-gate #define	F_REVOKE	25	/* C2 Security. Revoke access to file desc. */
1387c478bd9Sstevel@tonic-gate #endif
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate #define	F_HASREMOTELOCKS 26	/* Does vp have NFS locks; private to lock */
1417c478bd9Sstevel@tonic-gate 				/* manager */
1427c478bd9Sstevel@tonic-gate 
1437c478bd9Sstevel@tonic-gate /*
1447c478bd9Sstevel@tonic-gate  * Commands that refer to flock structures.  The argument types differ between
1457c478bd9Sstevel@tonic-gate  * the large and small file environments; therefore, the #defined values must
1467c478bd9Sstevel@tonic-gate  * as well.
1477c478bd9Sstevel@tonic-gate  * The NBMAND forms are private and should not be used.
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate #if defined(_LP64) || _FILE_OFFSET_BITS == 32
1517c478bd9Sstevel@tonic-gate /* "Native" application compilation environment */
1527c478bd9Sstevel@tonic-gate #define	F_SETLK		6	/* Set file lock */
1537c478bd9Sstevel@tonic-gate #define	F_SETLKW	7	/* Set file lock and wait */
154303bf60bSsdebnath #define	F_ALLOCSP	10	/* Allocate file space */
1557c478bd9Sstevel@tonic-gate #define	F_FREESP	11	/* Free file space */
1567c478bd9Sstevel@tonic-gate #define	F_GETLK		14	/* Get file lock */
1577c478bd9Sstevel@tonic-gate #define	F_SETLK_NBMAND	42	/* private */
1587c478bd9Sstevel@tonic-gate #else
1597c478bd9Sstevel@tonic-gate /* ILP32 large file application compilation environment version */
1607c478bd9Sstevel@tonic-gate #define	F_SETLK		34	/* Set file lock */
1617c478bd9Sstevel@tonic-gate #define	F_SETLKW	35	/* Set file lock and wait */
162303bf60bSsdebnath #define	F_ALLOCSP	28	/* Alllocate file space */
1637c478bd9Sstevel@tonic-gate #define	F_FREESP	27	/* Free file space */
1647c478bd9Sstevel@tonic-gate #define	F_GETLK		33	/* Get file lock */
1657c478bd9Sstevel@tonic-gate #define	F_SETLK_NBMAND	44	/* private */
1667c478bd9Sstevel@tonic-gate #endif /* _LP64 || _FILE_OFFSET_BITS == 32 */
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #if 	defined(_LARGEFILE64_SOURCE)
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #if !defined(_LP64) || defined(_KERNEL)
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * transitional large file interface version
1737c478bd9Sstevel@tonic-gate  * These are only valid in a 32 bit application compiled with large files
1747c478bd9Sstevel@tonic-gate  * option, for source compatibility, the 64-bit versions are mapped back
1757c478bd9Sstevel@tonic-gate  * to the native versions.
1767c478bd9Sstevel@tonic-gate  */
1777c478bd9Sstevel@tonic-gate #define	F_SETLK64	34	/* Set file lock */
1787c478bd9Sstevel@tonic-gate #define	F_SETLKW64	35	/* Set file lock and wait */
179303bf60bSsdebnath #define	F_ALLOCSP64	28	/* Allocate file space */
1807c478bd9Sstevel@tonic-gate #define	F_FREESP64	27	/* Free file space */
1817c478bd9Sstevel@tonic-gate #define	F_GETLK64	33	/* Get file lock */
1827c478bd9Sstevel@tonic-gate #define	F_SETLK64_NBMAND	44	/* private */
1837c478bd9Sstevel@tonic-gate #else
1847c478bd9Sstevel@tonic-gate #define	F_SETLK64	6	/* Set file lock */
1857c478bd9Sstevel@tonic-gate #define	F_SETLKW64	7	/* Set file lock and wait */
186303bf60bSsdebnath #define	F_ALLOCSP64	10	/* Allocate file space */
1877c478bd9Sstevel@tonic-gate #define	F_FREESP64	11	/* Free file space */
1887c478bd9Sstevel@tonic-gate #define	F_GETLK64	14	/* Get file lock */
1897c478bd9Sstevel@tonic-gate #define	F_SETLK64_NBMAND	42	/* private */
1907c478bd9Sstevel@tonic-gate #endif /* !_LP64 || _KERNEL */
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE */
1937c478bd9Sstevel@tonic-gate 
1947c478bd9Sstevel@tonic-gate #define	F_SHARE		40	/* Set a file share reservation */
1957c478bd9Sstevel@tonic-gate #define	F_UNSHARE	41	/* Remove a file share reservation */
1967c478bd9Sstevel@tonic-gate #define	F_SHARE_NBMAND	43	/* private */
1977c478bd9Sstevel@tonic-gate 
198a5f69788Scraigm #define	F_BADFD		46	/* Create Poison FD */
199a5f69788Scraigm 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * File segment locking set data type - information passed to system by user.
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate /* regular version, for both small and large file compilation environment */
2057c478bd9Sstevel@tonic-gate typedef struct flock {
2067c478bd9Sstevel@tonic-gate 	short	l_type;
2077c478bd9Sstevel@tonic-gate 	short	l_whence;
2087c478bd9Sstevel@tonic-gate 	off_t	l_start;
2097c478bd9Sstevel@tonic-gate 	off_t	l_len;		/* len == 0 means until end of file */
2107c478bd9Sstevel@tonic-gate 	int	l_sysid;
2117c478bd9Sstevel@tonic-gate 	pid_t	l_pid;
2127c478bd9Sstevel@tonic-gate 	long	l_pad[4];		/* reserve area */
2137c478bd9Sstevel@tonic-gate } flock_t;
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /* Kernel's view of ILP32 flock structure */
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate typedef struct flock32 {
2207c478bd9Sstevel@tonic-gate 	int16_t	l_type;
2217c478bd9Sstevel@tonic-gate 	int16_t	l_whence;
2227c478bd9Sstevel@tonic-gate 	off32_t	l_start;
2237c478bd9Sstevel@tonic-gate 	off32_t	l_len;		/* len == 0 means until end of file */
2247c478bd9Sstevel@tonic-gate 	int32_t	l_sysid;
2257c478bd9Sstevel@tonic-gate 	pid32_t	l_pid;
2267c478bd9Sstevel@tonic-gate 	int32_t	l_pad[4];		/* reserve area */
2277c478bd9Sstevel@tonic-gate } flock32_t;
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate /* transitional large file interface version */
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate #if 	defined(_LARGEFILE64_SOURCE)
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate typedef struct flock64 {
2367c478bd9Sstevel@tonic-gate 	short	l_type;
2377c478bd9Sstevel@tonic-gate 	short	l_whence;
2387c478bd9Sstevel@tonic-gate 	off64_t	l_start;
2397c478bd9Sstevel@tonic-gate 	off64_t	l_len;		/* len == 0 means until end of file */
2407c478bd9Sstevel@tonic-gate 	int	l_sysid;
2417c478bd9Sstevel@tonic-gate 	pid_t	l_pid;
2427c478bd9Sstevel@tonic-gate 	long	l_pad[4];		/* reserve area */
2437c478bd9Sstevel@tonic-gate } flock64_t;
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32)
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /* Kernel's view of ILP32 flock64 */
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2507c478bd9Sstevel@tonic-gate #pragma	pack(4)
2517c478bd9Sstevel@tonic-gate #endif
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate typedef struct flock64_32 {
2547c478bd9Sstevel@tonic-gate 	int16_t	l_type;
2557c478bd9Sstevel@tonic-gate 	int16_t	l_whence;
2567c478bd9Sstevel@tonic-gate 	off64_t	l_start;
2577c478bd9Sstevel@tonic-gate 	off64_t	l_len;		/* len == 0 means until end of file */
2587c478bd9Sstevel@tonic-gate 	int32_t	l_sysid;
2597c478bd9Sstevel@tonic-gate 	pid32_t	l_pid;
2607c478bd9Sstevel@tonic-gate 	int32_t	l_pad[4];		/* reserve area */
2617c478bd9Sstevel@tonic-gate } flock64_32_t;
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2647c478bd9Sstevel@tonic-gate #pragma pack()
2657c478bd9Sstevel@tonic-gate #endif
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /* Kernel's view of LP64 flock64 */
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate typedef struct flock64_64 {
2707c478bd9Sstevel@tonic-gate 	int16_t	l_type;
2717c478bd9Sstevel@tonic-gate 	int16_t	l_whence;
2727c478bd9Sstevel@tonic-gate 	off64_t	l_start;
2737c478bd9Sstevel@tonic-gate 	off64_t	l_len;		/* len == 0 means until end of file */
2747c478bd9Sstevel@tonic-gate 	int32_t	l_sysid;
2757c478bd9Sstevel@tonic-gate 	pid32_t	l_pid;
2767c478bd9Sstevel@tonic-gate 	int64_t	l_pad[4];		/* reserve area */
2777c478bd9Sstevel@tonic-gate } flock64_64_t;
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate #endif	/* _SYSCALL32 */
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE */
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate #if defined(_KERNEL) || defined(_KMEMUSER)
2847c478bd9Sstevel@tonic-gate /* SVr3 flock type; needed for rfs across the wire compatibility */
2857c478bd9Sstevel@tonic-gate typedef struct o_flock {
2867c478bd9Sstevel@tonic-gate 	int16_t	l_type;
2877c478bd9Sstevel@tonic-gate 	int16_t	l_whence;
2887c478bd9Sstevel@tonic-gate 	int32_t	l_start;
2897c478bd9Sstevel@tonic-gate 	int32_t	l_len;		/* len == 0 means until end of file */
2907c478bd9Sstevel@tonic-gate 	int16_t	l_sysid;
2917c478bd9Sstevel@tonic-gate 	int16_t	l_pid;
2927c478bd9Sstevel@tonic-gate } o_flock_t;
2937c478bd9Sstevel@tonic-gate #endif	/* defined(_KERNEL) */
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /*
2967c478bd9Sstevel@tonic-gate  * File segment locking types.
2977c478bd9Sstevel@tonic-gate  */
2987c478bd9Sstevel@tonic-gate #define	F_RDLCK		01	/* Read lock */
2997c478bd9Sstevel@tonic-gate #define	F_WRLCK		02	/* Write lock */
3007c478bd9Sstevel@tonic-gate #define	F_UNLCK		03	/* Remove lock(s) */
3017c478bd9Sstevel@tonic-gate #define	F_UNLKSYS	04	/* remove remote locks for a given system */
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate /*
3047c478bd9Sstevel@tonic-gate  * POSIX constants
3057c478bd9Sstevel@tonic-gate  */
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate #define	O_ACCMODE	3	/* Mask for file access modes */
3087c478bd9Sstevel@tonic-gate #define	FD_CLOEXEC	1	/* close on exec flag */
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate /*
3117c478bd9Sstevel@tonic-gate  * DIRECTIO
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate #if defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX)
3147c478bd9Sstevel@tonic-gate #define	DIRECTIO_OFF	(0)
3157c478bd9Sstevel@tonic-gate #define	DIRECTIO_ON	(1)
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate /*
3187c478bd9Sstevel@tonic-gate  * File share reservation type
3197c478bd9Sstevel@tonic-gate  */
3207c478bd9Sstevel@tonic-gate typedef struct fshare {
3217c478bd9Sstevel@tonic-gate 	short	f_access;
3227c478bd9Sstevel@tonic-gate 	short	f_deny;
3237c478bd9Sstevel@tonic-gate 	int	f_id;
3247c478bd9Sstevel@tonic-gate } fshare_t;
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate /*
3277c478bd9Sstevel@tonic-gate  * f_access values
3287c478bd9Sstevel@tonic-gate  */
3297c478bd9Sstevel@tonic-gate #define	F_RDACC		0x1	/* Read-only share access */
3307c478bd9Sstevel@tonic-gate #define	F_WRACC		0x2	/* Write-only share access */
3317c478bd9Sstevel@tonic-gate #define	F_RWACC		0x3	/* Read-Write share access */
332*da6c28aaSamw #define	F_RMACC		0x4	/* private flag: Delete share access */
333*da6c28aaSamw #define	F_MDACC		0x20	/* private flag: Metadata share access */
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate /*
3367c478bd9Sstevel@tonic-gate  * f_deny values
3377c478bd9Sstevel@tonic-gate  */
3387c478bd9Sstevel@tonic-gate #define	F_NODNY		0x0	/* Don't deny others access */
3397c478bd9Sstevel@tonic-gate #define	F_RDDNY		0x1	/* Deny others read share access */
3407c478bd9Sstevel@tonic-gate #define	F_WRDNY		0x2	/* Deny others write share access */
3417c478bd9Sstevel@tonic-gate #define	F_RWDNY		0x3	/* Deny others read or write share access */
342*da6c28aaSamw #define	F_RMDNY		0x4	/* private flag: Deny delete share access */
3437c478bd9Sstevel@tonic-gate #define	F_COMPAT	0x8	/* Set share to old DOS compatibility mode */
3447c478bd9Sstevel@tonic-gate #define	F_MANDDNY	0x10	/* private flag: mandatory enforcement */
3457c478bd9Sstevel@tonic-gate #endif /* defined(__EXTENSIONS__) || !defined(__XOPEN_OR_POSIX) */
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate  * Special flags for functions such as openat(), fstatat()....
3497c478bd9Sstevel@tonic-gate  */
3507c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(_ATFILE_SOURCE) || \
3517c478bd9Sstevel@tonic-gate 	defined(__EXTENSIONS__)
3527c478bd9Sstevel@tonic-gate #define	AT_FDCWD			0xffd19553
3537c478bd9Sstevel@tonic-gate #define	AT_SYMLINK_NOFOLLOW		0x1000
3547c478bd9Sstevel@tonic-gate #define	AT_REMOVEDIR			0x1
355b9238976Sth #define	_AT_TRIGGER			0x2
3567c478bd9Sstevel@tonic-gate #endif
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3597c478bd9Sstevel@tonic-gate }
3607c478bd9Sstevel@tonic-gate #endif
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate #endif	/* _SYS_FCNTL_H */
363