1 | /* $NetBSD: fcntl.h,v 1.10.2.1 1998/01/29 10:38:31 mellon Exp $ */
|
---|
2 |
|
---|
3 | /*-
|
---|
4 | * Copyright (c) 1983, 1990, 1993
|
---|
5 | * The Regents of the University of California. All rights reserved.
|
---|
6 | * (c) UNIX System Laboratories, Inc.
|
---|
7 | * All or some portions of this file are derived from material licensed
|
---|
8 | * to the University of California by American Telephone and Telegraph
|
---|
9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
---|
10 | * the permission of UNIX System Laboratories, Inc.
|
---|
11 | *
|
---|
12 | * Redistribution and use in source and binary forms, with or without
|
---|
13 | * modification, are permitted provided that the following conditions
|
---|
14 | * are met:
|
---|
15 | * 1. Redistributions of source code must retain the above copyright
|
---|
16 | * notice, this list of conditions and the following disclaimer.
|
---|
17 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
18 | * notice, this list of conditions and the following disclaimer in the
|
---|
19 | * documentation and/or other materials provided with the distribution.
|
---|
20 | * 3. All advertising materials mentioning features or use of this software
|
---|
21 | * must display the following acknowledgement:
|
---|
22 | * This product includes software developed by the University of
|
---|
23 | * California, Berkeley and its contributors.
|
---|
24 | * 4. Neither the name of the University nor the names of its contributors
|
---|
25 | * may be used to endorse or promote products derived from this software
|
---|
26 | * without specific prior written permission.
|
---|
27 | *
|
---|
28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
---|
29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
---|
32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
38 | * SUCH DAMAGE.
|
---|
39 | *
|
---|
40 | * @(#)fcntl.h 8.3 (Berkeley) 1/21/94
|
---|
41 | */
|
---|
42 |
|
---|
43 | /*
|
---|
44 | * このプログラムはNetBSD用ヘッダーに
|
---|
45 | * ROMファイル専用ファイルストレージ専用機能を追加したインクルードファイルである。
|
---|
46 | *
|
---|
47 | * $Modifier: roi takeuchi
|
---|
48 | * $Date: 2019/12/03
|
---|
49 | * $Version: 1.0.0.1
|
---|
50 | *
|
---|
51 | */
|
---|
52 | #ifndef _SYS_FCNTL_H_
|
---|
53 | #define _SYS_FCNTL_H_
|
---|
54 |
|
---|
55 | /*
|
---|
56 | * This file includes the definitions for open and fcntl
|
---|
57 | * described by POSIX for <fcntl.h>; it also includes
|
---|
58 | * related kernel definitions.
|
---|
59 | */
|
---|
60 | #ifndef NOTUSE_TYPES_H /* types.hは呼ばない */
|
---|
61 | #include <sys/types.h>
|
---|
62 | #elif defined(__SHC__) /* SHCの場合off_tは未定義 */
|
---|
63 | typedef long long off_t;
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * File status flags: these are used by open(2), fcntl(2).
|
---|
68 | * They are also used (indirectly) in the kernel file structure f_flags,
|
---|
69 | * which is a superset of the open/fcntl flags. Open flags and f_flags
|
---|
70 | * are inter-convertible using OFLAGS(fflags) and FFLAGS(oflags).
|
---|
71 | * Open/fcntl flags begin with O_; kernel-internal flags begin with F.
|
---|
72 | */
|
---|
73 | /* open-only flags */
|
---|
74 | #define O_RDONLY 0x0000 /* open for reading only */
|
---|
75 | #define O_WRONLY 0x0001 /* open for writing only */
|
---|
76 | #define O_RDWR 0x0002 /* open for reading and writing */
|
---|
77 | #define O_ACCMODE 0x0003 /* mask for above modes */
|
---|
78 |
|
---|
79 | /*
|
---|
80 | * Kernel encoding of open mode; separate read and write bits that are
|
---|
81 | * independently testable: 1 greater than the above.
|
---|
82 | *
|
---|
83 | * XXX
|
---|
84 | * FREAD and FWRITE are excluded from the #ifdef _KERNEL so that TIOCFLUSH,
|
---|
85 | * which was documented to use FREAD/FWRITE, continues to work.
|
---|
86 | */
|
---|
87 | #ifndef _POSIX_SOURCE
|
---|
88 | #define FREAD 0x0001
|
---|
89 | #define FWRITE 0x0002
|
---|
90 | #endif
|
---|
91 | #define O_NONBLOCK 0x0004 /* no delay */
|
---|
92 | #define O_APPEND 0x0008 /* set append mode */
|
---|
93 | #ifndef _POSIX_SOURCE
|
---|
94 | #define O_SHLOCK 0x0010 /* open with shared file lock */
|
---|
95 | #define O_EXLOCK 0x0020 /* open with exclusive file lock */
|
---|
96 | #define O_ASYNC 0x0040 /* signal pgrp when data ready */
|
---|
97 | #endif
|
---|
98 | #if !defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
|
---|
99 | #define O_SYNC 0x0080 /* synchronous writes */
|
---|
100 | #endif
|
---|
101 | #define O_CREAT 0x0200 /* create if nonexistant */
|
---|
102 | #define O_TRUNC 0x0400 /* truncate to zero length */
|
---|
103 | #define O_EXCL 0x0800 /* error if already exists */
|
---|
104 |
|
---|
105 | /* defined by POSIX 1003.1; BSD default, but required to be distinct */
|
---|
106 | #define O_NOCTTY 0x8000 /* don't assign controlling terminal */
|
---|
107 |
|
---|
108 | /*
|
---|
109 | * The O_* flags used to have only F* names, which were used in the kernel
|
---|
110 | * and by fcntl. We retain the F* names for the kernel f_flags field
|
---|
111 | * and for backward compatibility for fcntl.
|
---|
112 | */
|
---|
113 | #ifndef _POSIX_SOURCE
|
---|
114 | #define FAPPEND O_APPEND /* kernel/compat */
|
---|
115 | #define FASYNC O_ASYNC /* kernel/compat */
|
---|
116 | #define FFSYNC O_SYNC /* kernel */
|
---|
117 | #ifndef _XOPEN_SOURCE
|
---|
118 | #define O_FSYNC O_SYNC /* compat */
|
---|
119 | #endif
|
---|
120 | #define FNONBLOCK O_NONBLOCK /* kernel */
|
---|
121 | #define FNDELAY O_NONBLOCK /* compat */
|
---|
122 | #define O_NDELAY O_NONBLOCK /* compat */
|
---|
123 | #endif
|
---|
124 |
|
---|
125 | /*
|
---|
126 | * Constants used for fcntl(2)
|
---|
127 | */
|
---|
128 |
|
---|
129 | /* command values */
|
---|
130 | #define F_DUPFD 0 /* duplicate file descriptor */
|
---|
131 | #define F_GETFD 1 /* get file descriptor flags */
|
---|
132 | #define F_SETFD 2 /* set file descriptor flags */
|
---|
133 | #define F_GETFL 3 /* get file status flags */
|
---|
134 | #define F_SETFL 4 /* set file status flags */
|
---|
135 | #ifndef _POSIX_SOURCE
|
---|
136 | #define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
|
---|
137 | #define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
|
---|
138 | #endif
|
---|
139 | #define F_GETLK 7 /* get record locking information */
|
---|
140 | #define F_SETLK 8 /* set record locking information */
|
---|
141 | #define F_SETLKW 9 /* F_SETLK; wait if blocked */
|
---|
142 |
|
---|
143 | /* file descriptor flags (F_GETFD, F_SETFD) */
|
---|
144 | #define FD_CLOEXEC 1 /* close-on-exec flag */
|
---|
145 |
|
---|
146 | /* record locking flags (F_GETLK, F_SETLK, F_SETLKW) */
|
---|
147 | #define F_RDLCK 1 /* shared or read lock */
|
---|
148 | #define F_UNLCK 2 /* unlock */
|
---|
149 | #define F_WRLCK 3 /* exclusive or write lock */
|
---|
150 |
|
---|
151 | #ifndef _POSIX_SOURCE
|
---|
152 | /* lock operations for flock(2) */
|
---|
153 | #define LOCK_SH 0x01 /* shared file lock */
|
---|
154 | #define LOCK_EX 0x02 /* exclusive file lock */
|
---|
155 | #define LOCK_NB 0x04 /* don't block when locking */
|
---|
156 | #define LOCK_UN 0x08 /* unlock file */
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | /* fseek parameters */
|
---|
160 | #ifndef SEEK_SET
|
---|
161 | #define SEEK_SET 0 /* set file offset to offset */
|
---|
162 | #endif
|
---|
163 | #ifndef SEEK_CUR
|
---|
164 | #define SEEK_CUR 1 /* set file offset to current plus offset */
|
---|
165 | #endif
|
---|
166 | #ifndef SEEK_END
|
---|
167 | #define SEEK_END 2 /* set file offset to EOF plus offset */
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | /* struct stat defintion */
|
---|
171 | #ifndef _SYS_STAT_H
|
---|
172 | struct stat {
|
---|
173 | unsigned int st_dev; /* inode's device */
|
---|
174 | unsigned int st_ino; /* inode's number */
|
---|
175 | unsigned int st_mode; /* inode protection mode */
|
---|
176 | unsigned int t_nlink; /* number of hard links */
|
---|
177 | unsigned int st_uid; /* user ID of the file's owner */
|
---|
178 | unsigned int st_gid; /* group ID of the file's group */
|
---|
179 | unsigned int st_rdev; /* device type */
|
---|
180 | int st_atime; /* time of last access */
|
---|
181 | long st_atimensec; /* nsec of last access */
|
---|
182 | int st_mtime; /* time of last data modification */
|
---|
183 | long st_mtimensec; /* nsec of last data modification */
|
---|
184 | int st_ctime; /* time of last file status change */
|
---|
185 | long st_ctimensec; /* nsec of last file status change */
|
---|
186 | off_t st_size; /* file size, in bytes */
|
---|
187 | off_t st_blocks; /* blocks allocated for file */
|
---|
188 | unsigned int st_blksize; /* optimal blocksize for I/O */
|
---|
189 | unsigned int st_flags; /* user defined flags for file */
|
---|
190 | unsigned int st_gen; /* file generation number */
|
---|
191 | off_t st_qspare[2];
|
---|
192 | };
|
---|
193 | #define _STAT_H_
|
---|
194 | #endif /* _SYS_STAT_H */
|
---|
195 |
|
---|
196 | /*
|
---|
197 | * Protections are chosen from these bits, or-ed together
|
---|
198 | */
|
---|
199 | #define PROT_NONE 0x00 /* no permissions */
|
---|
200 | #define PROT_READ 0x01 /* pages can be read */
|
---|
201 | #define PROT_WRITE 0x02 /* pages can be written */
|
---|
202 | #define PROT_EXEC 0x04 /* pages can be executed */
|
---|
203 |
|
---|
204 | /*
|
---|
205 | * Flags contain sharing type and options.
|
---|
206 | * Sharing types; choose one.
|
---|
207 | */
|
---|
208 | #define MAP_SHARED 0x0001 /* share changes */
|
---|
209 | #define MAP_PRIVATE 0x0002 /* changes are private */
|
---|
210 | #define MAP_COPY 0x0004 /* "copy" region at mmap time */
|
---|
211 |
|
---|
212 | struct StdFileIndex {
|
---|
213 | void *sdmdev;
|
---|
214 | int sdmfd;
|
---|
215 | };
|
---|
216 |
|
---|
217 | extern int open(const char *pathname, int flags);
|
---|
218 | extern int close(int fd);
|
---|
219 | extern int fstat(int fd, struct stat *buf);
|
---|
220 | extern off_t lseek(int fd, off_t offset, int whence);
|
---|
221 | extern long read(int fd, void *buf, long count);
|
---|
222 | extern long write(int fd, const void *buf, long count);
|
---|
223 | extern void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
|
---|
224 | extern int munmap(void *start, size_t length);
|
---|
225 |
|
---|
226 |
|
---|
227 | #endif /* !_SYS_FCNTL_H_ */
|
---|
228 |
|
---|
229 |
|
---|