Tizen RT Libs&Environment
v1.0 D5
Main Page
Modules
Data Structures
Files
File List
Globals
fcntl.h
Go to the documentation of this file.
1
/****************************************************************************
2
*
3
* Copyright 2016 Samsung Electronics All Rights Reserved.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing,
12
* software distributed under the License is distributed on an
13
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14
* either express or implied. See the License for the specific
15
* language governing permissions and limitations under the License.
16
*
17
****************************************************************************/
18
/********************************************************************************
19
* include/fcntl.h
20
*
21
* Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved.
22
* Author: Gregory Nutt <gnutt@nuttx.org>
23
*
24
* Redistribution and use in source and binary forms, with or without
25
* modification, are permitted provided that the following conditions
26
* are met:
27
*
28
* 1. Redistributions of source code must retain the above copyright
29
* notice, this list of conditions and the following disclaimer.
30
* 2. Redistributions in binary form must reproduce the above copyright
31
* notice, this list of conditions and the following disclaimer in
32
* the documentation and/or other materials provided with the
33
* distribution.
34
* 3. Neither the name NuttX nor the names of its contributors may be
35
* used to endorse or promote products derived from this software
36
* without specific prior written permission.
37
*
38
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49
* POSSIBILITY OF SUCH DAMAGE.
50
*
51
********************************************************************************/
60
63
#ifndef __INCLUDE_FCNTL_H
64
#define __INCLUDE_FCNTL_H
65
66
/********************************************************************************
67
* Included Files
68
********************************************************************************/
69
70
#include <tinyara/config.h>
71
72
#include <sys/types.h>
73
#include <stdint.h>
74
75
/********************************************************************************
76
* Pre-processor Definitions
77
********************************************************************************/
78
79
/* open flag settings for open() (and related APIs) */
80
81
#define O_RDONLY (1 << 0)
/* Open for read access (only) */
82
#define O_RDOK O_RDONLY
/* Read access is permitted (non-standard) */
83
#define O_WRONLY (1 << 1)
/* Open for write access (only) */
84
#define O_WROK O_WRONLY
/* Write access is permitted (non-standard) */
85
#define O_RDWR (O_RDOK|O_WROK)
/* Open for both read & write access */
86
#define O_CREAT (1 << 2)
/* Create file/sem/mq object */
87
#define O_EXCL (1 << 3)
/* Name must not exist when opened */
88
#define O_APPEND (1 << 4)
/* Keep contents, append to end */
89
#define O_TRUNC (1 << 5)
/* Delete contents */
90
#define O_NONBLOCK (1 << 6)
/* Don't wait for data */
91
#define O_NDELAY O_NONBLOCK
/* Synonym for O_NONBLOCK */
92
#define O_SYNC (1 << 7)
/* Synchronize output on write */
93
#define O_DSYNC O_SYNC
/* Equivalent to OSYNC in TinyAra */
94
#define O_BINARY (1 << 8)
/* Open the file in binary (untranslated) mode. */
95
96
/* Unsupported, but required open flags */
97
98
#define O_RSYNC 0
/* Synchronize input on read */
99
#define O_ACCMODE O_RDWR
/* Mask for access mode */
100
#define O_NOCTTY 0
/* Required by POSIX */
101
#define O_TEXT 0
/* Open the file in text (translated) mode. */
102
103
/* This is the highest bit number used in the open flags bitset. Bits above
104
* this bit number may be used within TinyAra for other, internal purposes.
105
*/
106
107
#define _O_MAXBIT 8
108
109
/* Synonyms historically used as F_SETFL flags (BSD). */
110
111
#define FNDELAY O_NONBLOCK
/* Don't wait for data */
112
#define FNONBLOCK O_NONBLOCK
/* Don't wait for data */
113
#define FAPPEND O_APPEND
/* Keep contents, append to end */
114
#define FSYNC O_SYNC
/* Synchronize output on write */
115
#define FASYNC 0
/* No counterpart in TinyAra */
116
117
/* FFCNTL is all the bits that may be set via fcntl. */
118
119
#define FFCNTL (FNONBLOCK | FNDELAY | FAPPEND | FSYNC | FASYNC)
120
121
/* fcntl() commands */
122
123
#define F_DUPFD 0
/* Duplicate a file descriptor */
124
#define F_GETFD 1
/* Read the file descriptor flags */
125
#define F_GETFL 2
/* Read the file status flags */
126
#define F_GETLEASE 3
/* Indicates what type of lease is held on fd (linux) */
127
#define F_GETLK 4
/* Check if we could place a lock */
128
#define F_GETOWN 5
/* Get the pid receiving SIGIO and SIGURG signals for fd */
129
#define F_GETSIG 6
/* Get the signal sent */
130
#define F_NOTIFY 7
/* Provide notification when directory referred to by fd changes (linux) */
131
#define F_SETFD 8
/* Set the file descriptor flags to value */
132
#define F_SETFL 9
/* Set the file status flags to the value */
133
#define F_SETLEASE 10
/* Set or remove file lease (linux) */
134
#define F_SETLK 11
/* Acquire or release a lock on range of bytes */
135
#define F_SETLKW 12
/* Like F_SETLK, but wait for lock to become available */
136
#define F_SETOWN 13
/* Set pid that will receive SIGIO and SIGURG signals for fd */
137
#define F_SETSIG 14
/* Set the signal to be sent */
138
139
/* For posix fcntl() and lockf() */
140
141
#define F_RDLCK 0
/* Take out a read lease */
142
#define F_WRLCK 1
/* Take out a write lease */
143
#define F_UNLCK 2
/* Remove a lease */
144
145
/* close-on-exec flag for F_GETRL and F_SETFL */
146
147
#define FD_CLOEXEC 1
148
149
/* These are the notifications that can be received from F_NOTIFY (linux) */
150
151
#define DN_ACCESS 0
/* A file was accessed */
152
#define DN_MODIFY 1
/* A file was modified */
153
#define DN_CREATE 2
/* A file was created */
154
#define DN_DELETE 3
/* A file was unlinked */
155
#define DN_RENAME 4
/* A file was renamed */
156
#define DN_ATTRIB 5
/* Attributes of a file were changed */
157
158
/* int creat(const char *path, mode_t mode);
159
*
160
* is equivalent to open with O_WRONLY|O_CREAT|O_TRUNC.
161
*/
162
163
#define creat(path, mode) open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
164
165
/********************************************************************************
166
* Public Type Definitions
167
********************************************************************************/
168
169
/* struct flock is the third argument for F_GETLK, F_SETLK and F_SETLKW */
170
171
struct
flock
{
172
int16_t
l_type
;
/* Type of lock: F_RDLCK, F_WRLCK, F_UNLCK */
173
int16_t
l_whence
;
/* How to interpret l_start: SEEK_SET, SEEK_CUR, SEEK_END */
174
off_t
l_start
;
/* Starting offset for lock */
175
off_t
l_len
;
/* Number of bytes to lock */
176
pid_t
l_pid
;
/* PID of process blocking our lock (F_GETLK only) */
177
};
178
179
/********************************************************************************
180
* Public Function Prototypes
181
********************************************************************************/
182
183
#undef EXTERN
184
#if defined(__cplusplus)
185
#define EXTERN extern "C"
186
extern
"C"
{
187
#else
188
#define EXTERN extern
189
#endif
190
191
/********************************************************************************
192
* Public Data
193
********************************************************************************/
194
195
/* POSIX-like File System Interfaces */
202
int
open
(
const
char
*path,
int
oflag, ...);
209
int
fcntl
(
int
fd,
int
cmd, ...);
210
211
#undef EXTERN
212
#if defined(__cplusplus)
213
}
214
#endif
215
216
#endif
/* __INCLUDE_FCNTL_H */
217
fcntl
int fcntl(int fd, int cmd,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
flock::l_type
int16_t l_type
Definition:
fcntl.h:172
flock::l_start
off_t l_start
Definition:
fcntl.h:174
flock::l_len
off_t l_len
Definition:
fcntl.h:175
flock::l_whence
int16_t l_whence
Definition:
fcntl.h:173
flock::l_pid
pid_t l_pid
Definition:
fcntl.h:176
open
int open(const char *path, int oflag,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
flock
Definition:
fcntl.h:171
os
include
fcntl.h
Generated by
1.8.11