xref: /illumos-gate/usr/src/ucbhead/sys/file.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved	*/
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
32*7c478bd9Sstevel@tonic-gate  * The Regents of the University of California
33*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
36*7c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
37*7c478bd9Sstevel@tonic-gate  * contributors.
38*7c478bd9Sstevel@tonic-gate  */
40*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FILE_H
41*7c478bd9Sstevel@tonic-gate #define	_SYS_FILE_H
43*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
45*7c478bd9Sstevel@tonic-gate #ifndef _SYS_TYPES_H
46*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
47*7c478bd9Sstevel@tonic-gate #endif
49*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
50*7c478bd9Sstevel@tonic-gate extern "C" {
51*7c478bd9Sstevel@tonic-gate #endif
53*7c478bd9Sstevel@tonic-gate /*
54*7c478bd9Sstevel@tonic-gate  * One file structure is allocated for each open/creat/pipe call.
55*7c478bd9Sstevel@tonic-gate  * Main use is to hold the read/write pointer associated with
56*7c478bd9Sstevel@tonic-gate  * each open file.
57*7c478bd9Sstevel@tonic-gate  */
59*7c478bd9Sstevel@tonic-gate typedef struct file
60*7c478bd9Sstevel@tonic-gate {
61*7c478bd9Sstevel@tonic-gate 	struct file  *f_next;		/* pointer to next entry */
62*7c478bd9Sstevel@tonic-gate 	struct file  *f_prev;		/* pointer to previous entry */
63*7c478bd9Sstevel@tonic-gate 	ushort_t f_flag;
64*7c478bd9Sstevel@tonic-gate 	cnt_t	f_count;		/* reference count */
65*7c478bd9Sstevel@tonic-gate 	struct vnode *f_vnode;		/* pointer to vnode structure */
66*7c478bd9Sstevel@tonic-gate 	off_t	f_offset;		/* read/write character pointer */
67*7c478bd9Sstevel@tonic-gate 	struct	cred *f_cred;		/* credentials of user who opened it */
68*7c478bd9Sstevel@tonic-gate 	struct	aioreq *f_aiof;		/* aio file list forward link	*/
69*7c478bd9Sstevel@tonic-gate 	struct	aioreq *f_aiob;		/* aio file list backward link	*/
70*7c478bd9Sstevel@tonic-gate /* #ifdef MERGE */
71*7c478bd9Sstevel@tonic-gate 	struct	file *f_slnk;		/* XENIX semaphore queue */
72*7c478bd9Sstevel@tonic-gate /* #endif MERGE */
73*7c478bd9Sstevel@tonic-gate } file_t;
76*7c478bd9Sstevel@tonic-gate #ifndef _SYS_FCNTL_H
77*7c478bd9Sstevel@tonic-gate #include <sys/fcntl.h>
78*7c478bd9Sstevel@tonic-gate #endif
80*7c478bd9Sstevel@tonic-gate /* flags - see also fcntl.h */
82*7c478bd9Sstevel@tonic-gate #ifndef FOPEN
83*7c478bd9Sstevel@tonic-gate #define	FOPEN	0xFFFFFFFF
84*7c478bd9Sstevel@tonic-gate #define	FREAD	0x01
85*7c478bd9Sstevel@tonic-gate #define	FWRITE	0x02
86*7c478bd9Sstevel@tonic-gate #define	FNDELAY	0x04
87*7c478bd9Sstevel@tonic-gate #define	FAPPEND	0x08
88*7c478bd9Sstevel@tonic-gate #define	FSYNC	0x10
89*7c478bd9Sstevel@tonic-gate #define	FNONBLOCK	0x80	/* Non-blocking flag (POSIX).	*/
91*7c478bd9Sstevel@tonic-gate #define	FMASK	0xff		/* should be disjoint from FASYNC */
93*7c478bd9Sstevel@tonic-gate /* open only modes */
95*7c478bd9Sstevel@tonic-gate #define	FCREAT	0x100
96*7c478bd9Sstevel@tonic-gate #define	FTRUNC	0x200
97*7c478bd9Sstevel@tonic-gate #define	FEXCL	0x400
98*7c478bd9Sstevel@tonic-gate #define	FNOCTTY	0x800		/* don't allocate controlling tty (POSIX). */
99*7c478bd9Sstevel@tonic-gate #define	FASYNC	0x1000		/* asyncio is in progress */
100*7c478bd9Sstevel@tonic-gate #define	FPRIV	0x1000		/* open with private access */
102*7c478bd9Sstevel@tonic-gate /* file descriptor flags */
103*7c478bd9Sstevel@tonic-gate #define	FCLOSEXEC	001	/* close on exec */
104*7c478bd9Sstevel@tonic-gate #endif
106*7c478bd9Sstevel@tonic-gate /* record-locking options. */
107*7c478bd9Sstevel@tonic-gate #define	F_ULOCK		0	/* Unlock a previously locked region */
108*7c478bd9Sstevel@tonic-gate #define	F_LOCK		1	/* Lock a region for exclusive use */
109*7c478bd9Sstevel@tonic-gate #define	F_TLOCK		2	/* Test and lock a region for exclusive use */
110*7c478bd9Sstevel@tonic-gate #define	F_TEST		3	/* Test a region for other processes locks */
112*7c478bd9Sstevel@tonic-gate /*
113*7c478bd9Sstevel@tonic-gate  * flock operations.
114*7c478bd9Sstevel@tonic-gate  */
115*7c478bd9Sstevel@tonic-gate #define	LOCK_SH		1	/* shared lock */
116*7c478bd9Sstevel@tonic-gate #define	LOCK_EX		2	/* exclusive lock */
117*7c478bd9Sstevel@tonic-gate #define	LOCK_NB		4	/* don't block when locking */
118*7c478bd9Sstevel@tonic-gate #define	LOCK_UN		8	/* unlock */
120*7c478bd9Sstevel@tonic-gate /*
121*7c478bd9Sstevel@tonic-gate  * Access call.
122*7c478bd9Sstevel@tonic-gate  */
123*7c478bd9Sstevel@tonic-gate #define	F_OK		0	/* does file exist */
124*7c478bd9Sstevel@tonic-gate #define	X_OK		1	/* is it executable by caller */
125*7c478bd9Sstevel@tonic-gate #define	W_OK		2	/* writable by caller */
126*7c478bd9Sstevel@tonic-gate #define	R_OK		4	/* readable by caller */
128*7c478bd9Sstevel@tonic-gate /*
129*7c478bd9Sstevel@tonic-gate  * Lseek call.
130*7c478bd9Sstevel@tonic-gate  */
131*7c478bd9Sstevel@tonic-gate #ifndef L_SET
132*7c478bd9Sstevel@tonic-gate #define	L_SET		0	/* absolute offset */
133*7c478bd9Sstevel@tonic-gate #define	L_INCR		1	/* relative to current offset */
134*7c478bd9Sstevel@tonic-gate #define	L_XTND		2	/* relative to end of file */
135*7c478bd9Sstevel@tonic-gate #endif
138*7c478bd9Sstevel@tonic-gate /* miscellaneous defines */
140*7c478bd9Sstevel@tonic-gate #define	NULLFP ((struct file *)0)
142*7c478bd9Sstevel@tonic-gate /*
143*7c478bd9Sstevel@tonic-gate  * Count of number of entries in file list.
144*7c478bd9Sstevel@tonic-gate  */
145*7c478bd9Sstevel@tonic-gate extern unsigned int filecnt;
147*7c478bd9Sstevel@tonic-gate /*
148*7c478bd9Sstevel@tonic-gate  * routines dealing with user per-open file flags and
149*7c478bd9Sstevel@tonic-gate  * user open files.  getf() is declared in systm.h.  It
150*7c478bd9Sstevel@tonic-gate  * probably belongs here.
151*7c478bd9Sstevel@tonic-gate  */
152*7c478bd9Sstevel@tonic-gate #if defined(__STDC__)
153*7c478bd9Sstevel@tonic-gate extern void setf(int, file_t *);
154*7c478bd9Sstevel@tonic-gate extern void setpof(int, char);
155*7c478bd9Sstevel@tonic-gate extern char getpof(int);
156*7c478bd9Sstevel@tonic-gate extern int fassign(struct vnode **, int, int *);
157*7c478bd9Sstevel@tonic-gate #else
158*7c478bd9Sstevel@tonic-gate extern void setf(), setpof();
159*7c478bd9Sstevel@tonic-gate extern char getpof();
160*7c478bd9Sstevel@tonic-gate extern int fassign();
161*7c478bd9Sstevel@tonic-gate #endif
163*7c478bd9Sstevel@tonic-gate extern off_t lseek();
165*7c478bd9Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
166*7c478bd9Sstevel@tonic-gate 	!defined(__PRAGMA_REDEFINE_EXTNAME))
167*7c478bd9Sstevel@tonic-gate #if defined(__STDC__)
168*7c478bd9Sstevel@tonic-gate extern off64_t lseek64(int, off64_t, int);
169*7c478bd9Sstevel@tonic-gate #else
170*7c478bd9Sstevel@tonic-gate extern off64_t llseek64();
171*7c478bd9Sstevel@tonic-gate #endif
172*7c478bd9Sstevel@tonic-gate #endif  /* _LARGEFILE64_SOURCE... */
174*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
175*7c478bd9Sstevel@tonic-gate }
176*7c478bd9Sstevel@tonic-gate #endif
178*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_FILE_H */