blob: b2fd92358a401d745e28a4b59ede33088ef08a8a [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2
3 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials are licensed and made available under
5 the terms and conditions of the BSD License that accompanies this distribution.
6 The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12**/
13#ifndef _UNISTD_H_
14#define _UNISTD_H_
15
16//#include <machine/ansi.h>
17//#include <machine/int_types.h>
18//#include <sys/featuretest.h>
19//#include <sys/types.h>
20#include <sys/unistd.h>
21#include <sys/EfiSysCall.h>
22
23#define F_ULOCK 0
24#define F_LOCK 1
25#define F_TLOCK 2
26#define F_TEST 3
27
28/* access function */
29#define F_OK 0 /* test for existence of file */
30#define X_OK 0x01 /* test for execute or search permission */
31#define W_OK 0x02 /* test for write permission */
32#define R_OK 0x04 /* test for read permission */
33
34
35__BEGIN_DECLS
36int dup(int);
37int rename(const char *, const char *);
38
39/* Functions implemented for compatibility. */
40int getopt(int, char * const [], const char *);
41extern char *optarg; /* getopt(3) external variables */
42extern int optind;
43pid_t getpgrp(void);
44pid_t tcgetpgrp(int);
45char *getpass(const char *);
46int usleep(useconds_t);
47unsigned int sleep(unsigned int);
48char *basename(char *path);
49
50#ifndef GETCWD_DECLARED
51 /** Gets the current working directory.
52
53 The getcwd() function shall place an absolute pathname of the current
54 working directory in the array pointed to by buf, and return buf. The
55 pathname copied to the array shall contain no components that are
56 symbolic links. The size argument is the size in bytes of the character
57 array pointed to by the buf argument.
58
59 @param[in,out] Buf The buffer to fill.
60 @param[in] BufSize The number of bytes in buffer.
61
62 @retval NULL The function failed.
63 @retval NULL Buf was NULL.
64 @retval NULL Size was 0.
65 @return buf The function completed successfully. See errno for info.
66 **/
67 char *getcwd(char *Buf, size_t BufSize);
68 #define GETCWD_DECLARED
69#endif
70
71#ifndef CHDIR_DECLARED
72 /** Change the current working directory.
73
74 The chdir() function shall cause the directory named by the pathname
75 pointed to by the path argument to become the current working directory;
76 that is, the starting point for path searches for pathnames not beginning
77 with '/'.
78
79 @param[in] Path The new path to set.
80
81 @todo Add non-shell CWD changing.
82 **/
83 int chdir(const char *Path);
84#define CHDIR_DECLARED
85#endif
86
87/** Determine accessibility of a file.
88 The access() function checks the file, named by the pathname pointed to by
89 the Path argument, for accessibility according to the bit pattern contained
90 in Mode.
91
92 The value of Mode is either the bitwise-inclusive OR of the access
93 permissions to be checked (R_OK, W_OK, X_OK) or the existence test (F_OK).
94
95 If Path ends in '/' or '\\', the target must be a directory, otherwise it doesn't matter.
96 A file is executable if it is NOT a directory and it ends in ".efi".
97
98 @param[in] Path Path or name of the file to be checked.
99 @param[in] Mode Access permissions to check for.
100
101 @retval 0 Successful completion.
102 @retval -1 File is not accessible with the given Mode. The error condition
103 is indicated by errno. Values of errno specific to the access
104 function include: EACCES, ENOENT, ENOTDIR, ENAMETOOLONG
105**/
106int access(const char *Path, int Mode);
107pid_t getpid(void);
108
109// Networking
110long gethostid(void);
111int gethostname(char *, size_t);
112int getdomainname(char *, size_t);
113int setdomainname(const char *, size_t);
114int sethostid(long);
115int sethostname(const char *, size_t);
116
117/* Stub functions implemented for porting ease.
118 These functions always fail or return NULL.
119*/
120__aconst char *getlogin(void);
121pid_t fork(void);
122uid_t getuid(void);
123
124// For Future implementation
125ssize_t pread(int, void *, size_t, off_t);
126ssize_t pwrite(int, const void *, size_t, off_t);
127int syscall(int, ...);
128
129#if 0 // The following functions are not implemented
130__dead void _exit(int) __attribute__((__noreturn__));
131unsigned int alarm(unsigned int);
132int chown(const char *, uid_t, gid_t);
133size_t confstr(int, char *, size_t);
134int execl(const char *, const char *, ...);
135int execle(const char *, const char *, ...);
136int execlp(const char *, const char *, ...);
137int execv(const char *, char * const *);
138int execve(const char *, char * const *, char * const *);
139int execvp(const char *, char * const *);
140long fpathconf(int, int);
141gid_t getegid(void);
142uid_t geteuid(void);
143gid_t getgid(void);
144int getgroups(int, gid_t []);
145pid_t getppid(void);
146int link(const char *, const char *);
147long pathconf(const char *, int);
148int pause(void);
149int pipe(int *);
150int setgid(gid_t);
151int setpgid(pid_t, pid_t);
152pid_t setsid(void);
153int setuid(uid_t);
154long sysconf(int);
155
156int tcsetpgrp(int, pid_t);
157__aconst char *ttyname(int);
158
159extern int opterr;
160extern int optopt;
161extern int optreset;
162extern char *suboptarg;
163
164int setegid(gid_t);
165int seteuid(uid_t);
166int fdatasync(int);
167int fsync(int);
168int ttyname_r(int, char *, size_t);
169int chroot(const char *);
170int nice(int);
171__aconst char *crypt(const char *, const char *);
172int encrypt(char *, int);
173pid_t getsid(pid_t);
174
175#ifndef intptr_t
176typedef __intptr_t intptr_t;
177#define intptr_t __intptr_t
178#endif
179
180int brk(void *);
181int fchdir(int);
182int fchown(int, uid_t, gid_t);
183int getdtablesize(void);
184__pure int getpagesize(void); /* legacy */
185pid_t getpgid(pid_t);
186int lchown(const char *, uid_t, gid_t);
187int lockf(int, int, off_t);
188ssize_t readlink(const char * __restrict, char * __restrict, size_t);
189void *sbrk(intptr_t);
190int setregid(gid_t, gid_t);
191int setreuid(uid_t, uid_t);
192void swab(const void *, void *, size_t);
193int symlink(const char *, const char *);
194void sync(void);
195useconds_t ualarm(useconds_t, useconds_t);
196pid_t vfork(void) __RENAME(__vfork14);
197
198/*
199 * Implementation-defined extensions
200 */
201int acct(const char *);
202int closefrom(int);
203int des_cipher(const char *, char *, long, int);
204int des_setkey(const char *);
205void endusershell(void);
206int exect(const char *, char * const *, char * const *);
207int fchroot(int);
208int fsync_range(int, int, off_t, off_t);
209int getgrouplist(const char *, gid_t, gid_t *, int *);
210int getgroupmembership(const char *, gid_t, gid_t *, int, int *);
211mode_t getmode(const void *, mode_t);
212int getsubopt(char **, char * const *, char **);
213__aconst char *getusershell(void);
214int initgroups(const char *, gid_t);
215int iruserok(uint32_t, int, const char *, const char *);
216int issetugid(void);
217int nfssvc(int, void *);
218int profil(char *, size_t, u_long, u_int);
219void psignal(unsigned int, const char *);
220int rcmd(char **, int, const char *, const char *, const char *, int *);
221int revoke(const char *);
222int rresvport(int *);
223int ruserok(const char *, int, const char *, const char *);
224int setgroups(int, const gid_t *);
225int setlogin(const char *);
226void *setmode(const char *);
227int setrgid(gid_t);
228int setruid(uid_t);
229void setusershell(void);
230void strmode(mode_t, char *);
231__aconst char *strsignal(int);
232int swapctl(int, void *, int);
233quad_t __syscall(quad_t, ...);
234int undelete(const char *);
235int rcmd_af(char **, int, const char *, const char *, const char *, int *, int);
236int rresvport_af(int *, int);
237int iruserok_sa(const void *, int, int, const char *, const char *);
238#endif /* Unimplemented functions. */
239
240__END_DECLS
241
242#endif /* !_UNISTD_H_ */