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