VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/fcntl.h@ 48674

Last change on this file since 48674 was 48674, checked in by vboxsync, 12 years ago

EFI: Export newly imported tinaocore UEFI sources to OSE.

  • Property svn:eol-style set to native
File size: 8.5 KB
Line 
1/** @file
2 This file includes the definitions for open and fcntl described by POSIX
3 for <fcntl.h>; it also includes related kernel definitions.
4
5 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made
7 available under the terms and conditions of the BSD License which
8 accompanies this distribution. The full text of the license may be found
9 at http://opensource.org/licenses/bsd-license.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 Copyright (c) 1983, 1990, 1993
15 The Regents of the University of California. All rights reserved.
16 (c) UNIX System Laboratories, Inc.
17 All or some portions of this file are derived from material licensed
18 to the University of California by American Telephone and Telegraph
19 Co. or Unix System Laboratories, Inc. and are reproduced herein with
20 the permission of UNIX System Laboratories, Inc.
21
22 Redistribution and use in source and binary forms, with or without
23 modification, are permitted provided that the following conditions
24 are met:
25 1. Redistributions of source code must retain the above copyright
26 notice, this list of conditions and the following disclaimer.
27 2. Redistributions in binary form must reproduce the above copyright
28 notice, this list of conditions and the following disclaimer in the
29 documentation and/or other materials provided with the distribution.
30 3. Neither the name of the University nor the names of its contributors
31 may be used to endorse or promote products derived from this software
32 without specific prior written permission.
33
34 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
35 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
38 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 SUCH DAMAGE.
45
46 fcntl.h 8.3 (Berkeley) 1/21/94
47 NetBSD: fcntl.h,v 1.34 2006/10/05 14:48:33 chs Exp
48 */
49#ifndef _SYS_FCNTL_H_
50#define _SYS_FCNTL_H_
51
52#include <sys/featuretest.h>
53#include <sys/types.h>
54
55#include <sys/stat.h>
56
57/** @{
58 File status flags used by open(2), fcntl(2).
59 They are also used (indirectly) in the kernel file structure f_flags,
60 which is a superset of the open/fcntl flags.
61 Open/fcntl flags begin with O_; kernel-internal flags begin with F.
62**/
63/* open-only flags */
64#define O_RDONLY 0x00000000 ///< open for reading only
65#define O_WRONLY 0x00000001 ///< open for writing only
66#define O_RDWR 0x00000002 ///< open for reading and writing
67#define O_ACCMODE 0x00000003 ///< mask for above modes
68
69#define O_NONBLOCK 0x00000004 ///< no delay
70#define O_APPEND 0x00000008 ///< set append mode
71#define O_CREAT 0x00000200 ///< create if nonexistent
72#define O_TRUNC 0x00000400 ///< truncate to zero length
73#define O_EXCL 0x00000800 ///< error if already exists
74
75/* UEFI-specific open-only flags. */
76#define O_HIDDEN 0x00010000 ///< Hidden file attribute
77#define O_SYSTEM 0x00020000 ///< System file attribute
78#define O_ARCHIVE 0x00040000 ///< Archive file attribute
79/// @}
80
81//#define O_DIRECT 0x00080000 /* direct I/O hint */
82
83#define O_SETMASK 0x0000000F ///< Flags modifiable by F_SETFD (fcntl)
84
85/*
86 * Constants used for fcntl(2)
87 */
88
89/** @{ command values used for fcntl(2). **/
90#define F_DUPFD 0 ///< duplicate file descriptor
91#define F_GETFD 1 ///< get file descriptor flags
92#define F_SETFD 2 ///< set file descriptor flags
93#define F_GETFL 3 ///< get file status flags
94#define F_SETFL 4 ///< set file status flags
95#define F_GETOWN 5 ///< get SIGIO/SIGURG proc/pgrp
96#define F_SETOWN 6 ///< set SIGIO/SIGURG proc/pgrp
97#define F_GETLK 7 ///< get record locking information
98#define F_SETLK 8 ///< set record locking information
99#define F_SETLKW 9 ///< F_SETLK; wait if blocked
100#define F_CLOSEM 10 ///< close all fds >= to the one given
101#define F_MAXFD 11 ///< return the max open fd
102/// @}
103
104/** file descriptor flags (F_GETFD, F_SETFD). **/
105#define FD_CLOEXEC 1 ///< close-on-exec flag
106
107/** @{ record locking flags (F_GETLK, F_SETLK, F_SETLKW). **/
108#define F_RDLCK 1 ///< shared or read lock
109#define F_UNLCK 2 ///< unlock
110#define F_WRLCK 3 ///< exclusive or write lock
111/// @}
112
113/** @{ Constants for fcntl's passed to the underlying fs - like ioctl's. **/
114#define F_PARAM_MASK 0xfff
115#define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK)
116#define F_PARAM_MAX 4095
117#define F_FSCTL (int)0x80000000 ///< This fcntl goes to the fs
118#define F_FSVOID (int)0x40000000 ///< no parameters
119#define F_FSOUT (int)0x20000000 ///< copy out parameter
120#define F_FSIN (int)0x10000000 ///< copy in parameter
121#define F_FSINOUT (F_FSIN | F_FSOUT)
122#define F_FSDIRMASK (int)0x70000000 ///< mask for IN/OUT/VOID
123#define F_FSPRIV (int)0x00008000 ///< command is fs-specific
124/// @}
125
126/* Always ensure that these are consistent with <stdio.h> and <unistd.h>! */
127#ifndef SEEK_SET
128 #define SEEK_SET 0 /* set file offset to offset */
129#endif
130#ifndef SEEK_CUR
131 #define SEEK_CUR 1 /* set file offset to current plus offset */
132#endif
133#ifndef SEEK_END
134 #define SEEK_END 2 /* set file offset to EOF plus offset */
135#endif
136
137#include <sys/EfiCdefs.h>
138
139__BEGIN_DECLS
140#ifndef __FCNTL_SYSCALLS_DECLARED
141 #define __FCNTL_SYSCALLS_DECLARED
142
143 /** The open() function establishes the connection between a file and a file
144 descriptor. It creates an open file description that refers to a file
145 and a file descriptor that refers to that open file description. The file
146 descriptor is used by other I/O functions to refer to that file.
147
148 The open() function returns a file descriptor for the named file that is
149 the lowest file descriptor not currently open for that process. The open
150 file description is new, and therefore the file descriptor shall not
151 share it with any other process in the system.
152
153 The file offset used to mark the current position within the file is set
154 to the beginning of the file.
155
156 The file status flags and file access modes of the open file description
157 are set according to the value of oflags.
158
159 Values for oflags are constructed by a bitwise-inclusive OR of flags from
160 the following list, defined in <fcntl.h>. Applications shall specify
161 exactly one of { O_RDONLY, O_RDWR, O_WRONLY } in the value of oflags.
162 Any combination of { O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC, O_EXCL } may
163 also be specified in oflags.
164
165 Values for mode specify the access permissions for newly created files.
166
167 @param[in] Path The path argument points to a pathname naming the
168 object to be opened.
169 @param[in] oflags File status flags and file access modes of the
170 open file description.
171 @param[in] mode File access permission bits as defined in
172 <sys/stat.h>.
173
174 @return Upon successful completion, open() opens the file and returns
175 a non-negative integer representing the lowest numbered
176 unused file descriptor. Otherwise, open returns -1 and sets
177 errno to indicate the error. If a negative value is
178 returned, no files are created or modified.
179
180 @retval EMFILE No file descriptors available -- Max number already open.
181 @retval EINVAL Bad value specified for oflags or mode.
182 @retval ENOMEM Failure allocating memory for internal buffers.
183 @retval EEXIST File exists and open attempted with (O_EXCL | O_CREAT) set.
184 @retval EIO UEFI failure. Check value in EFIerrno.
185 **/
186 int open(const char *Path, int oflags, int mode);
187
188 /**
189 **/
190 int creat(const char *, mode_t);
191
192 /**
193 **/
194 int fcntl(int, int, ...);
195#endif // __FCNTL_SYSCALLS_DECLARED
196__END_DECLS
197
198#endif /* !_SYS_FCNTL_H_ */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette