source: mainline/uspace/lib/posix/unistd.h@ 6d100fd

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 6d100fd was 75406dc, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Additional wrappers and fixes for VFS functions.

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Zarevucky
3 * Copyright (c) 2011 Petr Koupy
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libposix
31 * @{
32 */
33/** @file Miscellaneous standard definitions.
34 */
35
36#ifndef POSIX_UNISTD_H_
37#define POSIX_UNISTD_H_
38
39#include "libc/unistd.h"
40#include "sys/types.h"
41
42/* Process Termination */
43#define _exit exit
44
45/* Option Arguments */
46extern char *optarg;
47extern int optind, opterr, optopt;
48extern int getopt(int, char * const [], const char *);
49
50/* Environment */
51extern char **posix_environ;
52
53/* Login Information */
54extern char *posix_getlogin(void);
55extern int posix_getlogin_r(char *name, size_t namesize);
56
57/* Identifying Terminals */
58extern int posix_isatty(int fd);
59
60/* Working Directory */
61extern char *posix_getcwd(char *buf, size_t size);
62extern int posix_chdir(const char *path);
63
64/* Query Memory Parameters */
65extern int posix_getpagesize(void);
66
67/* Process Identification */
68extern posix_pid_t posix_getpid(void);
69extern posix_uid_t posix_getuid(void);
70extern posix_gid_t posix_getgid(void);
71
72/* File Manipulation */
73extern int posix_close(int fildes);
74
75extern ssize_t posix_read(int fildes, void *buf, size_t nbyte);
76extern ssize_t posix_write(int fildes, const void *buf, size_t nbyte);
77
78extern int posix_fsync(int fildes);
79extern int posix_ftruncate(int fildes, posix_off_t length);
80
81extern int posix_rmdir(const char *path);
82extern int posix_unlink(const char *path);
83
84extern int posix_dup(int fildes);
85extern int posix_dup2(int fildes, int fildes2);
86
87/* Standard Streams */
88#undef STDIN_FILENO
89#define STDIN_FILENO (fileno(stdin))
90#undef STDOUT_FILENO
91#define STDOUT_FILENO (fileno(stdout))
92#undef STDERR_FILENO
93#define STDERR_FILENO (fileno(stderr))
94
95/* File Accessibility */
96#undef F_OK
97#undef X_OK
98#undef W_OK
99#undef R_OK
100#define F_OK 0 /* Test for existence. */
101#define X_OK 1 /* Test for execute permission. */
102#define W_OK 2 /* Test for write permission. */
103#define R_OK 4 /* Test for read permission. */
104extern int posix_access(const char *path, int amode);
105
106/* System Parameters */
107enum {
108 _SC_PHYS_PAGES,
109 _SC_AVPHYS_PAGES,
110 _SC_PAGESIZE,
111 _SC_CLK_TCK
112};
113extern long posix_sysconf(int name);
114
115/* Path Configuration Parameters */
116enum {
117 _PC_2_SYMLINKS,
118 _PC_ALLOC_SIZE_MIN,
119 _PC_ASYNC_IO,
120 _PC_CHOWN_RESTRICTED,
121 _PC_FILESIZEBITS,
122 _PC_LINK_MAX,
123 _PC_MAX_CANON,
124 _PC_MAX_INPUT,
125 _PC_NAME_MAX,
126 _PC_NO_TRUNC,
127 _PC_PATH_MAX,
128 _PC_PIPE_BUF,
129 _PC_PRIO_IO,
130 _PC_REC_INCR_XFER_SIZE,
131 _PC_REC_MIN_XFER_SIZE,
132 _PC_REC_XFER_ALIGN,
133 _PC_SYMLINK_MAX,
134 _PC_SYNC_IO,
135 _PC_VDISABLE
136};
137extern long posix_pathconf(const char *path, int name);
138
139/* Creating a Process */
140extern posix_pid_t posix_fork(void);
141
142/* Executing a File */
143extern int posix_execv(const char *path, char *const argv[]);
144extern int posix_execvp(const char *file, char *const argv[]);
145
146/* Creating a Pipe */
147extern int posix_pipe(int fildes[2]);
148
149#ifndef LIBPOSIX_INTERNAL
150 #define environ posix_environ
151
152 #define getlogin posix_getlogin
153 #define getlogin_r posix_getlogin_r
154
155 #define getcwd posix_getcwd
156 #define chdir posix_chdir
157
158 #define isatty posix_isatty
159
160 #undef getpagesize
161 #define getpagesize posix_getpagesize
162
163 #define getpid posix_getpid
164 #define getuid posix_getuid
165 #define getgid posix_getgid
166
167 #define close posix_close
168 #define read posix_read
169 #define write posix_write
170 #define fsync posix_fsync
171 #define ftruncate posix_ftruncate
172 #define rmdir posix_rmdir
173 #define unlink posix_unlink
174 #define dup posix_dup
175 #define dup2 posix_dup2
176
177 #define access posix_access
178
179 #define sysconf posix_sysconf
180
181 #define pathconf posix_pathconf
182
183 #define fork posix_fork
184
185 #define execv posix_execv
186 #define execvp posix_execvp
187
188 #define pipe posix_pipe
189#endif
190
191#endif /* POSIX_UNISTD_H_ */
192
193/** @}
194 */
Note: See TracBrowser for help on using the repository browser.