Relicense Sortix to the ISC license.
I hereby relicense all my work on Sortix under the ISC license as below.
All Sortix contributions by other people are already under this license,
are not substantial enough to be copyrightable, or have been removed.
All imported code from other projects is compatible with this license.
All GPL licensed code from other projects had previously been removed.
Copyright 2011-2016 Jonas 'Sortie' Termansen and contributors.
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2016-03-02 17:38:16 -05:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012, 2013, 2014 Jonas 'Sortie' Termansen.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* sortix/fcntl.h
|
|
|
|
* Declares various constants related to opening files.
|
|
|
|
*/
|
2012-02-23 07:15:40 -05:00
|
|
|
|
2013-03-31 11:18:42 -04:00
|
|
|
#ifndef INCLUDE_SORTIX_FCNTL_H
|
|
|
|
#define INCLUDE_SORTIX_FCNTL_H
|
2012-02-23 07:15:40 -05:00
|
|
|
|
2013-10-13 07:04:27 -04:00
|
|
|
#include <sys/cdefs.h>
|
2012-02-23 07:15:40 -05:00
|
|
|
|
2015-05-13 12:11:02 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2012-02-23 07:15:40 -05:00
|
|
|
|
2014-07-07 11:31:50 -04:00
|
|
|
/* Remember to update the flag classifications at the top of descriptor.cpp if
|
|
|
|
you add new flags here. */
|
2013-03-21 10:26:08 -04:00
|
|
|
#define O_READ (1<<0)
|
|
|
|
#define O_WRITE (1<<1)
|
|
|
|
#define O_EXEC (1<<2)
|
2012-02-23 07:15:40 -05:00
|
|
|
#define O_APPEND (1<<3)
|
|
|
|
#define O_CLOEXEC (1<<4)
|
2013-09-27 08:44:52 -04:00
|
|
|
#define O_CREATE (1<<5)
|
2012-02-23 07:15:40 -05:00
|
|
|
#define O_DIRECTORY (1<<6)
|
|
|
|
#define O_EXCL (1<<7)
|
|
|
|
#define O_TRUNC (1<<8)
|
2012-03-04 15:06:49 -05:00
|
|
|
#define O_CLOFORK (1<<9)
|
2013-03-21 10:26:08 -04:00
|
|
|
#define O_SEARCH (1<<10)
|
2013-03-31 11:18:42 -04:00
|
|
|
#define O_NONBLOCK (1<<11)
|
2013-10-17 07:05:29 -04:00
|
|
|
#define O_NOFOLLOW (1<<12)
|
2013-11-16 07:21:33 -05:00
|
|
|
#define O_SYMLINK_NOFOLLOW (1<<13)
|
2014-01-22 19:54:58 -05:00
|
|
|
#define O_NOCTTY (1<<14)
|
2014-01-22 19:56:01 -05:00
|
|
|
#define O_TTY_INIT (1<<15)
|
2012-03-04 15:06:49 -05:00
|
|
|
|
2014-02-15 08:04:07 -05:00
|
|
|
#define O_ACCMODE (O_READ | O_WRITE | O_EXEC | O_SEARCH)
|
|
|
|
|
2012-03-04 15:06:49 -05:00
|
|
|
#define FD_CLOEXEC (1<<0)
|
|
|
|
#define FD_CLOFORK (1<<1)
|
2012-02-23 07:15:40 -05:00
|
|
|
|
2012-08-07 18:19:44 -04:00
|
|
|
#define __FD_ALLOWED_FLAGS (FD_CLOEXEC | FD_CLOFORK)
|
|
|
|
|
2013-09-24 06:39:48 -04:00
|
|
|
/* Encode type information about arguments into fcntl commands. Unfortunately
|
|
|
|
the fcntl function declaration doesn't include type information, which means
|
|
|
|
that the fcntl implementation either needs a list of command type information
|
|
|
|
to use va_list correctly - or we can simply embed the information into the
|
|
|
|
commands. */
|
|
|
|
#define F_TYPE_EXP 3 /* 2^3 kinds of argument types supported.*/
|
|
|
|
#define F_TYPE_VOID 0
|
|
|
|
#define F_TYPE_INT 1
|
|
|
|
#define F_TYPE_LONG 2
|
|
|
|
#define F_TYPE_PTR 3
|
|
|
|
/* 5-7 is unused in case of future expansion. */
|
|
|
|
#define F_ENCODE_CMD(cmd_val, arg_type) ((cmd_val) << F_TYPE_EXP | (arg_type))
|
|
|
|
#define F_DECODE_CMD_RAW(cmd) (cmd >> F_TYPE_EXP)
|
|
|
|
#define F_DECODE_CMD_TYPE(cmd) ((cmd) & ((1 << F_TYPE_EXP)-1))
|
|
|
|
|
|
|
|
/* Encode small parameters into fcntl commands. This allows adding some flags
|
|
|
|
and other modifiers to fcntl commands without declaring a heap of new fcntl
|
|
|
|
commands variants. */
|
|
|
|
#define F_ENCODE(cmd, small_param) (((cmd) & 0xFFFF) | ((small_param) << 16))
|
|
|
|
#define F_DECODE_CMD(val) (val & 0xFFFF)
|
|
|
|
#define F_DECODE_FLAGS(val) ((val & ~0xFFFF) >> 16)
|
|
|
|
|
|
|
|
/* Set file descriptor status. */
|
|
|
|
#define F_SETFD_NUM 0
|
|
|
|
#define F_SETFD F_ENCODE_CMD(F_SETFD_NUM, F_TYPE_INT)
|
|
|
|
|
|
|
|
/* Get file descriptor status. */
|
|
|
|
#define F_GETFD_NUM 1
|
|
|
|
#define F_GETFD F_ENCODE_CMD(F_GETFD_NUM, F_TYPE_VOID)
|
|
|
|
|
|
|
|
/* Set descriptor table entry flags. */
|
|
|
|
#define F_SETFL_NUM 3
|
|
|
|
#define F_SETFL F_ENCODE_CMD(F_SETFL_NUM, F_TYPE_INT)
|
|
|
|
|
|
|
|
/* Get descriptor table entry flags. */
|
|
|
|
#define F_GETFL_NUM 3
|
|
|
|
#define F_GETFL F_ENCODE_CMD(F_GETFL_NUM, F_TYPE_VOID)
|
2012-03-04 15:36:40 -05:00
|
|
|
|
2013-09-24 07:35:05 -04:00
|
|
|
/* Duplicates the file descriptor with at least the given index. */
|
|
|
|
#define F_DUPFD_NUM 4
|
|
|
|
#define F_DUPFD F_ENCODE_CMD(F_ENCODE(F_DUPFD_NUM, 0), F_TYPE_INT)
|
|
|
|
#define F_DUPFD_CLOEXEC F_ENCODE_CMD(F_ENCODE(F_DUPFD_NUM, FD_CLOEXEC), F_TYPE_INT)
|
|
|
|
#define F_DUPFD_CLOFORK F_ENCODE_CMD(F_ENCODE(F_DUPFD_NUM, FD_CLOFORK), F_TYPE_INT)
|
|
|
|
|
2014-08-09 06:29:35 -04:00
|
|
|
/* Find the previous file descriptor. */
|
|
|
|
#define F_PREVFD_NUM 5
|
|
|
|
#define F_PREVFD F_ENCODE_CMD(F_PREVFD_NUM, F_TYPE_VOID)
|
|
|
|
|
|
|
|
/* Find the next file descriptor. */
|
|
|
|
#define F_NEXTFD_NUM 6
|
|
|
|
#define F_NEXTFD F_ENCODE_CMD(F_NEXTFD_NUM, F_TYPE_VOID)
|
|
|
|
|
2012-08-07 18:19:44 -04:00
|
|
|
#define AT_FDCWD (-100)
|
2012-10-23 07:50:33 -04:00
|
|
|
#define AT_REMOVEDIR (1<<0)
|
2012-10-23 17:55:33 -04:00
|
|
|
#define AT_EACCESS (1<<1)
|
|
|
|
#define AT_SYMLINK_NOFOLLOW (1<<2)
|
2013-01-06 13:14:30 -05:00
|
|
|
#define AT_REMOVEFILE (1<<3)
|
2013-03-31 11:06:06 -04:00
|
|
|
#define AT_SYMLINK_FOLLOW (1<<4)
|
2012-08-07 18:19:44 -04:00
|
|
|
|
2015-05-13 12:11:02 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
2012-02-23 07:15:40 -05:00
|
|
|
|
|
|
|
#endif
|