-/** @file\r
- This file includes the definitions for open and fcntl described by POSIX\r
- for <fcntl.h>; it also includes related kernel definitions.\r
-\r
- Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials are licensed and made\r
- available under the terms and conditions of the BSD License which\r
- accompanies this distribution. The full text of the license may be found\r
- at http://opensource.org/licenses/bsd-license.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- Copyright (c) 1983, 1990, 1993\r
- The Regents of the University of California. All rights reserved.\r
- (c) UNIX System Laboratories, Inc.\r
- All or some portions of this file are derived from material licensed\r
- to the University of California by American Telephone and Telegraph\r
- Co. or Unix System Laboratories, Inc. and are reproduced herein with\r
- the permission of UNIX System Laboratories, Inc.\r
-\r
- Redistribution and use in source and binary forms, with or without\r
- modification, are permitted provided that the following conditions\r
- are met:\r
- 1. Redistributions of source code must retain the above copyright\r
- notice, this list of conditions and the following disclaimer.\r
- 2. Redistributions in binary form must reproduce the above copyright\r
- notice, this list of conditions and the following disclaimer in the\r
- documentation and/or other materials provided with the distribution.\r
- 3. Neither the name of the University nor the names of its contributors\r
- may be used to endorse or promote products derived from this software\r
- without specific prior written permission.\r
-\r
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
- SUCH DAMAGE.\r
-\r
- fcntl.h 8.3 (Berkeley) 1/21/94\r
- NetBSD: fcntl.h,v 1.34 2006/10/05 14:48:33 chs Exp\r
- */\r
-#ifndef _SYS_FCNTL_H_\r
-#define _SYS_FCNTL_H_\r
-\r
-#include <sys/featuretest.h>\r
-#include <sys/types.h>\r
-\r
-#include <sys/stat.h>\r
-\r
-/** @{\r
- File status flags used by open(2), fcntl(2).\r
- They are also used (indirectly) in the kernel file structure f_flags,\r
- which is a superset of the open/fcntl flags.\r
- Open/fcntl flags begin with O_; kernel-internal flags begin with F.\r
-**/\r
-/* open-only flags */\r
-#define O_RDONLY 0x00000000 ///< open for reading only\r
-#define O_WRONLY 0x00000001 ///< open for writing only\r
-#define O_RDWR 0x00000002 ///< open for reading and writing\r
-#define O_ACCMODE 0x00000003 ///< mask for above modes\r
-\r
-#define O_NONBLOCK 0x00000004 ///< no delay\r
-#define O_APPEND 0x00000008 ///< set append mode\r
-#define O_CREAT 0x00000200 ///< create if nonexistent\r
-#define O_TRUNC 0x00000400 ///< truncate to zero length\r
-#define O_EXCL 0x00000800 ///< Grant EXCLusive access, or error if already exists and O_CREAT\r
-\r
-#define O_DIRECTORY 0x00001000 ///< error if path is not a directory\r
-#define O_NOCTTY 0x00002000 ///< Don't make this the controlling TTY\r
-#define O_TTY_INIT 0x00004000 ///< Initialize TTY to "sane" values on open\r
-\r
-/* UEFI-specific open-only flags. */\r
-#define O_HIDDEN 0x00010000 ///< Hidden file attribute\r
-#define O_SYSTEM 0x00020000 ///< System file attribute\r
-#define O_ARCHIVE 0x00040000 ///< Archive file attribute\r
-/// @}\r
-\r
-#define O_SETMASK 0x0000000F ///< Flags modifiable by F_SETFD (fcntl)\r
-\r
-/*\r
- * Constants used for fcntl(2)\r
- */\r
-\r
-/** @{ command values used for fcntl(2). **/\r
-#define F_DUPFD 0 ///< duplicate file descriptor\r
-#define F_GETFD 1 ///< get file descriptor flags\r
-#define F_SETFD 2 ///< set file descriptor flags\r
-#define F_GETFL 3 ///< get file status flags\r
-#define F_SETFL 4 ///< set file status flags\r
-#define F_GETOWN 5 ///< get SIGIO/SIGURG proc/pgrp\r
-#define F_SETOWN 6 ///< set SIGIO/SIGURG proc/pgrp\r
-#define F_GETLK 7 ///< get record locking information\r
-#define F_SETLK 8 ///< set record locking information\r
-#define F_SETLKW 9 ///< F_SETLK; wait if blocked\r
-#define F_CLOSEM 10 ///< close all fds >= to the one given\r
-#define F_MAXFD 11 ///< return the max open fd\r
-/// @}\r
-\r
-/** file descriptor flags (F_GETFD, F_SETFD). **/\r
-#define FD_CLOEXEC 1 ///< close-on-exec flag\r
-\r
-/** @{ record locking flags (F_GETLK, F_SETLK, F_SETLKW). **/\r
-#define F_RDLCK 1 ///< shared or read lock\r
-#define F_UNLCK 2 ///< unlock\r
-#define F_WRLCK 3 ///< exclusive or write lock\r
-/// @}\r
-\r
-/** @{ Constants for fcntl's passed to the underlying fs - like ioctl's. **/\r
-#define F_PARAM_MASK 0xfff\r
-#define F_PARAM_LEN(x) (((x) >> 16) & F_PARAM_MASK)\r
-#define F_PARAM_MAX 4095\r
-#define F_FSCTL (int)0x80000000 ///< This fcntl goes to the fs\r
-#define F_FSVOID (int)0x40000000 ///< no parameters\r
-#define F_FSOUT (int)0x20000000 ///< copy out parameter\r
-#define F_FSIN (int)0x10000000 ///< copy in parameter\r
-#define F_FSINOUT (F_FSIN | F_FSOUT)\r
-#define F_FSDIRMASK (int)0x70000000 ///< mask for IN/OUT/VOID\r
-#define F_FSPRIV (int)0x00008000 ///< command is fs-specific\r
-/// @}\r
-\r
-/* Always ensure that these are consistent with <stdio.h> and <unistd.h>! */\r
-#ifndef SEEK_SET\r
- #define SEEK_SET 0 /* set file offset to offset */\r
-#endif\r
-#ifndef SEEK_CUR\r
- #define SEEK_CUR 1 /* set file offset to current plus offset */\r
-#endif\r
-#ifndef SEEK_END\r
- #define SEEK_END 2 /* set file offset to EOF plus offset */\r
-#endif\r
-\r
-#include <sys/EfiCdefs.h>\r
-\r
-__BEGIN_DECLS\r
-#ifndef __FCNTL_SYSCALLS_DECLARED\r
- #define __FCNTL_SYSCALLS_DECLARED\r
-\r
- /** The open() function establishes the connection between a file and a file\r
- descriptor. It creates an open file description that refers to a file\r
- and a file descriptor that refers to that open file description. The file\r
- descriptor is used by other I/O functions to refer to that file.\r
-\r
- The open() function returns a file descriptor for the named file that is\r
- the lowest file descriptor not currently open for that process. The open\r
- file description is new, and therefore the file descriptor shall not\r
- share it with any other process in the system.\r
-\r
- The file offset used to mark the current position within the file is set\r
- to the beginning of the file.\r
-\r
- The file status flags and file access modes of the open file description\r
- are set according to the value of oflags.\r
-\r
- Values for oflags are constructed by a bitwise-inclusive OR of flags from\r
- the following list, defined in <fcntl.h>. Applications shall specify\r
- exactly one of { O_RDONLY, O_RDWR, O_WRONLY } in the value of oflags.\r
- Any combination of { O_NONBLOCK, O_APPEND, O_CREAT, O_TRUNC, O_EXCL } may\r
- also be specified in oflags.\r
-\r
- Values for mode specify the access permissions for newly created files.\r
-\r
- @param[in] Path The path argument points to a pathname naming the\r
- object to be opened.\r
- @param[in] oflags File status flags and file access modes of the\r
- open file description.\r
- @param[in] mode File access permission bits as defined in\r
- <sys/stat.h>.\r
-\r
- @return Upon successful completion, open() opens the file and returns\r
- a non-negative integer representing the lowest numbered\r
- unused file descriptor. Otherwise, open returns -1 and sets\r
- errno to indicate the error. If a negative value is\r
- returned, no files are created or modified.\r
-\r
- @retval EMFILE No file descriptors available -- Max number already open.\r
- @retval EINVAL Bad value specified for oflags or mode.\r
- @retval ENOMEM Failure allocating memory for internal buffers.\r
- @retval EEXIST File exists and open attempted with (O_EXCL | O_CREAT) set.\r
- @retval EIO UEFI failure. Check value in EFIerrno.\r
- **/\r
- int open(const char *Path, int oflags, int mode);\r
-\r
- /**\r
- **/\r
- int creat(const char *, mode_t);\r
-\r
- /**\r
- **/\r
- int fcntl(int, int, ...);\r
-#endif // __FCNTL_SYSCALLS_DECLARED\r
-__END_DECLS\r
-\r
-#endif /* !_SYS_FCNTL_H_ */\r