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